How to show graph y-value on chart_flutter hover?

Viewed 15

I rendered a time series line graph with charts_flutter. Is there a way to display the chart's y-value when the user hovers over the chart (I think this is a common graph feature). Here's my current code for simply displaying the chart:

Widget _graph() {

    //
    List<TimeSeriesSales> graphData = ...;

    //
    return Container(
        child: charts.TimeSeriesChart(
            [
                charts.Series<TimeSeriesSales, DateTime>(
                    id: 'Sales',
                    colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault,
                    domainFn: (TimeSeriesSales sales, _) => sales.time,
                    measureFn: (TimeSeriesSales sales, _) => sales.sales,
                    data: graphData,
                )
            ],
            animate: false,
            dateTimeFactory: const charts.LocalDateTimeFactory(),
        ),
    );
}

class TimeSeriesSales {
    final DateTime time;
    final int sales;

    TimeSeriesSales(this.time, this.sales);
}
0 Answers
Related