Hello, I am using AccumulationDistributionIndicator and I get a null check error.
AccumulationDistributionIndicator<GetSymbolChartRespItemDto, DateTime>(
seriesName: 'CandleChart',)
Hi Bar IIan,
We have analyzed your query and we suspect that the volumeValueMapper is not given in the AccumulationDistributionIndicator. AccumulationDistributionIndicator is a volume-based indicator, and it requires volumeValueMapper additionally with the data source to render. As there is no volumeValueMapper available in the candle series, we suggest you assign the same data points for both the candle series and AccumulationDistributionIndicator and you can give volumeValueMapper to the AccumulationDistributionIndicator.
Kindly review the code snippet below:
|
SfCartesianChart( primaryXAxis: DateTimeAxis(), primaryYAxis: NumericAxis(), series: <CartesianSeries<ChartSampleData, DateTime>>[ CandleSeries<ChartSampleData, DateTime>( dataSource: _data, xValueMapper: (ChartSampleData sales, int index) => sales.x, highValueMapper: (ChartSampleData sales, int index) => sales.high, lowValueMapper: (ChartSampleData sales, int index) => sales.low, openValueMapper: (ChartSampleData sales, int index) => sales.open, closeValueMapper: (ChartSampleData sales, int index) => sales.close, ), ], indicators: <TechnicalIndicators<ChartSampleData, DateTime>>[ AccumulationDistributionIndicator( dataSource: _data, xValueMapper: (ChartSampleData sales, int index) => sales.x, highValueMapper: (ChartSampleData sales, int index) => sales.high, lowValueMapper: (ChartSampleData sales, int index) => sales.low, closeValueMapper: (ChartSampleData sales, int index) => sales.close, volumeValueMapper: (ChartSampleData sales, int index) => sales.volume, ), ], ), |
If you have further queries, please get back to us.
Regards,
Hari Hara Sudhan. K
Hi, I used your suggested code but no line for the ADI is showing up even after that. Can you tell me what's the problem
Hi,
Sorry for the inconvenience. In the previous update, we missed attaching the sample below. You can achieve your requirement by adding an additional axis in the SfCartesianChart using the axes property. By doing this, you can display the AccumulationDistributionIndicator by mapping the indicator's name in the yAxisName property. We have shared a code snippet, output, and sample for your reference. You can modify the sample based on your needs. Please let us know if you need any further assistance.
Code Snippet:
|
SfCartesianChart( primaryXAxis: DateTimeCategoryAxis(), primaryYAxis: NumericAxis(), axes: <ChartAxis>[ NumericAxis( axisLine: const AxisLine(width: 0), majorGridLines: const MajorGridLines(width: 0), opposedPosition: true, name: 'yAxes', minimum: -5000000000, maximum: 5000000000, interval: 2500000000, ) ], indicators: <TechnicalIndicators<ChartSampleData, DateTime>>[ AccumulationDistributionIndicator( dataSource: chartData, xValueMapper: (ChartSampleData sales, int index) => sales.x, highValueMapper: (ChartSampleData sales, int index) => sales.high, lowValueMapper: (ChartSampleData sales, int index) => sales.low, closeValueMapper: (ChartSampleData sales, int index) => sales.close, volumeValueMapper: (ChartSampleData sales, int index) => sales.volume, yAxisName: 'yAxes', ), ], series: <ChartSeries>[ CandleSeries<ChartSampleData, DateTime>( dataSource: chartData, xValueMapper: (ChartSampleData data, _) => data.x, lowValueMapper: (ChartSampleData data, _) => data.low, highValueMapper: (ChartSampleData data, _) => data.high, openValueMapper: (ChartSampleData data, _) => data.open, closeValueMapper: (ChartSampleData data, _) => data.close, name: 'CandleChart', ), ], )
|
Screenshot:
Regards,
Lokesh P.