SfSparkLineChart.custom constructor
SfSparkLineChart.custom({
- Key? key,
- int? dataCount,
- SparkChartIndexedValueMapper? xValueMapper,
- SparkChartIndexedValueMapper<
num> ? yValueMapper, - SparkChartPlotBand? plotBand,
- double width = 2,
- List<
double> ? dashArray, - Color color = Colors.blue,
- bool isInversed = false,
- double axisCrossesAt = 0,
- Color axisLineColor = Colors.black,
- double axisLineWidth = 2,
- List<
double> ? axisLineDashArray, - Color? highPointColor,
- Color? lowPointColor,
- Color? negativePointColor,
- Color? firstPointColor,
- Color? lastPointColor,
- SparkChartTrackball? trackball,
- SparkChartMarker? marker,
- SparkChartLabelDisplayMode? labelDisplayMode,
- TextStyle? labelStyle,
Creates the sparkline chart for the provided set of data with its default view.
The difference between the default constructor and this constructor is,
in the default constructor uses its data property to get the input data
value. The data
property of the default constructor is of type List
The custom constructor uses its dataCount
, xValueMapper
and
yValueMapper
to get the input data.
The dataCount
property allows declaring the total data count going to be
displayed in the chart.
The xValueMapper
returns the x value of the corresponding data point.
The xValueMapper
allows providing num, DateTime, or string as x-value.
The yValueMapper
returns the y-value of the corresponding data point.
class SalesData {
SalesData(this.month, this.sales);
final String month;
final double sales;
}
List<SalesData> data;
@override
void initState() {
super.initState();
data = <SalesData>[
SalesData('Jan', 200),
SalesData('Feb', 215),
SalesData('Mar', 380),
SalesData('Apr', 240),
SalesData('May', 280),
];
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: SfSparkLineChart.custom(
dataCount: 5,
xValueMapper: (int index) => data[index].month,
yValueMapper: (int index) => data[index].sales
)
),
);
}
Implementation
SfSparkLineChart.custom(
{Key? key,
/// Data count for the spark charts.
int? dataCount,
/// Specifies the x-value mapping field.
SparkChartIndexedValueMapper<dynamic>? xValueMapper,
/// Specifies the y-value maping field.
SparkChartIndexedValueMapper<num>? yValueMapper,
this.plotBand,
this.width = 2,
this.dashArray,
this.color = Colors.blue,
this.isInversed = false,
this.axisCrossesAt = 0,
this.axisLineColor = Colors.black,
this.axisLineWidth = 2,
this.axisLineDashArray,
this.highPointColor,
this.lowPointColor,
this.negativePointColor,
this.firstPointColor,
this.lastPointColor,
this.trackball,
this.marker,
this.labelDisplayMode,
this.labelStyle})
: _sparkChartDataDetails = SparkChartDataDetails(
dataCount: dataCount,
xValueMapper: xValueMapper,
yValueMapper: yValueMapper),
super(key: key);