Search code examples
chartshighchartsprojection

Can this stock graph be made using Highstock?


Could this graph be made using Highstock? I'm currently using Highstock, but never saw this kind. Before I waste weeks trying, the question needs to be asked... If yes, how can this be made? by shifting the stock chart, and create another Xaxis at the right?

Stock projection


Solution

  • According to the comments - a similar result could be achieved by adding additional series with proper data.

    Demo: https://jsfiddle.net/BlackLabel/mkpj71n4/

    chart: {
      events: {
        load() {
          let chart = this;
    
          function addNewSeries(y, color) {
            let data = [],
              xValue = startDay,
              yData = 420; // last candle
    
            for (let i = 0; i < 20; i++) {
              xValue = xValue + 30 * 60 * 1000;
              yData = yData + i * y
              data.push([xValue, yData])
            }
            chart.addSeries({
              data: data,
                            color: color
            })
          }
    
          for (let i = 0; i < 4; i++) {
    
            if (i === 0) {
              addNewSeries(0.1, 'orange')
            } else if (i === 2) {
              addNewSeries(-0.1, 'orange')
    
            } else if (i === 3) {
              addNewSeries(0.2, 'red')
    
            } else {
              addNewSeries(-0.2, 'red')
            }
          }
        }
      }
    },
    

    API: https://api.highcharts.com/highcharts/chart.events.load

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