Sencha is very well documented and their examples are great. Here is the Pie Chart example we are going to be updating (using version 3.2.1). For those that don't know, extjs charts are based off of Yahoo's YUI charts which is also requires Flash. Not only is it pretty simple to create charts with extjs, but we already are using extjs so we decided to prototype some charts using it.
Here is the code that produces a simple basic PieChart:
new Ext.Panel({ width: 400, height: 400, title: 'Pie Chart with Legend - Favorite Season', renderTo: 'container', items: { store: store, xtype: 'piechart', dataField: 'total', categoryField: 'season', extraStyle: { legend: { display: 'bottom', padding: 5, font: { family: 'Tahoma', size: 13 } } } } });
This produces the following PieChart.
To change the default colors provide a series config option:
new Ext.Panel({ width: 400, height: 400, title: 'Pie Chart with Legend - Favorite Season', renderTo: 'container', items: { store: store, xtype: 'piechart', dataField: 'total', categoryField: 'season', series: [{ style: { colors: ["#ff2400", "#94660e", "#00b8bf", "#edff9f"] } }], extraStyle: { legend: { display: 'bottom', padding: 5, font: { family: 'Tahoma', size: 13 } } } } });
The chart it produces may not look the most appealing but at least we figured out how to change the colors.
Pie Chart with New Colors |
Again, I'm not certain this is the best way to accomplish this as the series config option isn't documented in 3.2.1. But by piecing together this PieChart question and this article, I was able to figure it out.