Brett89
12 Apr 2012, 10:51 PM
I have a data structure like this:
[
{
Month: 'January',
ID: 1,
Name: 'Foo',
Value: 1
},
{
Month: 'February',
ID: 1,
Name: 'Foo',
Value: 2
},
{
Month: 'March',
ID: 1,
Name: 'Foo',
Value: 3
},
{
Month: 'January',
ID: 2,
Name: 'Bar',
Value: 4
},
{
Month: 'February',
ID: 2,
Name: 'Bar',
Value: 5
},
{
Month: 'March',
ID: 2,
Name: 'Bar',
Value: 6
}
]
Is there a way to present a column chart that is grouped by both Month and ID? Currently, my solution is to change the data structure to be like this:
[
{
Month: 'January',
'Value-1': 1,
'Value-2': 4
},
{
Month: 'February',
'Value-1': 2,
'Value-2': 5
},
{
Month: 'March',
'Value-1': 3,
'Value-2': 6
}
]
And then on store load I'm doing some hacky stuff to change the model's fields, because the number of "Value-x" properties is dynamic. I'm also extracting the ID from "Value-x". The whole thing is just really hacky, and I get the feeling that there is a better way to do this in Ext. Any help would be greatly appreciated.
[
{
Month: 'January',
ID: 1,
Name: 'Foo',
Value: 1
},
{
Month: 'February',
ID: 1,
Name: 'Foo',
Value: 2
},
{
Month: 'March',
ID: 1,
Name: 'Foo',
Value: 3
},
{
Month: 'January',
ID: 2,
Name: 'Bar',
Value: 4
},
{
Month: 'February',
ID: 2,
Name: 'Bar',
Value: 5
},
{
Month: 'March',
ID: 2,
Name: 'Bar',
Value: 6
}
]
Is there a way to present a column chart that is grouped by both Month and ID? Currently, my solution is to change the data structure to be like this:
[
{
Month: 'January',
'Value-1': 1,
'Value-2': 4
},
{
Month: 'February',
'Value-1': 2,
'Value-2': 5
},
{
Month: 'March',
'Value-1': 3,
'Value-2': 6
}
]
And then on store load I'm doing some hacky stuff to change the model's fields, because the number of "Value-x" properties is dynamic. I'm also extracting the ID from "Value-x". The whole thing is just really hacky, and I get the feeling that there is a better way to do this in Ext. Any help would be greatly appreciated.