Skip to content

Commit 11025c0

Browse files
committed
feat: don't draw outliers as items
closes #105
1 parent 93e62f1 commit 11025c0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/elements/base.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export class StatsBase<T extends IStatsBaseProps, O extends IStatsBaseOptions> e
232232

233233
protected _drawItems(ctx: CanvasRenderingContext2D) {
234234
const vert = this.isVertical();
235-
const props = this.getProps(['x', 'y', 'items', 'width', 'height']);
235+
const props = this.getProps(['x', 'y', 'items', 'width', 'height', 'outliers']);
236236
const options = this.options;
237237

238238
if (options.itemRadius <= 0 || !props.items || props.items.length <= 0) {
@@ -251,14 +251,19 @@ export class StatsBase<T extends IStatsBaseProps, O extends IStatsBaseOptions> e
251251
radius: options.itemRadius,
252252
borderWidth: options.itemBorderWidth,
253253
};
254+
const outliers = new Set(props.outliers ?? []);
254255

255256
if (vert) {
256257
props.items.forEach((v) => {
257-
drawPoint(ctx, pointOptions, props.x - props.width / 2 + random() * props.width, v);
258+
if (!outliers.has(v)) {
259+
drawPoint(ctx, pointOptions, props.x - props.width / 2 + random() * props.width, v);
260+
}
258261
});
259262
} else {
260263
props.items.forEach((v) => {
261-
drawPoint(ctx, pointOptions, v, props.y - props.height / 2 + random() * props.height);
264+
if (!outliers.has(v)) {
265+
drawPoint(ctx, pointOptions, v, props.y - props.height / 2 + random() * props.height);
266+
}
262267
});
263268
}
264269
ctx.restore();

0 commit comments

Comments
 (0)