angular-highcharts icon indicating copy to clipboard operation
angular-highcharts copied to clipboard

Error while selecting YTD as default zoom in stock chart

Open yash27 opened this issue 6 years ago • 0 comments

In my project, I am using a stock chart having options mentioned below

      this.stock = new StockChart(<any>{
      rangeSelector: {
        selected: 3
      },
      colors: Global.colors,
      title: {
        text: ''
      },
      xAxis: {
        crosshair: true
      },
      yAxis: [
        {
          opposite: true,
          labels: {
            align: 'left',
            x: 5
          },
          height: '60%',
          lineWidth: 2,
          resize: {
            enabled: true
          },
        }, {
          labels: {
            align: 'right',
            x: -3
          },
          top: '65%',
          height: '35%',
          offset: 0,
          lineWidth: 2
        }],
      tooltip: {
        split: true,
        distance: 50,
        padding: 2,
      },
      credits: {
        enabled: false
      },
      legend: {
        enabled: false
      },
      plotOptions: {
        series: {
          marker: {
            enabled: false
          }
        },
      }
    });

Here , I am not setting the rangeSelector in options as it is going to select All as default zoom in stock chart. Now in this, I am adding data dynamically into the chart after initialization of the chart. So when I tried setting the rangeSelector to get the default zoom on the stock chart. It is working when I have set the default zoom to 1M , 3M , 6M , 1Y and All but when I tried to give YTD as default zoom.

rangeSelector : { 
   selected : 3 //For YTD
}

I am getting an error in the console which is

ERROR TypeError: Cannot read property 'substr' of undefined
    at a.Time.dateFormat (highcharts.js:99)
    at RangeSelector.setInputValue (stock.src.js:7517)
    at RangeSelector.render (stock.src.js:7963)
    at a.Chart.eval (stock.src.js:8285)
    at a.Chart.a.(:4200/anonymous function) [as redraw] (webpack-internal:///../../../../highcharts/highcharts.js:20:80)
    at a.Chart.eval (highcharts.js:325)
    at a.fireEvent (highcharts.js:30)
    at a.Chart.addSeries (highcharts.js:325)
    at SafeSubscriber.eval [as _next] (account-stats.component.ts:233)
    at SafeSubscriber.__tryOrSetError (Subscriber.js:247)

When I tried the same with static data that means providing data while initialization, its working fine. But its giving me problem when I am adding data after initializing the chart when I receive data from the server.

yash27 avatar Sep 12 '18 11:09 yash27