我的数据格式为belwo;
,mymy = UnitedStates,65 | UnitedKingdom,58 |德国,30 |印度,60 |俄罗斯,65 |中国,75
代码:
var myarr = mymy.split("|");
var i=0;
var myarr2 = [];
for (i=0;i<myarr.length;i++)
{
var mytemp=myarr[i].split(",");
myarr2[i]=mytemp[0]+','+mytemp[1];
};
var myChart = new JSChart('chartcontainer','bar');
var myData2 = new Array(myarr2);
/*
where mow
myarr2[0]={UnitedStates,65}
myarr2[1]={UnitedKingdom,58}
and so on
*/
myChart.setDataArray(myData2);
myChart.draw();
答案 0 :(得分:0)
看起来dataArray必须是一个数据点数组,每个数据点都是一个标签和值为成员的数组。所以我猜它会是:
var mymy = 'UnitedStates,65|UnitedKingdom,58|Germany,30|India,60|Russia,65|China,75'
var myarr = mymy.split("|");
var myarr2 = [];
for(i=0;i<myarr.length;i++){
var mytemp=myarr[i].split(",");
myarr2[i] = [mytemp[0],mytemp[1]];
};
var myChart = new JSChart('chartcontainer','bar');
myChart.setDataArray(myarr2);
myChart.draw();