Added Donut Chart support for HighChart ExtJs 4 extension
Donut Chart support is added to the latest HighChart ExtJs 4 extension. The code and an example are included in my latest github. You can also try the demo in joekuan.org. The example uses the same dataset as demonstrated in original Highchart example.
Donut chart basically contains two pie chart series that one is the subcategory of the other one, both series shares a single column of data. Based on the dataset from the Highchart example, the data model for the ExtJs Store would be:
fields: [ 'vendor', 'version', 'share' ]
So the returned Json data should look like this:
0: {version:MSIE 6.0, vendor:MSIE, share:10.85}
1: {version:MSIE 7.0, vendor:MSIE, share:7.35}
2: {version:MSIE 8.0, vendor:MSIE, share:33.06}
3: {version:MSIE 9.0, vendor:MSIE, share:2.81}
Vendor is the main category field (outer ring), whereas version (inner ring) is the drill down of each main category and share is the category data.
The following is the configuration setup for plotting a donut chart:
xtype: 'highchart',
series: [{
type: 'pie',
categorieField: 'vendor',
dataField: 'share',
name: 'Browsers',
size: '60%',
totalDataField: true,
dataLabels: {
formatter: function() {
return this.y > 5 ? this.point.name : null;
},
color: 'white',
distance: -30
}
}, {
type : 'pie',
categorieField : 'version',
dataField: 'share',
name: 'Versions',
innerSize: '60%',
dataLabels: {
formatter: function() {
return this.y > 1 ? '<strong>'+ this.point.name +':</strong> '+ this.y +'%' : null;
}
}
}],
chartConfig: {
...
Most of the configuration settings are derived from the original Highchart example, except the dataField, categorieField and totalDataField. The usages of dataField and categorieField are the same as how you normally use to plot a pie chart in the extension. Because the y-data of the main category, vendor, is the total of it’s own subcategory, an extra field, totalDataField, is required to tell the Highchart extension to compute it’s data differently.
However, if your server dataset already includes the main category total data, then you don’t need to specify totalDataField. All you need to do is to include an extra total field in your store’s model and redirect dataField to that extra field in your series config.





Excellent work, thanks a lot.
It would be sent as part of parameter the color, as does the demo of the pie (http://www.highcharts.com/demo/pie-donut)
In the api documentation is in http://www.highcharts.com/stock/ref/ # series – data
data: [{
name: 'Point 1',
color: '#00FF00',
y: 0
}, {
name: 'Point 2',
color: '#FF00FF',
y: 5
}]
I have a problem, In you demo when I resize the page the chart disapear .
Thanks Andres
Which browser are you using? I can’t get it to disappear when I resize the browser.
chrome
I have tested with Chrome (18.0.1025.162 m) on my Windows 7 Ultimate box and it all works fine. I resize the browser and the chart redraws fine.
I have a video for the issue
http://dl.dropbox.com/u/16337852/test-0000.mpeg
Please can you email me your code instead? kuan.joe@gmail.com
I only dounload the code from https://github.com/JoeKuan/Highcharts_ExtJs_4 in zip format and run
Are you running it with Apache? And what version is your chrome?
I have LAMP and Chrome 18.0.1025.162
Thats really a great work. I hope you will also add the new Highcharts 2.3beta to this extension. The areareange is a very useful chart and it would be great if we can create it with ExtJS4.
Here you can find few more examples:
http://www.highcharts.com/component/content/article/2-news/46-gauges-ranges-and-polar-charts-in-beta