jqPlot step chart not plotting in series order

后端 未结 2 462
时光说笑
时光说笑 2021-01-27 18:23

I need to build a step chart using jQPlot. My X-Axis is Date/Time and my Y-Axis is a number.

Doing this prototype everything runs fine:



        
2条回答
  •  执念已碎
    2021-01-27 18:38

    Use CategoryAxisRenderer, it will solve your problem and then you dont have to supply min and max.

    You can keep on adding as much data you want it will always plot it correctly.

    Jsfiddle link

    var line1 = [['2014-01-15 15:10:01', 21],
                 ['2014-01-15 15:10:12', 21],
                 ['2014-01-15 15:10:12', 22],
                 ['2014-01-15 15:10:14', 22],
                 ['2014-01-15 15:10:14', 21],
                 ['2014-01-15 15:10:17', 21],
                 ['2014-01-15 15:10:17', 22],
                 ['2014-01-15 15:10:23', 22],
                 ['2014-01-15 15:10:23', 18],
                 ['2014-01-15 15:10:28', 18],
                 ['2014-01-15 15:10:28', 21]];
    
            var plot1 = $.jqplot('chart1', [line1], {
                title: 'Default Date Axis',
                axes: { xaxis: { renderer: $.jqplot.CategoryAxisRenderer } },
                series: [{ lineWidth: 1, markerOptions: { style: 'square' } }]
            });
    

提交回复
热议问题