configurationChanged method
Finish configuring components that require context and graphics factory.
Some components require context and graphics factory to be set again when configuration has changed but the configuration is set prior to the chart first calling init with the context.
Implementation
@override
void configurationChanged() {
if (_newDomainAxis != null) {
markChartDirty();
if (_domainAxis != null) {
removeView(_domainAxis!);
}
_domainAxis = _newDomainAxis;
_domainAxis!
..context = context
..layoutPaintOrder = LayoutViewPaintOrder.domainAxis;
initDomainAxis();
addView(_domainAxis!);
_newDomainAxis = null;
}
if (_newDomainAxisSpec != null) {
markChartDirty();
_domainAxisSpec = _newDomainAxisSpec;
_newDomainAxisSpec!.configure(_domainAxis!, context, graphicsFactory!);
_newDomainAxisSpec = null;
}
if (_primaryMeasureAxisSpec != _newPrimaryMeasureAxisSpec) {
markChartDirty();
_primaryMeasureAxisSpec = _newPrimaryMeasureAxisSpec;
removeView(_primaryMeasureAxis);
_primaryMeasureAxis =
_primaryMeasureAxisSpec?.createAxis() ?? NumericAxis();
_primaryMeasureAxis.tickDrawStrategy = const GridlineRendererSpec<num>()
.createDrawStrategy(context, graphicsFactory!);
_primaryMeasureAxisSpec?.configure(
_primaryMeasureAxis,
context,
graphicsFactory!,
);
addView(_primaryMeasureAxis);
}
if (_secondaryMeasureAxisSpec != _newSecondaryMeasureAxisSpec) {
markChartDirty();
_secondaryMeasureAxisSpec = _newSecondaryMeasureAxisSpec;
removeView(_secondaryMeasureAxis);
_secondaryMeasureAxis =
_secondaryMeasureAxisSpec?.createAxis() ?? NumericAxis();
_secondaryMeasureAxis.tickDrawStrategy = const GridlineRendererSpec<num>()
.createDrawStrategy(context, graphicsFactory!);
_secondaryMeasureAxisSpec?.configure(
_secondaryMeasureAxis,
context,
graphicsFactory!,
);
addView(_secondaryMeasureAxis);
}
if (_disjointMeasureAxesSpec != _newDisjointMeasureAxesSpec) {
markChartDirty();
_disjointMeasureAxesSpec = _newDisjointMeasureAxesSpec;
_disjointMeasureAxes.forEach((axisId, axis) {
removeView(axis);
});
// ignore: prefer_collection_literals, https://github.com/dart-lang/linter/issues/1649
_disjointMeasureAxes = LinkedHashMap<String, NumericAxis>();
_disjointMeasureAxesSpec?.forEach((axisId, axisSpec) {
_disjointMeasureAxes[axisId] = axisSpec.createAxis();
_disjointMeasureAxes[axisId]!.tickDrawStrategy =
NoneDrawStrategy<num>(graphicsFactory!);
axisSpec.configure(
_disjointMeasureAxes[axisId]!,
context,
graphicsFactory!,
);
addView(_disjointMeasureAxes[axisId]!);
});
}
}