代码之家  ›  专栏  ›  技术社区  ›  thehme

如何设置Highcharts绘图的最小开始日期?

  •  0
  • thehme  · 技术社区  · 6 年前

    我有10/19到11/01的数据,我正在用一个分散的Highcharts绘图(v4.1.10,无法升级)来绘制它。因为某些原因,我的x轴显示为10/18,但我希望它从10/19开始。我试过用 pointStart ,但这不起作用。关于如何在我的x轴上显示正确的开始日期有什么建议吗?

    Highcharts.chart('container', {
        yAxis: {
        gridLineWidth: 0.5,
      gridLineColor: '#D6D6D6',
      tickInterval: 5,
      dashStyle: 'LongDash',
      lineColor: '#D6D6D6'
    },
    xAxis: {
        type: 'datetime',
        dateTimeLabelFormats: {
          day: '%m/%d',
          week: '%d/%b',
          month: '%b/%y',
          year: '%Y'
        },
        title: {
          enabled: true,
          text: 'date'
        },
        gridLineWidth: 0,
        lineColor: '#D6D6D6',
        lineWidth: 0.5,
        startOnTick: true
    },
    plotOptions: {
        scatter: {
          marker: {
            radius: 5,
            states: {
              hover: {
                enabled: true,
                lineColor: 'rgb(100,100,100)'
              }
            }
          },
          states: {
            hover: {
              marker: {
                enabled: false
              }
            }
          },
          tooltip: this.toolTip
        }
    },
    chart: {
        marginTop: 5,
        marginRight: 0,
        reflow: false,
        backgroundColor: 'rgba(255, 255, 255, 0.1)',
        style: {
          fontFamily: 'Open Sans'
        },
        type: 'scatter',
        spacingBottom: 0,
        spacingTop: 0,
        spacingLeft: 0,
        spacingRight: 0
    },
    tooltip: {
        formatter: function () {
            var s = '<b>' + Highcharts.dateFormat('%m/%d %H:%M:%S', this.x) 
            + ' - ' + Highcharts.numberFormat(this.y, 2);
            return s;
        },
    },
    series: values
    });
    

    jsfiddle code here

    1 回复  |  直到 6 年前
        1
  •  2
  •   jlbriggs    6 年前

    可以设置x轴 min 价值:

    xAxis: {
        min:1539950400000
    

    http://jsfiddle.net/jlbriggs/dwnx6o8e/9/

    根据数据和其他选项,您可能需要查看其他属性,如 startOnTick , tickInterval

    推荐文章