So I have the following data-structure coming back from my server.
{date:'2/1', name: 'product 1', count: 10}
{date:'2/1', name: 'product 2', count: 5}
{date:'2/1', name: 'product 3', count: 15}
{date:'2/2', name: 'product 1', count: 11}
{date:'2/2', name: 'product 2', count: 6}
I have to run through bunch of loops and string manipulation to create the following data-structure for the stacked bar chart.
{date:'2/1', product_1: 10, product_2: 5, product_3: 15 }
{date:'2/2', product_1: 11, product_2: 6, product_3: 0}
Is there a more elegant way to solve this problem. I don’t have much control over the server side of things.
I should think the code to convert from one to the other would be fairly simple.
I don’t think there are any helper classes in Ext for this particular conversion, and I don’t think the chart system can accept different data formats. You could write your own
Modelwhich references the original data, but I think that would be more work than the above code.