PDA

View Full Version : data store and chart issues



Hedgehog
22 Feb 2011, 12:23 PM
Hi.
I'm new to ExtJS so my questions may sound foolish. I need to create a chart, but there are some issues that i can't handle. So here is my problem:

Let's consider this example: http://dev.sencha.com/deploy/dev/examples/chart/stacked-bar-chart.html. As you can see there is a fixed number of fields and series in the data store and chart configuration.
Is there any possibility to enter these parameters separatly from the rest of the config objects ? Something like: store.fields.push(desired_field) and series.push(desired_field) ?
I'm asking this because i need to use a data store whose fields i don't know. They should be acquired from the server and their number and values can be anything. Let's say i have a database containing all those movie genres with the money value for each of them and i need to pass them to the ExtJS script to display the chart. So my question is if there is any way to let the ExtJS script know about all the fields and the series without declaring them explicitly (hardcoded) ?

I've seen some scripts where the data store was loaded from the server, but the fields were declared right there. Only the data was loaded from the server.

Sorry for my bad english. Hoping that i've made myself clear, i'll wait for some ideas.
Thank you in advance.

Hedgehog
26 Feb 2011, 5:10 PM
So... is there no solution for my problem ?... :(
Anyone ? :|

fay
26 Feb 2011, 6:08 PM
One idea(?):

As that example uses a JsonStore, you should be able to pass back metaData json from the server to specify your fields and data, and automatically re-configure your store. See: http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.JsonReader

In the metachange event, you can then use Chart's setSeries method to add the new data. Note, this isn't documented but can be found in the \src\widgets\chart\Chart.js code - I'd recomment you read through this as it shows you how to set axes, etc.

Btw, this is just an idea, I haven't tried it as I've no experience with Charts. Also, you might be better looking at the ExtJS 4 charting as I think this has been completely re-written.