drawVerticalAxesTickLines method
- Canvas canvas,
- ChartAxisRenderer axisRenderer,
- SfCartesianChart chart,
- [String renderType,
- double animationFactor,
- ChartAxisRenderer oldAxisRenderer,
- bool needAnimate]
To draw tick lines of vertical axes
Implementation
@override
void drawVerticalAxesTickLines(
Canvas canvas, ChartAxisRenderer axisRenderer, SfCartesianChart chart,
[String renderType,
double animationFactor,
ChartAxisRenderer oldAxisRenderer,
bool needAnimate]) {
final ChartAxis axis = axisRenderer._axis;
final Rect axisBounds = axisRenderer._bounds;
final List<AxisLabel> visibleLabels = axisRenderer._visibleLabels;
num tempInterval, pointX, pointY, length = visibleLabels.length;
const num padding = 1;
final bool isBetweenTicks = axis is CategoryAxis &&
axis.labelPlacement == LabelPlacement.betweenTicks;
final num tickBetweenLabel = isBetweenTicks ? 0.5 : 0;
length += isBetweenTicks ? 1 : 0;
for (int i = 0; i < length; i++) {
tempInterval = isBetweenTicks
? i < length - 1
? visibleLabels[i].value - tickBetweenLabel
: (visibleLabels[i - 1].value +
axisRenderer._visibleRange.interval) -
tickBetweenLabel
: visibleLabels[i].value;
pointY = (_valueToCoefficient(tempInterval, axisRenderer) *
axisBounds.height) +
axisBounds.top;
pointY = (axisBounds.top + axisBounds.height) -
(pointY - axisBounds.top).abs();
pointX = axisBounds.left + padding - axis.axisLine.width / 2;
if (needAnimate) {
final double oldLocation =
_getPrevLocation(axisRenderer, oldAxisRenderer, tempInterval);
pointY = oldLocation != null
? (oldLocation - (oldLocation - pointY) * animationFactor)
: pointY;
}
if (pointY >= axisBounds.top && pointY <= axisBounds.bottom) {
if (axis.majorGridLines.width > 0 &&
renderType == 'outside' &&
(axis.plotOffset > 0 ||
((i == 0 || i == length - 1) &&
chart.plotAreaBorderWidth == 0) ||
(((i == 0 && !axis.opposedPosition) ||
(i == length - 1 && axis.opposedPosition)) &&
axis.axisLine.width == 0) ||
(axisBounds.top < pointY - axis.majorGridLines.width &&
axisBounds.bottom > pointY + axis.majorGridLines.width))) {
axisRenderer.drawVerticalAxesMajorGridLines(
canvas,
Offset(pointX, pointY),
axisRenderer,
axis.majorGridLines,
i,
chart);
}
if (axis.minorGridLines.width > 0 || axis.minorTickLines.width > 0) {
axisRenderer.drawVerticalAxesMinorTickLines(canvas, axisRenderer,
tempInterval, axisBounds, i, chart, renderType);
}
if (axis.majorTickLines.width > 0 &&
renderType == axis.tickPosition.toString().split('.')[1]) {
_drawDashedPath(
canvas,
_CustomPaintStyle(
axisRenderer.getAxisMajorTickWidth(axis, i),
axisRenderer.getAxisMajorTickColor(axis, i) ??
_chartState._chartTheme.majorTickLineColor,
PaintingStyle.stroke),
Offset(pointX, pointY),
Offset(
!axis.opposedPosition
? (axisRenderer._isInsideTickPosition
? pointX + axis.majorTickLines.size
: pointX - axis.majorTickLines.size)
: (axisRenderer._isInsideTickPosition
? pointX - axis.majorTickLines.size
: pointX + axis.majorTickLines.size),
pointY));
}
}
}
}