Used an animation curve in flutter_charts

Viewed 46

I'm using https://pub.dev/packages/charts_flutter to display graphs in my application. Currently I can change the animation duration for the animations but not the animation curve. As an example, I'm using the first example from the gallery.

class SimpleBarChart extends StatelessWidget {
  final List<charts.Series<dynamic, String>> seriesList;
  final bool animate;

  const SimpleBarChart(this.seriesList, {Key? key, this.animate = true})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return charts.BarChart(seriesList,

        animate: animate, animationDuration: const Duration(milliseconds: 250));
  }

  /// Create one series with sample hard coded data.
  static List<charts.Series<OrdinalSales, String>> createSampleData() {
    final data = List.generate(8, (index) => OrdinalSales((2000+index).toString(), Random().nextDouble()));

    return [
      charts.Series<OrdinalSales, String>(
        id: 'Sales',
        colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault,
        domainFn: (OrdinalSales sales, _) => sales.year,
        measureFn: (OrdinalSales sales, _) => sales.sales,
        data: data
      )
    ];
  }
}

Is there a way I can set the curve to be for example Curves.cubic?

0 Answers
Related