а

dynamic chart data


#1

Hi, I am trying to dynamically build a csv or jsarray object and then pass it to the chart script.
This example is my jsarray attempt.
The charting portion ends with a java script error.
If I hard code a csv or jsarry like your examples, it works fine.
Any help would be appreciated.

Thanks.


#2

var lndata = ‘[’ +’"’+calc1+’"’+","+’"’+calc2+’"’+","+’"’+calc3+’"’+","+’"’+yr+’"’+’]’;

must be

var lndata = [calc1,calc2,calc3,yr];


#3

Stanislav, you rock, thanks very much.


#4

Hi

I have a problem of similar kind, I want to create a bar chart of series type, (3 bar’s similar to the example given here dhtmlx.com/docs/products/dhtmlxC … eries.html),
but I want to load the data using jsarray instead of using json.
I tried to declare the array as below:
var data = [
[100, 125, 245, 147, 67],
[85, 156, 179, 211, 123],
[97, 87, 56, 267, 157]
];

				var myBarChart;
	function doOnLoad() {
		myBarChart =  new dhtmlXChart({
			view:"bar",
			container:"chart1",
			value:"#data1#",
			color: "#58dccd",
			gradient:"rising",
			tooltip:{
				template:"#data1#"
			},
			width:60,
			xAxis:{
        template:function(item){
            return item.$unit;
        },
        value:function(item){
            return item.year;
        },
        units:{
            start:2000,
            end:2004,
            next:function(value){
                return value+1;
            }
        }
    },
			yAxis:{
				start:0,
				step:10,
				end:100
			},
			legend:{
				values:[{text:"Type A",color:"#58dccd"},{text:"Type B",color:"#a7ee70"},{text:"Type C",color:"#36abee"}],
				valign:"middle",
				align:"right",
				width:90,
				layout:"y"
			}
		});
		myBarChart.addSeries({
			value:"#data2#",
			color:"#a7ee70",
			tooltip:{
				template:"#data2#"
			}              
		});
		myBarChart.addSeries({
			value:"#data3#",
			color:"#36abee",
			tooltip:{
				template:"#data3#"
			}
		});
		myBarChart.parse(data,"jsarray");
	}

the x and y-axis are displayed but the values are not being plotted.
can anyone help in using jsarray for this chart?