Hybrid View
-
18 Jul 2011 8:38 AM #1
Dynamically add series to a chart?
Dynamically add series to a chart?
I am trying to add a new series to an existing chart (the existing chart works fine). This was pretty simple in Ext JS 3, but I can't figure it out in 4. Here is what I've got:
When I call this code, I get the following error:Code:var chart = theGraph.getComponent('intakeChart'); var newSeries = Ext.create('Ext.chart.LineSeries', { type: 'line', id: 'series1', axis: 'left', yField: 'jobcount' }); chart.series.add(newSeries); chart.surface.removeAll(); chart.redraw(false);
"Uncaught TypeError: Cannot read property 'surface' of undefined"
Any ideas on what I'm doing wrong?
-
25 Jul 2011 6:19 PM #2
I too am wondering how this is done. I'd like to avoid re-creating my chart from scratch each time I need to toggle a line. Is this even possible in extjs 4?
-
16 Aug 2011 12:42 AM #3
I have the same problem... anyone got a solution yet?
-
24 Aug 2011 4:23 AM #4
I need the same thing. I would want to define a serie with is own store . Any ideas?
-
24 Aug 2011 4:18 PM #5
*knock knock*... Anybody found the solution to this yet? I'm stuck with the same problem.
-
25 Aug 2011 12:39 AM #6
partially solved
partially solved
Hello all,
I use the following method to add dynamically series to a chart:
This solution works for me, but the next problem is: how to remove a serie dynamically from the chart?Code:// define the new serie (do not use Ext.create()) var serie = { type: 'line' ,axis: 'left' ,smooth: true ,xField: 'name' ,yField: 'data3' }; // add the serie to the chart (the variable 'chart' holds the complete chart component) chart.add(serie); // redraw the chart chart.redraw();
I can 'remove()' them from the chart but the .redraw() function does not update the surface...
I bet the solution will be found by today and I keep you updated...


Reply With Quote