drawValues method
Loops over all Entrys and draws their values.
@param c
Implementation
@override
void drawValues(Canvas c) {
double phaseX = animator!.getPhaseX();
double phaseY = animator!.getPhaseY();
double sliceAngle = _painter!.getSliceAngle();
// calculate the factor that is needed for transforming the value to
// pixels
double factor = _painter!.getFactor();
MPPointF center = _painter!.getCenterOffsets();
MPPointF pOut = MPPointF.getInstance1(0, 0);
MPPointF pIcon = MPPointF.getInstance1(0, 0);
double? yOffset = Utils.convertDpToPixel(5);
for (int i = 0; i < _painter!.getData()!.getDataSetCount(); i++) {
IRadarDataSet dataSet =
_painter!.getData()!.getDataSetByIndex(i) as IRadarDataSet;
if (!shouldDrawValues(dataSet)) continue;
// apply the text-styling defined by the DataSet
applyValueTextStyle(dataSet);
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 < dataSet.getEntryCount(); j++) {
RadarEntry entry = dataSet.getEntryForIndex(j)!;
Utils.getPosition(
center,
(entry.y - _painter!.getYChartMin()!) * factor * phaseY,
sliceAngle * j * phaseX + _painter!.getRotationAngle(),
pOut);
if (dataSet.isDrawValuesEnabled()) {
drawValue(
c,
formatter!.getRadarLabel(entry),
pOut.x,
pOut.y - yOffset,
dataSet.getValueTextColor2(j),
dataSet.getValueTextSize(),
dataSet.getValueTypeface());
}
if (entry.mIcon != null && dataSet.isDrawIconsEnabled()) {
Utils.getPosition(center, entry.y * factor * phaseY + iconsOffset.y,
sliceAngle * j * phaseX + _painter!.getRotationAngle(), pIcon);
//noinspection SuspiciousNameCombination
pIcon.y += iconsOffset.x;
CanvasUtils.drawImage(c, Offset(pIcon.x, pIcon.y), entry.mIcon!,
const Size(15, 15), drawPaint!);
}
}
MPPointF.recycleInstance(iconsOffset);
}
MPPointF.recycleInstance(center);
MPPointF.recycleInstance(pOut);
MPPointF.recycleInstance(pIcon);
}