Search code examples
javascripthighchartsreact-highchartsangular2-highcharts

Can we have 2 Y-axis for StockCharts in HighCart.js?


Picture as a reference

Picture As A reference

I want to build this type of chart and my data set link is below. I'm unable to find any example regarding this. https://docs.google.com/spreadsheets/d/1geCzzfBeyY8yDHAdEFWUSUf8ex3QWfqDtPg7ArOdTw0/edit?usp=sharing


Solution

  • From the referred image I can see that it is a stock chart, which demo base you can find here: https://www.highcharts.com/demo/stock

    How to align the series to the particular yAxis you can find here: https://api.highcharts.com/highcharts/series.line.yAxis

    Sample demo: https://jsfiddle.net/BlackLabel/95ptgrec/

    // Create the chart
    Highcharts.stockChart('container', {
      yAxis: [{
        title: {
          text: 'axis1'
        }
      }, {
        title: {
          text: 'axis2'
        }
      }, {
        title: {
          text: 'axis3'
        },
        opposite: false
      }],
      series: [{
        data: generateData()
      }, {
        data: generateData(),
        yAxis: 1
      }, {
        data: generateData(),
        yAxis: 2
      }]
    });
    

    If you want to implement charts in Angular or React environment I encourage to use the official wrappers:

    https://github.com/highcharts/highcharts-angular

    https://github.com/highcharts/highcharts-react