xValueMapper property

  1. @override
ChartIndexedValueMapper<D>? xValueMapper
final

Field in the data source, which is considered as x-value.

Defaults to null.

Widget build(BuildContext context) {
  return SfCartesianChart(
    series: <ColumnSeries<SalesData, num>>[
      ColumnSeries<SalesData, num>(
        dataSource: chartData,
        xValueMapper: (SalesData sales, _) => sales.x,
        yValueMapper: (SalesData sales, _) => sales.y,
      ),
    ],
  );
}

final List<SalesData> chartData = <SalesData>[
  SalesData(1, 23),
  SalesData(2, 35),
  SalesData(3, 19)
];

class SalesData {
  SalesData(this.x, this.y);
    final double x;
    final double y;
}

Implementation

@override
final ChartIndexedValueMapper<D>? xValueMapper;