We have requirement that grid data to be shown in chart form,basically would like to convert grid data into aggregate form data that can supplied to charts?
Thanks
Hello annasaheb,
Thank you for posting in the community.
I am attaching a sample illustrating an igDataChart being created upon a button click with data supplied from an igGrid's datasource. Note that the dataSource option of igGrid may be used to acquire the grid's data in json format which can then be used to populate the chart.
Please let me know if you have any questions.
Thanks Peter for prompt answer, sample was helpful, actually I wanted to know how can I aggregate data like group by.
for example, In following data, I would like to total for field "Open" grouped by dates. Is there any way we can get the data from grid?
e.g
var data = [ { "DateString": "1/1/2010", "Open": 1000, "High": 1019.75, "Low": 967.75, "Close": 995 }, { "DateString": "1/1/2010", "Open": 800, "High": 1019.75, "Low": 967.75, "Close": 995 }, { "DateString": "1/2/2010", "Open": 995, "High": 1016.75, "Low": 975, "Close": 1004 }, { "DateString": "1/2/2010", "Open": 925.5, "High": 1000.25, "Low": 912.75, "Close": 999.25 }, { "DateString": "1/3/2010", "Open": 940.25, "High": 1040.25, "Low": 920.75, "Close": 975.25 }, { "DateString": "1/3/2010", "Open": 1020.5, "High": 1060.25, "Low": 999.75, "Close": 1050.25 } ];
function createPieChart() { $("#chart1").igDataChart("destroy"); $('#chart1').igPieChart({ dataSource: data, width: '300px', height: '300px', valueMemberPath: 'Open', labelMemberPath: 'DateString', // explodedSlices: '0 1', radiusFactor: .8, showTooltip: true, tooltipTemplate: '<div class="tooltip">${item.DateString}</div><div>Open: ${item.Open}</div>', legend: { element: 'legend', type: 'item' } });
}
Thank you for your reply.
There is no built in approach for grouping JSON data using the igGrid API, however it should be still possible to achieve this manually:
http://stackoverflow.com/questions/10468978/is-it-possible-to-have-group-by-in-json-data
http://stackoverflow.com/questions/8578814/groupby-in-javascript-to-group-json-data-and-populate-on-optgroup
Please do not hesitate to contact me if you have any questions.