drawValues method
Loops over all Entrys and draws their values.
@param c
Implementation
@override
void drawValues(Canvas c) {
BubbleData? bubbleData = _provider!.getBubbleData();
if (bubbleData == null) return;
// if values are drawn
if (isDrawingValuesAllowed(_provider!)) {
final List<IBubbleDataSet> dataSets = bubbleData.dataSets;
double lineHeight = Utils.calcTextHeight(valuePaint!, "1").toDouble();
for (int i = 0; i < dataSets.length; i++) {
IBubbleDataSet dataSet = dataSets[i];
if (!shouldDrawValues(dataSet) || dataSet.getEntryCount() < 1) continue;
// apply the text-styling defined by the DataSet
applyValueTextStyle(dataSet);
final double phaseX = max(0.0, min(1.0, animator!.getPhaseX()));
final double phaseY = animator!.getPhaseY();
xBounds!.set(_provider!, dataSet);
List<double?> positions = _provider!
.getTransformer(dataSet.getAxisDependency())!
.generateTransformedValuesBubble(
dataSet, phaseY, xBounds!.min!, xBounds!.max!);
final double alpha = phaseX == 1 ? phaseY : phaseX;
ValueFormatter? formatter = dataSet.getValueFormatter();
MPPointF iconsOffset = MPPointF.getInstance3(dataSet.getIconsOffset());
iconsOffset.x = Utils.convertDpToPixel(iconsOffset.x);
iconsOffset.y = Utils.convertDpToPixel(iconsOffset.y);
for (int j = 0; j < positions.length; j += 2) {
Color valueTextColor =
dataSet.getValueTextColor2(j ~/ 2 + xBounds!.min!);
valueTextColor = Color.fromARGB((255.0 * alpha).round(),
valueTextColor.red, valueTextColor.green, valueTextColor.blue);
double? x = positions[j];
double? y = positions[j + 1];
if (!viewPortHandler!.isInBoundsRight(x)) break;
if ((!viewPortHandler!.isInBoundsLeft(x) ||
!viewPortHandler!.isInBoundsY(y))) continue;
BubbleEntry entry = dataSet.getEntryForIndex(j ~/ 2 + xBounds!.min!)!;
if (dataSet.isDrawValuesEnabled()) {
drawValue(
c,
formatter!.getBubbleLabel(entry),
x!,
y! + (0.5 * lineHeight),
valueTextColor,
dataSet.getValueTextSize(),
dataSet.getValueTypeface());
}
if (entry.mIcon != null && dataSet.isDrawIconsEnabled()) {
CanvasUtils.drawImage(
c,
Offset(x! + iconsOffset.x, y! + iconsOffset.y),
entry.mIcon!,
const Size(15, 15),
drawPaint!);
}
}
MPPointF.recycleInstance(iconsOffset);
}
}
}