Skip to content

Commit 2171052

Browse files
committed
fix: some radar chart fixes
1 parent eb7a2e1 commit 2171052

File tree

1 file changed

+35
-27
lines changed

1 file changed

+35
-27
lines changed

src/charting/renderer/RadarChartRenderer.ts

+35-27
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,14 @@ export class RadarChartRenderer extends LineRadarRenderer {
8585
const minVal = this.mChart.getYChartMin();
8686
const angle = this.mChart.getRotationAngle();
8787

88-
89-
9088
const entryCount = dataSet.getEntryCount();
9189
if (!this.mLineBuffer || this.mLineBuffer.length < Math.max(entryCount * 2, 2) * 2) {
9290
this.mLineBuffer = Utils.createArrayBuffer(Math.max(entryCount * 2, 2) * 2);
9391
}
9492
const float32arr = this.mLineBuffer;
9593
let index = 0;
9694
for (let j = 0; j < dataSet.getEntryCount(); j++) {
97-
this.mRenderPaint.setColor(dataSet.getColor(j));
95+
this.mRenderPaint.setColor(dataSet.getColor());
9896

9997
const e = dataSet.getEntryForIndex(j);
10098
const yProperty = dataSet.yProperty;
@@ -104,20 +102,22 @@ export class RadarChartRenderer extends LineRadarRenderer {
104102
if (isNaN(pOut.x)) continue;
105103

106104
if (!hasMovedToPoint) {
107-
float32arr[index++] =pOut.x;
105+
float32arr[index++] = pOut.x;
108106
float32arr[index++] = pOut.y;
109107
hasMovedToPoint = true;
110108
}
111109

112-
float32arr[index++] =pOut.x;
110+
float32arr[index++] = pOut.x;
113111
float32arr[index++] = pOut.y;
114112
}
115113

116114
if (dataSet.getEntryCount() > mostEntries) {
117115
// if this is not the largest set, draw a line to the center before closing
118-
float32arr[index++] =center.x;
116+
float32arr[index++] = center.x;
119117
float32arr[index++] = center.y;
120118
}
119+
float32arr[index++] = float32arr[0];
120+
float32arr[index++] = float32arr[1];
121121
const points = Utils.pointsFromBuffer(float32arr);
122122
surface.setLines(points, 0, index);
123123

@@ -223,40 +223,48 @@ export class RadarChartRenderer extends LineRadarRenderer {
223223
const center = this.mChart.getCenterOffsets();
224224

225225
// draw the web lines that come from the center
226-
this.mWebPaint.setStrokeWidth(this.mChart.getWebLineWidth());
227-
this.mWebPaint.setColor(this.mChart.getWebColor());
228-
this.mWebPaint.setAlpha(this.mChart.getWebAlpha());
226+
const lineWidth = this.mChart.getWebLineWidth();
227+
if (lineWidth > 0) {
228+
this.mWebPaint.setStrokeWidth(this.mChart.getWebLineWidth());
229+
this.mWebPaint.setColor(this.mChart.getWebColor());
230+
this.mWebPaint.setAlpha(this.mChart.getWebAlpha());
229231

230-
const xIncrements = 1 + this.mChart.getSkipWebLineCount();
231-
const maxEntryCount = this.mChart.getData().getMaxEntryCountSet().getEntryCount();
232+
const xIncrements = 1 + this.mChart.getSkipWebLineCount();
233+
const maxEntryCount = this.mChart.getData().getMaxEntryCountSet().getEntryCount();
232234

233-
const p: MPPointF = { x: 0, y: 0 };
234-
for (let i = 0; i < maxEntryCount; i += xIncrements) {
235-
Utils.getPosition(center, this.mChart.getYRange() * factor, sliceangle * i + rotationangle, p);
235+
const p: MPPointF = { x: 0, y: 0 };
236+
for (let i = 0; i < maxEntryCount; i += xIncrements) {
237+
Utils.getPosition(center, this.mChart.getYRange() * factor, sliceangle * i + rotationangle, p);
236238

237-
c.drawLine(center.x, center.y, p.x, p.y, this.mWebPaint);
239+
c.drawLine(center.x, center.y, p.x, p.y, this.mWebPaint);
240+
}
238241
}
242+
239243
// MPPointF.recycleInstance(p);
240244

241245
// draw the inner-web
242-
this.mWebPaint.setStrokeWidth(this.mChart.getWebLineWidthInner());
243-
this.mWebPaint.setColor(this.mChart.getWebColorInner());
244-
this.mWebPaint.setAlpha(this.mChart.getWebAlpha());
246+
const innerWidth = this.mChart.getWebLineWidthInner();
247+
if (innerWidth > 0) {
248+
this.mWebPaint.setStrokeWidth(this.mChart.getWebLineWidthInner());
249+
this.mWebPaint.setColor(this.mChart.getWebColorInner());
250+
this.mWebPaint.setAlpha(this.mChart.getWebAlpha());
245251

246-
const labelCount = this.mChart.getYAxis().mEntryCount;
252+
const labelCount = this.mChart.getYAxis().mEntryCount;
247253

248-
const p1out: MPPointF = { x: 0, y: 0 };
249-
const p2out: MPPointF = { x: 0, y: 0 };
250-
for (let j = 0; j < labelCount; j++) {
251-
for (let i = 0; i < this.mChart.getData().getEntryCount(); i++) {
252-
const r = (this.mChart.getYAxis().mEntries[j] - this.mChart.getYChartMin()) * factor;
254+
const p1out: MPPointF = { x: 0, y: 0 };
255+
const p2out: MPPointF = { x: 0, y: 0 };
256+
for (let j = 0; j < labelCount; j++) {
257+
for (let i = 0; i < this.mChart.getData().getEntryCount(); i++) {
258+
const r = (this.mChart.getYAxis().mEntries[j] - this.mChart.getYChartMin()) * factor;
253259

254-
Utils.getPosition(center, r, sliceangle * i + rotationangle, p1out);
255-
Utils.getPosition(center, r, sliceangle * (i + 1) + rotationangle, p2out);
260+
Utils.getPosition(center, r, sliceangle * i + rotationangle, p1out);
261+
Utils.getPosition(center, r, sliceangle * (i + 1) + rotationangle, p2out);
256262

257-
c.drawLine(p1out.x, p1out.y, p2out.x, p2out.y, this.mWebPaint);
263+
c.drawLine(p1out.x, p1out.y, p2out.x, p2out.y, this.mWebPaint);
264+
}
258265
}
259266
}
267+
260268
// MPPointF.recycleInstance(p1out);
261269
// MPPointF.recycleInstance(p2out);
262270
}

0 commit comments

Comments
 (0)