[英]How to add Series data in Highcharts from MVC
Using this JFiddle example of Highcharts 使用这个Highcharts的JFiddle示例
http://jsfiddle.net/yxz80f4u/9/ http://jsfiddle.net/yxz80f4u/9/
We can see data being input as 我们可以看到输入的数据为
[Date.UTC(YYYY,MM,DD,HH,MM,SS), Y-data-point]
data: [
[Date.UTC(1970, 7, 5,1,1,1), 2.22],
[Date.UTC(1970, 7, 5,2,2,1), 1.15],
[Date.UTC(1970, 7, 5,2,30,1), 1.15],
[Date.UTC(1970, 7, 5,3,50,1), 0],
[Date.UTC(1970, 7, 5,10,50,1), 2.5],
]
And it is working perfectly. 而且它运行良好。 Now the problem is how can I do the same thing but 现在的问题是我该怎么做
Using arrays of datapoints. 使用数据点数组。
Year_array = ["5/7/1970 1:1:1 AM" , " another year ", etc....] Datapoints= [2.22,1.15, etc...] Year_array = [“ 5/7/1970 1:1:1 AM”,“另一年”,等等。。。数据点= [2.22,1.15等...]
OR from my controller 或从我的控制器
graph_points.year.Add("2015, 1, 2, 9, 29, 00");
graph_points.year.Add("20015, 1, 2, 9, 31, 00");
graph_points.chlorine.Add(10.1);
graph_points.chlorine.Add(10.12);
So how can I do the same thing when I have two arrays of data points as seen? 那么,当我看到两个数据点阵列时,该怎么做?
UPDATE: 更新:
Hi sir, thank you for you suggestion. 您好先生,谢谢您的建议。 Do you mean something like this? 你的意思是这样吗?
for (var i = 0; i < year.length; i++) {
myseries.push(Date.UTC(year[i]),chlorine[i]);
}
UPDATE: Hi Sir, thank you again, one last question ! 更新:主席先生,再次感谢您,最后一个问题! I did what you said 我按照你说的做了
for (var i = 0; i < year.length; i++) {
var datapoint = [];
var d = new Date(Date.parse());
datapoint.push(year[i]); // Year =2/01/2015 9:45:00 AM (format)
datapoint.push(chlorine[i]);
data.push(datapoint);
But it returns 00:00:00 on the x-axis for some reason 但是由于某种原因,它在x轴上返回00:00:00
code like this: 像这样的代码:
for (i = 0; i < Year_array.length; i++){
var dataPoint = [];
dataPoint.push(Year_array(i); dataPoint.push(Datapoints(i));
data.push(dataPoint);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.