HIGHCHARTS onclick按钮可以缩放并缩小xaxis值

时间:2016-06-17 07:50:29

标签: javascript html

我使用Onclick事件放大并缩小图表外部,并放大动态数据选项。这是我的代码

HTML代码

<a href="#" onclick="zoomout()"><span class="glyphicon glyphicon-zoom-out"></span></a>
      <a href="#" onclick="zoomin()"><span class="glyphicon glyphicon-zoom-in"></span></a>

Javascript代码

    function zoomin()
{
  var chart = $('#tv_chart_container').highcharts();
  //data = chart.series[0].data;
  var min = chart.xAxis[0].getExtremes().min,
  max = chart.xAxis[0].getExtremes().max;
  chart.xAxis[0].setExtremes((min + 12 * 3600 * 1000),(max - 12 * 3600 * 1000));
}

Highcharts初始化

series: [{
            name: 'Random data',
            type: 'area',
            color: '#0AB9F1',
             //Dim  - #212F3B
             //Dark - #0AB9F1
            data: (function() {
                // generate an array of random data
                var data = [],
                    time = (new Date()).getTime(),
                    i;

                for (i = -999; i <= 0; i++) {
                    data.push([
                        time + i * 6000,
                        Math.random()*100,
                        Math.random()*100,
                        Math.random()*100,
                        Math.random()*100
                        ]);
                }
                return data;
            })()},{data:[{ x:14654694989093 , y: 50,y: 52,y: 56,y: 57}], color: 'rgba(0,0,0,0)',enableMouseTracking:true}]

0 个答案:

没有答案