小编Ank*_*shi的帖子

动态设置图形点的开始和结束

我正在使用highcharts,我今天默认拥有全天数据.我想动态设置起点和终点.

$(document).ready(function() {
  $.ajax({
            type:'POST',
            dataType: 'JSON',
            url: "http://localhost/data.php",
        success: function(response) {
        var pointstart=response.start_date;
            console.info(response.start_date+" "+response.end_date);
        $('#graph').highcharts({
            chart: {
                type: 'spline',
                zoomType: 'x'
              },
              xAxis: {
                type: 'datetime',
                setExtremes: (response.start_date,response.end_date),
                tickInterval: 3600 * 1000,
                dateTimeLabelFormats: { // don't display the dummy year
                  month: '%e. %b',
                  year: '%b'
                }
              },
            series:[{
                pointStart      : pointstart,
                pointInterval   : 3600 * 1000,
                name: 'cc',
                data: response.data
            }]
                 });
            },
            cache: false
    });
});
Run Code Online (Sandbox Code Playgroud)

问题:我无法在00:00:00到23:59:59看到图表.我每分钟都有单曲.上图显示了我从12:48:01到23:59:01的数据.我正在使用这个测试数据.

注意:在某些情况下,我有多个月的数据,因此需要根据ajax响应start_date和end_date动态设置值.通过

测试数据:http://dpaste.com/2QQQX49

highcharts

0
推荐指数
1
解决办法
80
查看次数

标签 统计

highcharts ×1