简体   繁体   中英

How to draw the below chart using highchart?

Please help me with how can we draw the below chart using highchart.

I am almost sure that I already answered this question here, but I cannot find it.

Anyway - to split the chart use the yAxis and xAxis plotLines which position you can calculate dynamically in the load callback.

  chart: {
    events: {
      load() {
        const chart = this,
          yAxis = chart.yAxis[0],
          xAxis = chart.xAxis[0];

        xAxis.addPlotLine({
          value: (xAxis.max + xAxis.min) / 2,
          color: 'grey',
          width: 2,
          dashStyle: 'dash'
        });

        yAxis.addPlotLine({
          value: (yAxis.max + yAxis.min) / 2,
          color: 'grey',
          width: 2,
          dashStyle: 'dash'
        });
      }
    }
  },

Demo: https://jsfiddle.net/BlackLabel/5xL7o1kg/

API: https://api.highcharts.com/class-reference/Highcharts.Axis#addPlotLine


To color, the part of the split area use the polygon series type.

Demo: https://jsfiddle.net/BlackLabel/7smLnqad/

chart.addSeries({
  type: 'polygon',
  data: [
    [xAxis.min, yAxis.min],
    [(xAxis.max + xAxis.min) / 2, yAxis.min],
    [(xAxis.max + xAxis.min) / 2, (yAxis.max + yAxis.min) / 2],
    [xAxis.min, (yAxis.max + yAxis.min) / 2],
  ],
  color: 'rgba(244, 198, 245, 0.5)',
  showInLegend: false,
  enableMouseTracking: false,
})

API: https://api.highcharts.com/class-reference/Highcharts.Chart#addSeries

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM