所以我试图做一个相当独特的情节,似乎在密谋。我想用时间作为我的x轴刻度,我将绘制2-5行,每个行在数据点之间有不同的时间量。我正在使用zingcharts,他们在一般比例元素上有一些好documentation,但我不知道这是否是可能的情况。
现在他们在相同的时间步长上绘制,然后数据点较少的点(点之间的时间更长)最终变短并且不以真实的方式显示。当我只有一个图表并使用该数据的时间戳但它不能用于两个时,它工作正常。
这是我需要在后端处理的东西还是可以在前端的Zingcharts中完成?
这是我单个情节的javascript工作正常。我是否需要更改此选项以允许上述多个绘图的时间范围?
var myChart=
{
"type": "line",
"title":{
"text":" value over time --- 38 data points"
},
"legend": {},
"tooltip": {},
"crosshair-x":{},
"plot": {
"valueBox": {
"type": "max, min",
"placement": "top",
"visible" : false
}
},
"scaleX": {
"label": {
"text": "Time",
},
"values" : [ 1418947599.0, 1418947599.0, 1418947599.0, 1418947599.0, 1418947599.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, 1418947600.0, ],
"zooming" : true,
},
"scaleY": {
"label": {
"text": "Value"
},
"zooming" : true,
},
"series": [
{
"text" : "sim data - raw value",
"values": [-0.31408204379961535, -0.3140820437996114, -0.3140820437996066, -0.3140820437996098, -0.3140820437996114, -0.31408204379960986, -0.314082043799613, -0.3140820437996122, -0.3140820437996098, -0.31408204379960664, -0.31408204379960825, -0.3140820437996067, -0.3140820437996083, -0.3140820437996114, -0.3140820437996098, -0.3140820437996154, -0.3140820437996114, -0.3140820437996123, -0.31408204379960586, -0.31408204379960913, -0.3140820437996099, -0.31408204379960825, -0.3140820437996098, -0.31408204379960664, -0.3140820437996098, -0.3140820437996114, -0.31408204379960825, -0.31408204379960986, -0.314082043799605, -0.3140820437996099, -0.31408204379960974, -0.3140820437996113, -0.31408204379961147, -0.31408204379960664, -0.3140820437996083, -0.31408204379960997, -0.3140820437996083, -0.31408204379961135]
},
]
};
window.onload=function(){
zingchart.render({
id:"myChartDiv",
data:myChart,
height:600,
width:"100%"
});
};
答案 0 :(得分:3)
分别配置scale-x,scale-x-2和scale-x-n对象,并使用“scales”属性在每个系列对象中设置它们:
"series":[
{
"values": [-0.31408204379961535, -0.3140820437996114, -0.3140820437996066, -0.3140820437996098, -0.3140820437996114, -0.31408204379960986, -0.314082043799613, -0.3140820437996122, -0.3140820437996098, -0.31408204379960664, -0.31408204379960825, -0.3140820437996067, -0.3140820437996083, -0.3140820437996114, -0.3140820437996098, -0.3140820437996154, -0.3140820437996114, -0.3140820437996123, -0.31408204379960586, -0.31408204379960913, -0.3140820437996099, -0.31408204379960825, -0.3140820437996098, -0.31408204379960664, -0.3140820437996098, -0.3140820437996114, -0.31408204379960825, -0.31408204379960986, -0.314082043799605, -0.3140820437996099, -0.31408204379960974, -0.3140820437996113, -0.31408204379961147, -0.31408204379960664, -0.3140820437996083, -0.31408204379960997, -0.3140820437996083, -0.31408204379961135],
"scales":"scale-x,scale-y"
},
{
"values": [-0.31408204379961535, -0.3140820437996114, -0.3140820437996066, -0.3140820437996098, -0.3140820437996114, -0.31408204379960986, -0.314082043799613, -0.3140820437996122, -0.3140820437996098, -0.31408204379960664, -0.31408204379960825, -0.3140820437996067, -0.3140820437996083, -0.3140820437996114, -0.3140820437996098],
"scales":"scale-x-2,scale-y"
}
]
有几点需要注意:
ZingChart使用时间戳(以毫秒为单位),因此您应该在时间戳上添加3个额外的0。
你的scale-x值似乎重复了很多,所以如果你使用[x,y]值对方法,你可能会看到一些时髦的结果。是否应该在每个点之间存在时间间隔,或者在一个系列中是否有多个值可以为每个时间戳绘制?
答案 1 :(得分:2)
这是我第一次尝试使用ZingCharts时抓住了我。但答案其实很简单:
"values": [[x,y],[x,y],...],
或者:
"series": [{"values": [[timestamp,value],[timestamp,value],...]},
{"values": [[timestamp,value],[timestamp,value],...]}]