sfLineCartesianChart method
Implementation
Widget sfLineCartesianChart({List<ChartData>? dados, List<List<ChartData>>? dadosList}) => dados == null && dadosList == null
? const SizedBox()
: SfCartesianChart(
title: ChartTitle(
text: dados![0].title!.replaceRange(dados[0].title!.length - 2, dados[0].title!.length, ''),
alignment: ChartAlignment.near,
textStyle: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 14,
)
),
primaryXAxis: const CategoryAxis(),
margin: const EdgeInsets.all(10),
series: [
if (dados.isNotEmpty && dadosList == null)
LineSeries<ChartData, String>(
dataSource: dados,
xValueMapper: (ChartData data, _) => data.nome,
yValueMapper: (ChartData data, _) => data.valor,
dataLabelMapper: (ChartData data, _) => data.type == int ? '${Features.toFormatNumber(data.valor.toString(), qtCasasDecimais: 0)}' : 'R\$ ${Features.toFormatNumber(data.valor.toString())}',
pointColorMapper: (ChartData data, _) => data.color,
width: 3,
markerSettings: const MarkerSettings(
isVisible: true,
height: 4,
width: 4,
shape: DataMarkerType.circle,
borderWidth: 3,
borderColor: Colors.red,
),
dataLabelSettings: const DataLabelSettings(
useSeriesColor: true,
labelAlignment: ChartDataLabelAlignment.auto,
textStyle: TextStyle(fontSize: 10),
showZeroValue: false,
isVisible: true,
labelPosition: ChartDataLabelPosition.outside,
showCumulativeValues: true,
borderRadius: 7,
),
),
if (dados.isEmpty && dadosList != null)
for (var value in dadosList)
LineSeries<ChartData, String>(
dataSource: value,
xValueMapper: (ChartData data, _) => data.nome,
yValueMapper: (ChartData data, _) => data.valor * 100,
dataLabelMapper: (ChartData data, _) => '${Features.toFormatNumber((data.valor).toString().replaceAll('_', ' '), qtCasasDecimais: 1)}',
pointColorMapper: (ChartData data, _) => data.color,
enableTooltip: true,
width: 3,
markerSettings: const MarkerSettings(
isVisible: true,
height: 4,
width: 4,
shape: DataMarkerType.circle,
borderWidth: 3,
borderColor: Colors.red,
),
dataLabelSettings: const DataLabelSettings(
useSeriesColor: true,
labelAlignment: ChartDataLabelAlignment.auto,
textStyle: TextStyle(fontSize: 10),
showZeroValue: false,
isVisible: true,
labelPosition: ChartDataLabelPosition.outside,
showCumulativeValues: true,
borderRadius: 7,
),
),
],
);