initialVisibleMinimum property
The minimum visible value of the axis. The axis is rendered from this value initially, and it applies only during load time. The value will not be updated when zooming or panning.
Defaults to null
.
Widget build(BuildContext context) {
return Container(
child: SfCartesianChart(
primaryXAxis: NumericAxis(initialVisibleMinimum: 0),
)
);
}
Use the onRendererCreated callback, as shown in the code below, to update the visible minimum value dynamically.
LogarithmicAxisController? axisController;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
SfCartesianChart(
primaryXAxis: LogarithmicAxis(
initialVisibleMinimum: 0,
initialVisibleMaximum: 100,
onRendererCreated: (LogarithmicAxisController controller) {
axisController = controller;
},
),
series: <CartesianSeries<SalesData, num>>[
LineSeries<SalesData, num>(
dataSource: data,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales,
),
],
),
TextButton(
onPressed: () {
if (axisController != null) {
axisController!.visibleMinimum = 30;
axisController!.visibleMaximum = 70;
}
},
child: const Text('Update Axis Range'),
),
],
),
);
}
Implementation
final double? initialVisibleMinimum;