-
1 Apr 2012 9:23 AM #1
How to show Catagories in the legend instead of the name of the Store's data field
How to show Catagories in the legend instead of the name of the Store's data field
Hi All,
Default behavior of the Ext JS chart is a little strange: While Bar and Column charts shows the Store's data field's name e.g. data1, the Pie chart shows the values of Store's name field e.g. Jan, Feb...
Is it possible to get a behavior like in Pie chart to the Bar and Column charts? I've been searching fro this nearly full 2 days, but couldn't come across anything.PHP Code:var store1 = new Ext.data.JsonStore({
fields:['name', 'data1'],
data: [
{name:'Jan', data1: 2000},{name:'Feb', data1: 1800},
{name:'Mar', data1: 1500},{name:'Apr', data1: 2150},
{name:'May', data1: 2210},{name:'Jun', data1: 2250},
{name:'Jul', data1: 2370},{name:'Aug', data1: 2500},
{name:'Sep', data1: 3000},{name:'Oct', data1: 2580},
{name:'Nov', data1: 2100},{name:'Dec', data1: 2650}
]});
-
1 Apr 2012 9:25 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,118
- Vote Rating
- 453
The legend isn't that configurable.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
1 Apr 2012 9:59 AM #3
Then I have to create my own legend. Can you post the code how to get the color of the bar/column. I tried to get it where I applied custom colors under renderer, but it returns duplicated values, not the exact amount of available data and color. I used Jquery to append the values into a div:
ThanksPHP Code:series: [{
type: 'bar',
axis: ['bottom'],
xField: 'name',
yField: 'data1',
label: {
display: 'insideEnd',
field: 'data1',
orientation: 'horizontal',
color: '#333',
'text-anchor': 'middle',
contrast: true
},
renderer: function(sprite, record, attr, index, store) {
var colorVal = colors2[index % colors2.length];
attr.fill = colorVal;
//$("#legendDiv").append("Value: " + record.get('name') + ", color: " + colorVal);
return attr;
}
}]
});


Reply With Quote