I과 유사한는 ExtJS에 그룹화 된 막대 그래프를 플롯하려고를 사용하여 그룹화 막대 차트를 만드는 방법 센차의 example.의 ExtJS -> 2 개 관련 모델에게 (hasMany의 관계)
당신은의 필드 필드를 사용할 수 모델 xField/yField의 차트의 상점 모델에 속하는 하위 모델?
"GolfClubs"이 많은 "Golfer"모델의 경우 골퍼에 속한 각 GolfClub에 대한 막대를 표시하는 그룹화 된 막대 차트를 렌더링 할 수 있습니까 (각 골퍼의 이름은 축 레이블이됩니까)? 엽차의 예에서
가게가 하나 개의 레코드에있는 모든 데이터를 가지고 있지만 나는 그것이 모델 관련된 "hasMany의"자동으로 결합 할 수 있겠죠?
// 모델
Ext.define('GolfClub', {
extend : 'Ext.data.Model',
fields : [{
name : 'ClubType',
type : 'string'
}, {
name : 'Weight',
type : 'float'
}]
});
Ext.define('Golfer', {
extend : 'Ext.data.Model',
requires: ['GolfClub'],
fields : [{
name : 'GolferName',
type : 'string'
}],
hasMany: {model: 'GolfClub', name: 'golfClubs'}
});
// 최종 모델
// 현지 데이터 (그냥 작업하기가 첫번째)
function data(){
var golfers = [];
var rory = Ext.create('Golfer', {
GolferName : 'Rory'
});
var rorysDriver = Ext.create('GolfClub', {
ClubType : 'Driver',
Weight : 80
});
var rorysPutter = Ext.create('GolfClub', {
ClubType : 'Putter',
Weight : 60
});
var rorysSandWedge = Ext.create('GolfClub', {
ClubType : 'SandWedge',
Weight : 50
});
var rorysClubs = rory.golfClubs();
rorysClubs.add(rorysDriver);
rorysClubs.add(rorysPutter);
rorysClubs.add(rorysSandWedge);
golfers.push(rory);
var tiger = Ext.create('Golfer', {
GolferName : 'Tiger'
});
var tigersDriver = Ext.create('GolfClub', {
ClubType : 'Driver',
Weight : 85
});
var tigersPutter = Ext.create('GolfClub', {
ClubType : 'Putter',
Weight : 55
});
var tigersSandWedge = Ext.create('GolfClub', {
ClubType : 'SandWedge',
Weight : 58
});
var tigersClubs = tiger.golfClubs();
tigersClubs.add(tigersDriver);
tigersClubs.add(tigersPutter);
tigersClubs.add(tigersSandWedge);
golfers.push(tiger);
return golfers;
}
// 종료 로컬 데이터
// Local Store
function store1(){
var golferStore = Ext.create('Ext.data.Store', {
model: 'Golfer',
data : data()});
return golferStore;
}
// 끝 지역 상점
Ext.onReady(function() {
var chart = Ext.create('Ext.chart.Chart', {
style: 'background:#fff',
animate: true,
shadow: true,
store: store1(),
legend: {
position: 'right'
},
axes: [{
type: 'Numeric',
position: 'bottom',
fields: ['golfClubs.Weight']
}, {
type: 'Category',
position: 'left',
fields: ['GolferName'],
title: 'Golfer'
}],
series: [{
type: 'bar',
axis: ['bottom'],
xField: ['golfClubs.Weight'],//Is that how you bind to child record?
yField: ['GolferName']
}]
});
var win = Ext.create('Ext.Window', {
width: '100%',
height: '100%',
title: 'Breakdown of Golfers and their Clubs..',
autoShow: true,
layout: 'fit',
items: chart
});
});
건배, 톰.
을이 링크 질문에 대답 할 수 있지만, 여기에 해답의 본질적인 부분을 포함하고 제공하는 것이 좋습니다 링크를 참조하십시오. 링크 된 페이지가 변경되면 링크 전용 답변이 유효하지 않게 될 수 있습니다. - [From Review] (리뷰/저품절 게시물/16974038) –