drawHighlighted method
Draws all highlight indicators for the values that are currently highlighted.
@param c @param indices the highlighted values
Implementation
@override
void drawHighlighted(Canvas c, List<Highlight>? indices) {
BubbleData? bubbleData = _provider!.getBubbleData();
double phaseY = animator!.getPhaseY();
for (Highlight high in indices!) {
IBubbleDataSet? set =
bubbleData!.getDataSetByIndex(high.dataSetIndex ?? 0);
if (set == null || !set.isHighlightEnabled()) continue;
final BubbleEntry entry =
set.getEntryForXValue2(high.x ?? 0, high.y ?? 0)!;
if (entry.y != high.y) continue;
if (!isInBoundsX(entry, set)) continue;
Transformer trans = _provider!.getTransformer(set.getAxisDependency())!;
sizeBuffer[0] = 0;
sizeBuffer[2] = 1;
trans.pointValuesToPixel(sizeBuffer);
bool normalizeSize = set.isNormalizeSizeEnabled();
// calcualte the full width of 1 step on the x-axis
final double maxBubbleWidth = (sizeBuffer[2]! - sizeBuffer[0]!).abs();
final double maxBubbleHeight =
(viewPortHandler!.contentBottom() - viewPortHandler!.contentTop())
.abs();
final double referenceSize = min(maxBubbleHeight, maxBubbleWidth);
pointBuffer[0] = entry.x;
pointBuffer[1] = entry.y * phaseY;
trans.pointValuesToPixel(pointBuffer);
high.setDraw(pointBuffer[0], pointBuffer[1]);
double shapeHalf = getShapeSize(
entry.size, set.getMaxSize(), referenceSize, normalizeSize) /
2;
if (!viewPortHandler!.isInBoundsTop(pointBuffer[1]! + shapeHalf) ||
!viewPortHandler!.isInBoundsBottom(pointBuffer[1]! - shapeHalf)) {
continue;
}
if (!viewPortHandler!.isInBoundsLeft(pointBuffer[0]! + shapeHalf)) {
continue;
}
if (!viewPortHandler!.isInBoundsRight(pointBuffer[0]! - shapeHalf)) break;
final Color originalColor = set.getColor2(entry.x.toInt());
var hsv = HSVColor.fromColor(originalColor);
var color = hsv.toColor();
highlightPaint
?..color = color
..strokeWidth = set.getHighlightCircleWidth()!;
c.drawCircle(
Offset(pointBuffer[0]!, pointBuffer[1]!), shapeHalf, highlightPaint!);
}
}