highcharts js Y轴从最后一个值开始

qacovj5a  于 2022-11-10  发布在  Highcharts
关注(0)|答案(1)|浏览(154)

我正在使用highchart,我有下面的图表工作。

但是,我需要下一个值从上一个值的点开始。

有人能帮帮我吗?
我用这个函数来生成图表

function generateChart(chartUrl, id) {
  let options = {};

  $.ajax({
    url: chartUrl,
    data: {name: id},
    success: function (data) {
        options.series[0].data = data;

        // Get categories dynamicaly, not harcoded
        for(let i=0;i<data.length;i++){
          options.xAxis.categories.push(data[i][0]);
        }

      $(`#${id}`).highcharts(options);
    }
  });
}

这段代码生成数据和图表效果

function generateEfectsChart() {
  let options = {
    chart: {
      type: 'column'
    },
    title: {
      text: ''
    },
    exporting: {
      enabled: false
    },
    credits: {
      enabled: false
    },
    xAxis: {
      lineColor: '#FFFFFF',
      lineWidth: 0,
      gridLineColor: '#DADBDF',
      categories: [],
    },
    yAxis: {
      lineColor: '#FFFFFF',
      lineWidth: 0,
      gridLineColor: '#DADBDF',
      plotBands: [{
        color: '#000000', // Color value
        from: 0, // Start of the plot band
        to: 0 // End of the plot band
      }],
      title: {
        text: ''
      },
    legend: {
      enabled: false
    },
    plotOptions: {
      column: {
        dataLabels: {
          enabled: true,
          color: '#000000'
        },
        colorByPoint: true,
        pointWidth: 150
      },
      series: {
        borderWidth: 0,
        dataLabels: {
          enabled: true,
          format: '{point.y}'
        },
        turboThreshold: 0
      }
    },
    series: [{
      negativeColor: '#ED4D5F'
    }]
  };

  return options;
}
z0qdvdin

z0qdvdin1#

使用waterfall系列类型。

Highcharts.chart('container', {
    chart: {
        type: 'waterfall'
    },
    ...,
});

现场演示:https://www.highcharts.com/demo/waterfall
文件:https://www.highcharts.com/docs/chart-and-series-types/waterfall-series

相关问题