When updating the data series within a charts_flutter TimeSeriesChart the indicator dot disappears. This link suggests a possible workaround but so far I've no been able to implement it as the explanation doesn't come with a full example. Does anyone have any example whereby they are able to achieve this? Specifically I'm trying to maintain the indicator dot on the graph line whilst also updating Text widget.
Code for TimeSeriesChart:
new charts.TimeSeriesChart(
getSeries(reading),
dateTimeFactory: new charts.UTCDateTimeFactory(),
animate: false,
selectionModels: [
new charts.SelectionModelConfig(
changedListener: _onSelectionChanged,
)
],
behaviors: [
new charts.LinePointHighlighter(
defaultRadiusPx: 20.0,
radiusPaddingPx: 20.0,
showHorizontalFollowLine:
charts.LinePointHighlighterFollowLineType.nearest,
showVerticalFollowLine:
charts.LinePointHighlighterFollowLineType.nearest
),
new charts.SelectNearest(
eventTrigger: charts.SelectionTrigger.tapAndDrag
)
],
primaryMeasureAxis: ...
domainAxis: ...
And then the code for _onSelectionChanged:
_onSelectionChanged(charts.SelectionModel model) {
final selectedDatum = model.selectedDatum;
DateTime time;
final measures = <String, num>{};
num value;
if (selectedDatum.isNotEmpty) {
time = selectedDatum.first.datum.time;
value = selectedDatum.first.datum.value;
selectedDatum.forEach((charts.SeriesDatum datumPair) {
measures[datumPair.series.displayName] = datumPair.datum.value;
if (!datumPair.series.id.contains("min") && !datumPair.series.id.contains("max"))
value = datumPair.datum.value;
});
}
setState(() {
_time = time;
_measures = measures;
_value = value; // This is the value that is used within the `Text` widget
});
}