我花了差不多一个星期的时间,似乎无法知道如何解决它。
我正在尝试使用趋势线创建一个条形图,如下所示:
以下是我的应用程序的一些代码(jSON字符串):
var arr = [20, 60, 10, 50, 25];
var avg = [];
var total = 0, thisAverage = 0;
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j <= i; j++) {
total += arr[j];
}
thisAverage = total / (i + 1)
avg[i] = thisAverage
}
这是我在AngularJS中的JSON字符串:
jsonString += "\"series\": [{";
jsonString += "\"type\": \"bar\",";
jsonString += "\"name\": \"BAR Chart\",";
jsonString += "\"stack\": " + true + ",";
jsonString += "\"color\":\"Red\",";
jsonString += "\"data\": \""+arr+"\",";
jsonString += "}, {";
jsonString += "\"type\": \"line\",";
jsonString += "\"name\": \"Line Chart\",";
jsonString += "\"stack\": "+true+",";
jsonString += "\"color\":\"blue\",";
jsonString += "\"data\": \"" + avg + "\",";
jsonString += " }],";
对此有何帮助?请给我解决方案,在剑道条形图中创建趋势线?