I am using TimeSeriesChart from the flutter_charts package, and the colors of the selected markers are not matching up with their corresponding line color. There is also no data from other series hiding behind these data points.
Since the series is dynamic, I am setting to colorFn using math.Random to generate random colors for each series.
Color((math.Random().nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0))
I'm not sure how this would affect the markers, though, since the series is compiled before the markers are used. Here is the function I'm using to build my series, along with the chart
List<charts.Series<ResultSummary, DateTime>> _createChartData() {
// create chart map
Map<String, List<ResultSummary>> chartMap = {};
ConsumerTargetResults selectedTargetResults = getConsumerTargetResults(resultsPool, [selectedTarget])[0];
Map<String, Color> promptColorMap = {};
promptColorMap['Independent'] = Color((math.Random().nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0);
promptColorMap.addAll(Map.fromIterable(selectedTargetResults.target.prompts, key: (p) =>
p.title, value: (p) => Color((math.Random().nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0))
);
promptColorMap.forEach((key, value) {
List<ResultSummary> resultSummaries = [];
for (Session s in selectedTargetResults.sessions) {
ResultSummary tResultSummary = ResultSummary(s.date, 0, value);
if (s.promptStatsMap[key] != null) tResultSummary.measure = s.promptStatsMap[key];
resultSummaries.add(tResultSummary);
}
chartMap[key] = resultSummaries;
});
// implement to chart
List<charts.Series<ResultSummary, DateTime>> chartDataList = [];
chartMap.forEach((key, value) {
chartDataList.add(
charts.Series<ResultSummary, DateTime>(
id: key,
data: value,
domainFn: (ResultSummary r, _) => r.domain,
measureFn: (ResultSummary r, _) => r.measure,
fillColorFn: (ResultSummary r, _) => r.color,
));
});
return chartDataList;
}
Expanded(
child: Container(
padding: EdgeInsets.fromLTRB(40.0, 10.0, 40.0, 10.0),
child: charts.TimeSeriesChart(
widget.seriesList,
// animate: widget.animate,
animate: false,
behaviors: [ charts.SeriesLegend(
position: charts.BehaviorPosition.end,
outsideJustification: charts.OutsideJustification.endDrawArea,
horizontalFirst: false,
desiredMaxColumns: 1,
cellPadding: EdgeInsets.only(right: 4.0, bottom: 4.0),
entryTextStyle: charts.TextStyleSpec(
color: charts.MaterialPalette.purple.shadeDefault,
fontFamily: 'Georgia',
fontSize: 11),
)],
selectionModels: [
charts.SelectionModelConfig(
type: charts.SelectionModelType.info,
changedListener: _onSelectionChanged,
updatedListener: _onSelectionChanged,
)
],
)),
),