updateCommonChart method

  1. @override
void updateCommonChart(
  1. BaseChart<num> chart,
  2. BaseChart<num>? oldWidget,
  3. BaseChartState<num> chartState
)
inherited

Updates the common.BaseChart based on changes in the widget properties.

This method is called when the chart widget is updated, allowing the chart to be reconfigured based on the new widget properties.

chart The common.BaseChart instance to update. oldWidget The previous BaseChart widget, if any. chartState The current BaseChartState instance.

Implementation

@override
void updateCommonChart(
  common.BaseChart<D> chart,
  BaseChart<D>? oldWidget,
  BaseChartState<D> chartState,
) {
  super.updateCommonChart(chart, oldWidget, chartState);

  final prev = oldWidget as CartesianChart?;
  final cartesianChart = chart as common.CartesianChart;

  if (flipVerticalAxis != null) {
    cartesianChart.flipVerticalAxisOutput = flipVerticalAxis!;
  }

  if (domainAxis != null && domainAxis != prev?.domainAxis) {
    cartesianChart.domainAxisSpec = domainAxis!;
    chartState.markChartDirty();
  }

  if (primaryMeasureAxis != prev?.primaryMeasureAxis) {
    cartesianChart.primaryMeasureAxisSpec = primaryMeasureAxis;
    chartState.markChartDirty();
  }

  if (secondaryMeasureAxis != prev?.secondaryMeasureAxis) {
    cartesianChart.secondaryMeasureAxisSpec = secondaryMeasureAxis;
    chartState.markChartDirty();
  }

  if (disjointMeasureAxes != prev?.disjointMeasureAxes) {
    cartesianChart.disjointMeasureAxisSpecs = disjointMeasureAxes;
    chartState.markChartDirty();
  }
}