buildSeries method

  1. @override
CartesianSeries<ChartData, DateTime> buildSeries(
  1. BuildContext context,
  2. List<ChartData> chartData
)
override

Implementation

@override
CartesianSeries<ChartData, DateTime> buildSeries(BuildContext context, List<ChartData> chartData) {
  return SplineAreaSeries<ChartData, DateTime>(
    animationDuration: 0,
        dataSource: chartData,
        xValueMapper: (ChartData data, _) => DateTime.parse(data.x),
        yValueMapper: (ChartData data, _) => data.y,
        name: 'Values',
        borderColor: color,
        borderWidth: 1.5, // Border thickness for the line
       gradient: LinearGradient(
        colors: [color, color.withValues(alpha: 0)],
        begin: Alignment.topCenter,
        end: Alignment.bottomCenter,
      ),
        splineType: SplineType.cardinal,
        cardinalSplineTension: 0.7,
        markerSettings: MarkerSettings(
          isVisible: false, // Show markers at data points
          height: 3,
          width: 3,
          shape: DataMarkerType.circle,
          borderWidth: 0,
          color: color,
        ),
      );
}