Yu Hsuan Su
Yu Hsuan Su

Reputation: 41

Highstock - SMA (Simple moving average) dataGrouping not working

I'm trying to add SMA (Simple moving average) into my highstock with dataGrouping. dataGrouping works fine without SMA. But when I add SMA it only group data on daily basis. Has anyone got the same problem?

I've checked the chart element and I can see the series & SMA object they all got the dataGrouping attribute but still not display properly in the chart.

I tried to add dataGrouping in both plotOptions.series & plotOptions.sma or add it in series respectively but none of them work.

let dataGrouping = {
  forced: true,
  units: [
    ['week', [1]],
  ]
};

const options = {
   //...
   plotOptions: {
     candlestick: {
       color: 'green',
       upColor: '#e00000',
     },
     series: {
       marker: {
         enabled: false,
       },
       states: {
         hover: {
           enabled: true,
           lineWidth: 1.5,
         }
       },
       dataGrouping,
     },
     sma: {
       dataGrouping,
     }
  },
}

My highcharts verion is 6.0.7

I also tried to add dataGrouping on an official example and here's the link: http://jsfiddle.net/tuuz4yho/8/

and here's another example with a simple line chart https://jsfiddle.net/Lyf6vzev/19/

But dataGrouping still not work on SMA lines. Anyone know how to group SMA weekly or monthly?

Really need your help! Thanks! :)

Upvotes: 3

Views: 716

Answers (1)

Yu Hsuan Su
Yu Hsuan Su

Reputation: 41

Turns out it's a known bug:

https://github.com/highcharts/highcharts/issues/7823

The workaround is setting dataGrouping.approximation and dataGrouping.groupPixelWidth in the indicator config.

Upvotes: 1

Related Questions