如何highcharts组数据时缩小

问题描述 投票:0回答:1

enter image description here

这是我使用的highchart选项:

let min = moment(new Date(1549011531000)).startOf("day").unix() * 1000
let max = moment(new Date(1549011531000)).endOf('day').unix() * 1000
let reportCount = [{"x":1549011531000,"title":"5","text":null},{"x":1549011547000,"title":"10","text":null},{"x":1549011559000,"title":"1","text":null},{"x":1549011577000,"title":"5","text":null},{"x":1549011588000,"title":"5","text":null},{"x":1549011658000,"title":"0","text":null},{"x":1549011682513,"title":"1","text":null},{"x":1549011695000,"title":"2","text":null},{"x":1549011709000,"title":"3","text":null},{"x":1549011726000,"title":"4","text":null},{"x":1549011743000,"title":"5","text":null},{"x":1549011756000,"title":"6","text":null},{"x":1549011769000,"title":"7","text":null},{"x":1549011779000,"title":"8","text":null},{"x":1549011791000,"title":"9","text":null},{"x":1549011802000,"title":"10","text":null}];
let reportLine = [{"x":1549011531000,"y":5},{"x":1549011547000,"y":10},{"x":1549011559000,"y":1},{"x":1549011577000,"y":5},{"x":1549011588000,"y":5},{"x":1549011658000,"y":0},{"x":1549011682513,"y":1},{"x":1549011695000,"y":2},{"x":1549011709000,"y":3},{"x":1549011726000,"y":4},{"x":1549011743000,"y":5},{"x":1549011756000,"y":6},{"x":1549011769000,"y":7},{"x":1549011779000,"y":8},{"x":1549011791000,"y":9},{"x":1549011802000,"y":10}];
let options = {
      tooltip : {
        hideDelay: 0,
      },
      plotOptions : {
        
        series : {
          turboThreshold: 100000,
          pointStart : min,
          pointInterval : 60 * 60 * 1000
          
        }
      },
      chart: {
        height : 180,
        alignTicks: false,
        panning: false,
        zoomType: 'x',
        resetZoomButton: {
          position: {
            align: 'right',
          },
          theme: {
            fill: 'white',
            stroke: 'silver',
            opacity: 0.8,
            r: 0,
            states: {
              hover: {
                fill: '#41739D ',
                style: {
                  color: 'white'
                  
                }
              }
            }
          }
        },
        animation: false
      },
      xAxis: {
        tickLength : 0,
        min : min,
        max : max,
        type : 'datetime',
        tickInterval : 60 * 60 * 1000,
        ordinal: false
      },
      rangeSelector:{
        enabled: false
      },
      navigator: {
        enabled: false
      },
      scrollbar:{
        enabled: false
      },
      title: {
        text: ''
      },
      credits: {
        enabled: false
      },
      legend: {
        adjustChartSize: true,
      },
yAxis : [{
        opposite: false,
        className: "YPR",
        min : 0,
        max : 15,
        tickInterval : 3,
        id: "PR",
        labels: {
          align: 'left',
          x: -6
        },
        title: {
          text: "Reports Graph",
          style: {
            color: '#0082af',
          },
        },
        lineWidth: 2,
      }],
      series: [
        {
          name: "Reports Series",
          data: reportLine,
          id: 'PRLINE',
          yAxis: "PR",
          type: 'line',
          color: 'transparent',
          enableMouseTracking: true,
          zoneAxis: 'y',
        },
        {
          name: "Report",
          type: 'flags',
          data: reportCount,
          shape: 'circle',
          id: 'PR',
          yAxis: "PR",
          style: { // text style
              color: 'white',
              fontFamily: 'Manrope',
          },
          color : '#2c618a',
          fillColor : '#2c618a',
          width: 15,
          height : 15,
          allowOverlapX : true,
          onSeries : 'PRLINE',
          enableMouseTracking: true,
          zoneAxis: 'y',
          states: {
            hover: {
                color : '#2c618a',
                fillColor: '#2c618a', // darker
                lineWidth : 5,
                lineColor : '#2c618a',
            }
          },
          lineColor : '#2c618a',
          lineWidth : 5,
          // y : 10
        }
      ]
    };
    Highcharts.stockChart('report',options)
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highstock/6.0.3/highstock-all.js"></script>
<div id="report" class="chart" style=" width: 100%"></div>

因为有很多在非常微小的数据,该标志很清楚凑钱和不可见的。

我怎么能总结所有的数据并显示为一个单一的标志,当其他标志附近,图表完全处于缩小状态(第1天是最大缩小状态),并在图中被放大,这是可以显示所有的标志,那么它应该显示在相应的位置所有的标志。

javascript highcharts
1个回答
0
投票

您可以通过设置适当的dataGrouping.groupPixelWidth实现它。检查演示和代码贴在下面。

码:

  plotOptions: {
    series: {
      dataGrouping: {
        groupPixelWidth: 100
      }
    }
  }

演示:

API参考:

© www.soinside.com 2019 - 2024. All rights reserved.