SfSparkBarChart.custom constructor
SfSparkBarChart.custom({
- Key? key,
- int? dataCount,
- SparkChartIndexedValueMapper? xValueMapper,
- SparkChartIndexedValueMapper<
num> ? yValueMapper, - SparkChartPlotBand? plotBand,
- double borderWidth = 2,
- Color? borderColor,
- Color? color,
- bool isInversed = false,
- double axisCrossesAt = 0,
- Color? axisLineColor,
- double axisLineWidth = 2,
- List<
double> ? axisLineDashArray, - Color? highPointColor,
- Color? lowPointColor,
- Color? negativePointColor,
- Color? firstPointColor,
- Color? lastPointColor,
- SparkChartLabelDisplayMode? labelDisplayMode,
- TextStyle? labelStyle,
- SparkChartTrackball? trackball,
Creates the spark bar 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: SfSparkBarChart.custom(
dataCount: 5,
xValueMapper: (int index) => data[index].month,
yValueMapper: (int index) => data[index].sales
)),
);
}
Implementation
SfSparkBarChart.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.borderWidth = 2,
this.borderColor,
this.color,
this.isInversed = false,
this.axisCrossesAt = 0,
this.axisLineColor,
this.axisLineWidth = 2,
this.axisLineDashArray,
this.highPointColor,
this.lowPointColor,
this.negativePointColor,
this.firstPointColor,
this.lastPointColor,
this.labelDisplayMode,
this.labelStyle,
this.trackball})
: _sparkChartDataDetails = SparkChartDataDetails(
dataCount: dataCount,
xValueMapper: xValueMapper,
yValueMapper: yValueMapper),
super(key: key);