initialZoomFactor property

double initialZoomFactor
final

Defines the percentage of the visible range from the total range of axis values. It applies only during load time and the value will not be updated when zooming or panning.

Scale the axis based on this value, and it ranges from 0 to 1.

Defaults to 1.

Widget build(BuildContext context) {
    return Container(
        child: SfCartesianChart(
           primaryXAxis: NumericAxis(initialZoomFactor: 0.5),
        )
    );
}

Use the onRendererCreated callback, as shown in the code below, to update the zoom factor value dynamically.

NumericAxisController? axisController;

@override
Widget build(BuildContext context) {
  return Scaffold(
    body: Column(
      children: [
        SfCartesianChart(
          primaryXAxis: NumericAxis(
            initialZoomFactor: 0.5,
            onRendererCreated: (NumericAxisController 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!.zoomFactor = 0.3;
           }
          },
          child: const Text('Update ZoomFactor'),
        ),
      ],
    ),
  );
}

Implementation

final double initialZoomFactor;