Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
172 views
in Technique[技术] by (71.8m points)

javascript - DOJO addSeries method in a loop ploting a graph with commulative sum

While creating a dynamic stacked Line chart in Dojo, i use Chart object's addSeries() method with response (JSON array). here for a while i am using two static data arrays. When addSeries method invocations, the charts get created with their commulative sum. That is not actual data of the graph. Here whats wrong with the addSeries method, not ploting the actual data.

hare the data array is:

var DataArr = new Array (   
                          [20, 30, 30, 30, 30, 45, 50, 0, 30, 119.2, 47.04, 0],
                          [20, 30, 30, 64, 20, 50, 10, 60, 0, 19, 87.04, 50]
                        );

var LegendArr = new Array("one", "two");

var colorArr = new Array("red","blue");

and the addSeries method is as:

for(var i = 0;i<2; i++){
        chart.addSeries(LegendArr[i],DataArr[i], {color:colorArr[i]});
   //   DataArr = [0,0,0,0,0,0,0,0,0,0,0,0];
        alert(DataArr[i]);
      }

the alert result is here, it is correct. enter image description here enter image description here Graph image is as: enter image description here

Here the second line with Blue Legend is not showing the actual data passed in the Array(showing commulative sum). whereas alert message showing the correct data. here what modification in the addSeries method is required to obtain the correct data line.

Thanks in ADVANCE.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

That's how the dojo StackLine plot is designed. It is accumulating the data of the previous series to display them. If you want a different behavior (i.e. no accumulation of values) I guess you can just use a regular Line plot?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...