detectOutsideLabelCollision method
Detects whether the current outside label collides with the previous label.
Implementation
@protected
bool detectOutsideLabelCollision(num labelY, bool labelLeftOfChart,
num? previousOutsideLabelY, bool? previousLabelLeftOfChart) {
var collides = false;
// Given that labels are vertically centered, we can assume they will
// collide if the current label's Y coordinate +/- the font size
// crosses past the Y coordinate of the previous label drawn on the
// same side of the chart.
if (previousOutsideLabelY != null &&
labelLeftOfChart == previousLabelLeftOfChart) {
if (labelY > previousOutsideLabelY) {
if (labelY - outsideLabelStyleSpec.fontSize! <= previousOutsideLabelY) {
collides = true;
}
} else {
if (labelY + outsideLabelStyleSpec.fontSize! >= previousOutsideLabelY) {
collides = true;
}
}
}
return collides;
}