高库存不同的时间值间隔
Highstock different time value interval
我有一个返回图表列表的WebService。这是我的类图的结构:
public class Point
{
public string Date { get; set; }
public float Value { get; set; }
}
public class Serie
{
public string Port { get; set; }
public string Name { get; set; }
public string Unit { get; set; }
public List<Point> Data { get; set; }
}
public class Chart
{
public string Unit { get; set; }
public List<Serie> Series { get; set; }
}
public List<Chart> charts;
我在 js 脚本中使用 HighStock 来显示图表列表中的所有图表。我想按单位对我的系列进行分组,并为每个单位创建一个新的 yAxis 以显示相同的单位系列(见下图)。
这是 js 文件中的代码:
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "WebService.asmx/Channels",
data: "{}",
dataType: "json",
success: function (Charts) {
document.getElementById("debug").innerHTML = Charts.d;
Charts = Charts.d;
var margin = 40,
top = 100,
height = 160,
count = 0;
// Generals options for chart
var options = {
credits: { enabled: false },
chart: {
renderTo: chart,
zoomType: 'x',
alignTicks: false
},
legend: {
enabled: true
},
title: {
text: 'Values'
},
tooltip: {
valueDecimals: 2,
shared: true
},
xAxis: {
ordinal: false
},
yAxis: [],
series: []
};
// Go through Charts
for (var i in Charts) {
// Infos for the yAxis of the serie
// -------------------
options.yAxis.push({
title: {
text: "[" + Charts[i].Unit + "]"
},
labels: {
x: 30,
y: 4,
align: "right",
format: '{value} ' + Charts[i].Unit
},
offset: 0,
top: top,
height: height,
opposite: true
});
// Go through Series in a Charts
for (var j in Charts[i].Series) {
// Infos for the serie
// -------------------
var data = [];
// Go through Data in Series of a Charts
for (var k in Charts[i].Series[j].Data) {
var point = new Array(new Date(Charts[i].Series[j].Data[k].Date).getTime(), Charts[i].Series[j].Data[k].Value);
data.push(point);
}// End: Go through Data in Series of a Charts
count = Number(i);
// Add a serie and these attributes
options.series.push({
name: Charts[i].Series[j].Name,
data: data,
tooltip: {
valueSuffix: ' ' + Charts[i].Series[j].Unit,
valueDecimals: 3
},
yAxis: count
});
}// End: Go through Series in a Charts
count++;
top += height + margin;
}// End: Go through Charts
options.chart.height = top + 190;
Highcharts.StockChart(options);
},
error: function (xhr, thrownError) {
//alert("Error : " + xhr.status + "'nMessage : 'n" + xhr.responseText);
document.getElementById("debug").innerHTML = "Error : " + xhr.status + "'nMessage : 'n" + xhr.responseText;
}
});
});
</script>
如果我运行代码:
空白页无图表
我遇到的错误是:
未捕获的类型错误:无法读取未定义的属性"clientX">高库存.js:177
还有(有时)这个错误:
未捕获的类型错误:无法读取未定义的属性"信息"> highstock.js:342(与 #line 无关)
如果我删除具有不同间隔的系列,或者如果取消选择 Vbatt 系列(具有不同间隔的系列),它有效:
显示我的所有图表
我花了很多时间在互联网和堆栈溢出上,以找到我的问题,但是......无。。。
编辑:
-> 我们可以在同一张图表上绘制的最大系列是多少?
-> 我们可以在同一张图表上绘制的最大点是多少?
提前感谢您的反馈。
此致敬意
史蒂夫
问题解决了!
问题是我的网络服务发送的纪元数据以秒为单位,而 HighStock 需要有毫秒。
问题解决了!
问题是我的网络服务发送的纪元数据以秒为单位,而 HighStock 需要有毫秒。
相关文章:
- 高库存时期时间与时区不匹配
- 无法让getjson在高库存上工作
- 单点高库存滚动条问题
- 高库存 - 时间轴滴答声不是连续的
- 高图表(高库存):从外部 CSV 获取数据,无法正确显示日期
- 高库存 - 使用日期时间轴时在列之间放置一条线
- 高库存 - 更改超出数据最大值的输入范围
- 为什么高库存范围选择器中有禁用的按钮
- 高图表高库存工具提示系列顺序
- 呈现高库存日期时出错
- 高库存不同的时间值间隔
- 高库存数据点像素间距
- 高库存 - 在日期时间轴上使用刻度线放置“之间”(无类别)
- 显示带有高库存的 json 文件
- 通过推送数组将数据添加到高库存
- 以编程方式读取散点图的值 - 高库存
- 将高库存标志更改为 xAxis 上的线条
- 使用自定义 html 打印高库存
- 高库存-不规则的时间间隔
- 高库存x轴总是时间