使用AngularJS在剑道条形图中显示趋势线

时间:2016-08-19 07:01:07

标签: angularjs json kendo-ui kendo-chart

我花了差不多一个星期的时间,似乎无法知道如何解决它。

我正在尝试使用趋势线创建一个条形图,如下所示:

Trendline in Bar Chart

以下是我的应用程序的一些代码(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 += " }],";

对此有何帮助?请给我解决方案,在剑道条形图中创建趋势线?

0 个答案:

没有答案