javascript - A few tables in one chart use amchart -


i have 1 question you. data chart looks like:

var chartdatafull=[] chartdata1=[{category:1, value:2},{category:2, value:3},{category:3, value:6}]; chartdata2=[{category:1, value:5},{category:2, value:1},{category:3, value:2}]; chartdata3=[{category:1, value:3},{category:2, value:9},{category:3, value:7}];  chartdatafull.push(chartdata1, chartdata2, chartdata3); 

i 3 table put on 1 chart (different "value" same field "category") amchart. each represented separate column. how can do this?

using code fill graph (access multidimensional array index):

var chartdatafull=[] chartdata1=[{category:1, value:2},{category:2, value:3},{category:3, value:6}]; chartdata2=[{category:1, value:5},{category:2, value:1},{category:3, value:2}]; chartdata3=[{category:1, value:3},{category:2, value:9},{category:3, value:7}];  chartdatafull.push(chartdata1); chartdatafull.push(chartdata2); chartdatafull.push(chartdata3); 

first solution:

display 1 dataset inside graph option of switching in between them.

code:

chart.dataprovider = chartdatafull[1]; //switch index here if want graph based on datasets. range (0-2).

  chart = new amcharts.amserialchart();     chart.automarginoffset = 0;     chart.dataprovider = chartdatafull[1]     chart.categoryfield = "category";     chart.startduration = 1; 

fiddle example: http://jsfiddle.net/cww3d/448/

second solution

this solution get's closest need's. done concataneting array's. you've mentioned arrays not static, still can adjust concat() function suit needs.

code:

chartdatafull.push(chartdata1); chartdatafull.push(chartdata2); chartdatafull.push(chartdata3); var children = chartdata1.concat(chartdata2,chartdata3); 

url fiddle: http://jsfiddle.net/eugensunic/cww3d/452/

official example

fiddle example:

url fiddle: http://jsfiddle.net/amcharts/u3ypb/

you can see when displaying other dataset, placing in chart.

conclusion:

unfortunately once populate dataset using dataprovider attribute that's pretty it. you've created graph , can not modify in way insert additional data. once operation attribute filled done data population.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -