-
26 Aug 2011 4:16 PM #11
Was there anything else you did for the code above? I'm still getting the surface of undefined error.
-
30 Aug 2011 1:55 AM #12
Hey,
the removing of the series works for me, but the chart.add gives me the error
(Uncaught TypeError: Object [object Object] has no method 'add')
the series object of the chart has the add-method for me, but when using this the chart doesnt draw itself correctly. ( chart.series.add(..); )
How come? Oo
-
30 Oct 2011 9:20 PM #13
Hi All,
i have tried code give by electronix but it doesnt worked for me, it was showing me error
but i have fixed it by replacing chart.redraw withchart.redraw is not a function
Now its not showing any error also its not displaying graph.chart.items.items[0].redraw();
Please help.
-
13 Dec 2011 2:21 AM #14
find solution
find solution
Hello.
I have found this solution: at first we delete all old series :
Then we simply add new series like :Code:var removeChart = function() { var series = this.chart.series.items, surface = this.chart.surface, length = series.length, len = surface.groups.keys.length, array = [], i = 0, j = 0, t = 0; for(; i < length; i++) { array = Ext.Array.merge(array, series[i].group.keys); } this.chart.series.clear(); for(; j < array.length; j++) { surface.items.getByKey(array[j]).destroy(); } for(; t < len; t++) { surface.groups.items[t].destroy(); } },
I use this code when dynamically change chart series from type: 'line' to type: 'column'.Code:chart.series.add({ type: 'column', axis: 'left', gutter: 30, groupGutter: 3, title: ['1', '2', '3'], xField: ['count'], yField: ['name1', 'name2', 'name3'] });
-
25 Jan 2012 3:17 AM #15
There's no add() on chart in 4.0.7. Use:
Code:var series = []; // Setup your series chart.series.addAll(series); chart.redraw();
-
2 Mar 2012 6:14 AM #16
thank you electronix, that works fine, but I think you meant
if(surface.groups.keys[groupKey].search(seriesId) != 0)
-
2 Sep 2012 7:45 PM #17
[QUOTE=gcrshiye21;881714]I meet this problem too,and can't be resolve perfect so i use a container out of the chart and a store for this container so I can't calculate how many series i shold draw and when the store is load calculate it again here is the code
Code:Code:constructor : function(config) { var me=this; me.store=Ext.create('com.suning.portal.chart.Line.MutipleLineStore',{storeUrl:baseUrl+ 'ueTask/userExpMutipleChartView.htm'}); me.store.addListener('load_complete',function(success,record,xField,yFields){ if(!success){ return; }else{ if(typeof(record)!=undefined&&record.length!=0){ var chartFields=xField.concat(yFields); if(typeof(me.chart)=='undefined'||!(me.preYFields.sort().toString()==yFields.sort().toString())){ var chartAxes=me.initAxes(xField,yFields); var chartSeries=me.initSeries(xField,yFields); var chartStore=Ext.create('Ext.data.Store', { fields: chartFields, data : record }); me.chart=Ext.create('Ext.chart.Chart',{ theme : 'Category3', store:chartStore, legend:true, axes:chartAxes, series:chartSeries }); me.removeAll(); me.add(me.chart); me.preYFields=yFields; }else{ if(typeof(me.chart.store)!='undefined'){ me.chart.store.loadData(record); } } } } });
-
18 Oct 2012 9:25 AM #18
Line Chart
Line Chart
This solution is fine por Line Chart.... it hasnt got SURFACE object

any solution ?
Thx 4 all!!
-
21 Feb 2013 9:00 AM #19
Anyone have any updates on how to properly load line charts dynamically?
I have a copy of my store (below) that loads the data that is used for the line chart and builds all the new series and axes properties. Unfortuantely all my new series values are slammed to the left along the x-axis and do not populate on the appropriate y-axis value. Please let me know if you spot something with my code that'll clear this issue.
Image of graph after above store is processed for a date range.Code:var analyticsLineStore = Ext.create('Ext.data.Store', { autoLoad: false, autoSync: true, model: 'AnalyticsLine', proxy: { type: 'ajax', api:{ read: 'adminprocess.php?analyticsLine' }, reader: { root: 'data' }, afterRequest:function(request,success){ var chart = Ext.getCmp('lineChart'); var variables = this.reader.jsonData ; var chart_series = []; var visit = []; var vis = ""; var visitorsField = []; var vs ="avg"; var i = 0; var j = 0; visitorsField[j] = {name: 'date_range', type: 'string'} j = j+1; visitorsField[j] = {name: 'avg', type: 'float'} if(variables.info) { chart.surface.destroy(); for(i = 0; i <= variables.info.length-1; i++) { if(visit == '') { vis = 'visitors_'+variables['info'][i].analytics.replace(' ','_'); visit = vis; } else { vis = 'visitors_'+variables['info'][i].analytics.replace(' ','_'); } j = j +1 ; visitorsField[j] = {name: vis.replace(' ','_'), type: 'float'} ; vs = vs +','+ vis.replace(' ','_'); } this.model = Ext.destroy('AnalyticsLine'); this.model = Ext.define('AnalyticsLine', { extend: 'Ext.data.Model', fields: visitorsField }); chart.axes.clear(); chart.axes.add({ type: 'Category', position: 'bottom', fields: ['date_range'], title: false, grid: true, label: { font: '11px Arial', renderer: function(date_range) { return date_range; } } }); chart.axes.add({ type: 'Numeric', minimum: 0, position: 'left', fields: [vs], title: 'Visitors', grid: true, label: { renderer: Ext.util.Format.numberRenderer('0,0'), font: '10px Arial' } }); chart.series.clear(); chart.series.add({ axis: 'left', type: 'line', yField: 'date_range', xField: [vs], style: { 'stroke-width': 3 }, markerConfig: { type: 'circle', size: 4, radius: 4, 'stroke-width': 0 } }); chart.createSurface(); chart.redraw(); } } } });
lineChart.jpg
-
28 Feb 2013 7:58 AM #20
I was able to solve this by creating a new chart within the store and having it renderTo the object id I wanted the chart to draw into.
example code to follow.


Reply With Quote