将面积图与highcharts.js中的折线图相结合

时间:2016-08-10 18:41:30

标签: javascript highcharts

所以我有一个区域堆积图表:

chart: {
      type: 'area',
    },
    plotOptions: {
      series: {
        stacking: 'normal',
      },
      area: {
        events: {
          legendItemClick: function () {
            return false; // <== returning false will cancel the default action
          },
        },
      },
    },
    title: {
      text: title,
    },
    xAxis: {
      type: 'datetime',
      min: startDateInMS,
      max: endDateInMS,
    },
    yAxis: {
      title: {
        text: yLabel,
      },
    },
    series: data,
    credits: {
      enabled: false,
    },
  };

如何将订单项/图表添加到我已有的订单项/图表中?我查看了文档,但他们并没有将线与面积图合并的例子。

谢谢!

1 个答案:

答案 0 :(得分:4)

Highcharts支持组合不同类型的图表,如下所示:

http://www.highcharts.com/docs/chart-and-series-types/combining-chart-types

series: [{
        type: 'area',
        name: 'Jane',
        data: [3, 2, 1, 3, 4]
    }, {
        type: 'line',
        name: 'John',
        data: [2, 3, 5, 7, 6]
    }, 

组合区域和线条看起来像这样:

http://jsfiddle.net/henrikskar/ateje82r/