From cdc3a36c9f994830f2df4e5ebb9e8a786a73a01a Mon Sep 17 00:00:00 2001 From: rozetko Date: Tue, 24 May 2022 19:50:29 +0400 Subject: [PATCH] init onMouseMove update --- src/delaunay.ts | 4 +-- src/index.ts | 70 +++++++++++++++++++++++++++++-------------------- src/types.ts | 2 +- 3 files changed, 44 insertions(+), 32 deletions(-) diff --git a/src/delaunay.ts b/src/delaunay.ts index dc8cc3d..8a2d873 100644 --- a/src/delaunay.ts +++ b/src/delaunay.ts @@ -70,13 +70,13 @@ export class DelaunayDiagram { } private concatSeriesDatapoints(series: ScatterData[]): number[][] { - // return type row: [ 0:x, 1:y, 2?:custom value, last:serieIdx ] + // return type row: [ 0:x, 1:y, 2?:custom value, last-1:serieIdx, last:pointIdx ] const datapointsList = _.map(series, serie => { const serieIdx = this.getSerieIdxByTarget(serie.target); const datapointsWithOptions = _.map(serie.datapoints, row => _.concat(row, serieIdx)); return datapointsWithOptions; }); - return _.union(...datapointsList); + return _.concat(...datapointsList); } private getSerieIdxByTarget(target: string): number { diff --git a/src/index.ts b/src/index.ts index 8fde794..4db8d16 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ import { ChartwerkPod, VueChartwerkPodMixin, TickOrientation, TimeFormat, yAxisOrientation, CrosshairOrientation } from '@chartwerk/core'; -import { ScatterData, ScatterOptions, PointType, LineType } from './types'; +import { ScatterData, ScatterOptions, PointType, LineType, Datapoint } from './types'; import { DelaunayDiagram } from './delaunay'; @@ -150,12 +150,12 @@ export class ChartwerkScatterPod extends ChartwerkPod this.series[_.last(d)].pointSize || DEFAULT_POINT_SIZE); } - getSeriesColorFromDataRow(values: number[], rowIdx: number): string { - const seriesIdx = _.last(values); - if(this.series[seriesIdx].colorFormatter) { - return this.series[seriesIdx].colorFormatter(values, rowIdx); + getSeriesColorFromDataRow(datapoint: Datapoint): string { + const serieIdx = datapoint.serieIdx; + if(this.series[serieIdx].colorFormatter) { + return this.series[serieIdx].colorFormatter(datapoint); } - return this.getSerieColor(seriesIdx); + return this.getSerieColor(serieIdx); } onPanningEnd(): void { @@ -173,23 +173,18 @@ export class ChartwerkScatterPod extends ChartwerkPod string; +export type ColorFormatter = (datapoint: Datapoint) => string;