简体   繁体   English

使用时间作为x轴的多行图

[英]zingcharts using time as x axis with multiple lines

So I am trying to do a rather unique case of plotting it seems. 因此,我正在尝试绘制一个看起来很独特的情况。 I want to use time as my x-axis scale and I will have 2-5 lines being plotted, each with a different amount of time between datapoints. 我想将时间用作我的x轴比例,并且将绘制2-5条线,每条线在数据点之间的时间不同。 I am using zingcharts and they have some good documentation on general scale elements but I don't know if this is a case that is possible. 我正在使用zingcharts,它们在常规比例尺元素上有一些不错的文档 ,但是我不知道这是否有可能。

Right now they plot on the same timestep and then the one that has less datapoints (greater time between points) ends up being shorter and not being displayed in a true manner. 现在,它们以相同的时间步进行绘制,然后数据点较少(点之间的时间较长)的数据点变短了,并且没有以真实的方式显示。 It works fine when I have only one chart and use that data's timestamp but it doesn't work for two. 当我只有一个图表并使用该数据的时间戳时,它工作正常,但对于两个图表却无效。

Is this something I need to handle on the backend or can this be done in Zingcharts on the frontend? 这是我需要在后端处理的事情,还是可以在前端的Zingcharts中完成?

This is my javascript of a single plot that works fine. 这是我的单个剧情的javascript,效果很好。 Do I need to change this to allow for the above time scale with multiple plots? 我是否需要更改此值以在多个绘图中考虑上述时间比例?

    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%"
        });
    };

Luke is correct. 卢克是正确的。 You can use [x,y] values pairs within your values array, or you can assign the other series to another scale-xn object, as seen here . 您可以使用[X,Y]你的价值观阵列中的值对,也可以与其他系列分配给另一个尺度xn的对象,看到这里

Configure your scale-x, scale-x-2, and scale-xn objects individually, and set them in each series object using the "scales" attribute: 分别配置scale-x,scale-x-2和scale-xn对象,并使用“ 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"
}
]

A couple of things to note: 需要注意的几件事:

ZingChart uses timestamps in milliseconds, so you should add 3 additional 0's to your timestamps. ZingChart使用时间戳(以毫秒为单位),因此您应该在时间戳上添加3个额外的0。

Your scale-x values seem to repeat quite a bit, so if you're using the [x,y] value pair method, you may see some funky results. 您的scale-x值似乎重复了很多,因此,如果您使用[x,y]值对方法,则可能会看到一些时髦的结果。 Are there supposed to be gaps in time between each point, or are there multiple values to plot for each timestamp, in a single series? 是否应该在单个序列中每个点之间存在时间间隔,或者每个时间戳都需要绘制多个值?

This caught me out the first time I tried to use ZingCharts. 这是我第一次尝试使用ZingCharts时遇到的麻烦。 But the answer is actually quite simple: 但是答案实际上很简单:

"values": [[x,y],[x,y],...],

Or: 要么:

"series": [{"values": [[timestamp,value],[timestamp,value],...]},
           {"values": [[timestamp,value],[timestamp,value],...]}]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ZingCharts水平堆积条形图X轴标签被切断 - ZingCharts horizontal stacked bar chart X-Axis labels being cut off 在 x 轴 Highcharts 上绘制多条线 - Plot multiple lines on x-axis Highcharts Highcharts:如何在同一个x轴上添加多行 - Highcharts: How to add multiple lines on the same x-axis 在具有额外维度的 ChartJS 上对多行上的 x 轴标签进行分组 - Grouping x-axis labels on multiple lines on a ChartJS with an extra dimension 如何使用chartjs将x轴值和线点移动到两条x轴线的中间? - How to move the x-axis values and line points to the middle of two x-axis lines using chartjs? 如何使用chartjs删除X轴上的多余线条? - How to remove excess lines on X axis using chartjs? amchart-使用同一X轴的多个Y轴 - amchart - Multiple Y-axis using the same X-axis 如何使用自定义的x轴在同一张图中绘制多个时间序列 - how to plot multiple time series in the same graph with customized x axis 使用react-chart-js-2和reactapp不会在x轴上显示时间 - time on x axis is not appearing using react-chart-js-2 with reactapp 在 ECharts 的 X 轴上使用 'time' 类型进行时间序列图 - Using 'time' type on X axis of ECharts for timeseries graphing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM