updateSegmentColor method
void
updateSegmentColor(
- ChartSegment segment,
- Color? borderColor,
- double borderWidth, {
- Color? fillColor,
- bool isLineType = false,
Implementation
void updateSegmentColor(
ChartSegment segment, Color? borderColor, double borderWidth,
{Color? fillColor, bool isLineType = false}) {
Color color;
Color strokeColor;
double strokeWidth;
final Color effColor = effectiveColor(segment.currentSegmentIndex);
if (segment.isEmpty) {
color = (isLineType && emptyPointSettings.mode == EmptyPointMode.zero)
? fillColor ?? effColor
: emptyPointSettings.color;
// The purpose of isLineType is to set a default border color for
// both line-type series and financial-type series.
strokeColor = isLineType ? color : emptyPointSettings.borderColor;
strokeWidth = emptyPointSettings.borderWidth;
} else {
color = fillColor ?? effColor;
strokeColor = borderColor ?? effColor;
strokeWidth = borderWidth;
}
if (opacity != 1.0) {
if (color != Colors.transparent) {
color = color.withOpacity(opacity);
}
if (strokeColor != Colors.transparent) {
strokeColor = strokeColor.withOpacity(opacity);
}
}
if (effectiveSelectionBehavior != null &&
effectiveSelectionBehavior!.enable &&
parent != null &&
parent!.selectionController.hasSelection) {
if (isSelected || segment.isSelected) {
final double opacity = effectiveSelectionBehavior!.selectedOpacity;
color = effectiveSelectionBehavior!.selectedColor ?? color;
if (color != Colors.transparent) {
color = color.withOpacity(opacity);
}
strokeColor =
effectiveSelectionBehavior!.selectedBorderColor ?? strokeColor;
if (strokeColor != Colors.transparent) {
strokeColor = strokeColor.withOpacity(opacity);
}
strokeWidth =
effectiveSelectionBehavior!.selectedBorderWidth ?? strokeWidth;
} else {
final double opacity = effectiveSelectionBehavior!.unselectedOpacity;
color = effectiveSelectionBehavior!.unselectedColor ?? color;
if (color != Colors.transparent) {
color = color.withOpacity(opacity);
}
strokeColor =
effectiveSelectionBehavior!.unselectedBorderColor ?? strokeColor;
if (strokeColor != Colors.transparent) {
strokeColor = strokeColor.withOpacity(opacity);
}
strokeWidth =
effectiveSelectionBehavior!.unselectedBorderWidth ?? strokeWidth;
}
}
segment.fillPaint.color = color;
segment.strokePaint
..color = strokeColor
..strokeWidth = strokeWidth;
}