pointShaderMapper property

ChartShaderMapper? pointShaderMapper
final

Returns the shaders to fill each data point.

The data points of pie, doughnut and radial bar charts can be filled with gradient (linear, radial and sweep gradient) and image shaders.

A shader specified in a data source cell will be applied to that specific data point. Also, a data point may have a gradient and another data point may have an image shader.

The user can also get the data, index, color and rect values of the specific data point from ChartShaderMapper and can use this method, for creating shaders.

Defaults to null.

import 'dart:ui' as ui;

Widget build(BuildContext context) {
   return Container(
       child: SfCircularChart(
           series: <PieSeries<ChartData, String>>[
             PieSeries<ChartData, String>(
               dataSource: <ChartData>[
                  ChartData('USA', 10, ui.Gradient.radial(Offset(112.4, 140.0), 90, [
                           Colors.pink,
                           Colors.red,
                         ], [
                           0.25,
                         0.5,
                         ]),),
                  ChartData('China', 11, ui.Gradient.sweep(Offset(112.4, 140.0),[
                           Colors.pink,
                           Colors.red,
                         ], [
                           0.25,
                         0.5,
                         ]),),
               ],
               xValueMapper: (ChartData data, _) => data.xVal,
               yValueMapper: (ChartData data, _) => data.yVal,
               pointShaderMapper: (ChartData data, _, Color color, Rect rect) => data.pointShader,
             ),
          ],
       )
  );
}
class ChartData {
  ChartData(this.xVal, this.yVal, [this.pointShader]);
  final String xVal;
  final int yVal;
  final Shader pointShader;
}

Implementation

final ChartShaderMapper<dynamic>? pointShaderMapper;