@windborne/grapher 1.0.30 → 1.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.cjs +1 -1
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.esm.js +1 -1
- package/dist/bundle.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/renderer/draw_area.js +23 -1
- package/src/renderer/draw_line.js +32 -9
- package/src/renderer/graph_body_renderer.js +3 -28
- package/src/renderer/line_program.js +16 -1
package/package.json
CHANGED
|
@@ -39,6 +39,7 @@ export default function drawArea(
|
|
|
39
39
|
showIndividualPoints,
|
|
40
40
|
negativeColor,
|
|
41
41
|
pointRadius,
|
|
42
|
+
minPointSpacing,
|
|
42
43
|
width,
|
|
43
44
|
highlighted,
|
|
44
45
|
shadowColor = "black",
|
|
@@ -223,7 +224,28 @@ export default function drawArea(
|
|
|
223
224
|
if (showIndividualPoints && !renderCutoffGradient) {
|
|
224
225
|
context.fillStyle = color;
|
|
225
226
|
|
|
226
|
-
|
|
227
|
+
// Apply point spacing for individual point circles only
|
|
228
|
+
function applyPointSpacing(points, minSpacing) {
|
|
229
|
+
if (!minSpacing || points.length <= 1) {
|
|
230
|
+
return points;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const spacedPoints = [];
|
|
234
|
+
let lastX = -Infinity;
|
|
235
|
+
|
|
236
|
+
for (const point of points) {
|
|
237
|
+
const [x] = point;
|
|
238
|
+
if (x - lastX >= minSpacing) {
|
|
239
|
+
spacedPoints.push(point);
|
|
240
|
+
lastX = x;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return spacedPoints;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const pointsToRender = applyPointSpacing(individualPoints, minPointSpacing);
|
|
248
|
+
for (let [x, y] of pointsToRender) {
|
|
227
249
|
if (negativeColor && hasNegatives) {
|
|
228
250
|
if (y === zero && zeroColor) {
|
|
229
251
|
context.fillStyle = zeroColor;
|
|
@@ -2,8 +2,27 @@ import {DPI_INCREASE} from './size_canvas';
|
|
|
2
2
|
import pathsFrom from './paths_from';
|
|
3
3
|
import { applyReducedOpacity } from "../helpers/colors";
|
|
4
4
|
|
|
5
|
+
function applyPointSpacing(points, minSpacing) {
|
|
6
|
+
if (!minSpacing || points.length <= 1) {
|
|
7
|
+
return points;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const spacedPoints = [];
|
|
11
|
+
let lastX = -Infinity;
|
|
12
|
+
|
|
13
|
+
for (const point of points) {
|
|
14
|
+
const [x] = point;
|
|
15
|
+
if (x - lastX >= minSpacing) {
|
|
16
|
+
spacedPoints.push(point);
|
|
17
|
+
lastX = x;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return spacedPoints;
|
|
22
|
+
}
|
|
23
|
+
|
|
5
24
|
export default function drawLine(dataInRenderSpace, {
|
|
6
|
-
color, width=1, context, shadowColor='black', shadowBlur=5, dashed=false, dashPattern=null, highlighted=false, showIndividualPoints=false, pointRadius, getIndividualPoints, getRanges, cutoffIndex, cutoffOpacity, originalData, renderCutoffGradient, currentBounds, selectionBounds, rendering, isPreview
|
|
25
|
+
color, width=1, context, shadowColor='black', shadowBlur=5, dashed=false, dashPattern=null, highlighted=false, showIndividualPoints=false, pointRadius, minPointSpacing, getIndividualPoints, getRanges, cutoffIndex, cutoffOpacity, originalData, renderCutoffGradient, currentBounds, selectionBounds, rendering, isPreview
|
|
7
26
|
}) {
|
|
8
27
|
if (!context) {
|
|
9
28
|
console.error("Canvas context is null in drawLine");
|
|
@@ -343,8 +362,9 @@ export default function drawLine(dataInRenderSpace, {
|
|
|
343
362
|
const visibleMinTime = selectionBounds.minX instanceof Date ? selectionBounds.minX.getTime() : selectionBounds.minX;
|
|
344
363
|
const visibleMaxTime = selectionBounds.maxX instanceof Date ? selectionBounds.maxX.getTime() : selectionBounds.maxX;
|
|
345
364
|
|
|
346
|
-
|
|
347
|
-
|
|
365
|
+
const spacedPoints = applyPointSpacing(individualPoints, minPointSpacing);
|
|
366
|
+
for (let i = 0; i < spacedPoints.length; i++) {
|
|
367
|
+
const [x, y] = spacedPoints[i];
|
|
348
368
|
|
|
349
369
|
let isBeforeCutoff = false;
|
|
350
370
|
if (cutoffTime < visibleMinTime) {
|
|
@@ -369,8 +389,9 @@ export default function drawLine(dataInRenderSpace, {
|
|
|
369
389
|
context.fill();
|
|
370
390
|
}
|
|
371
391
|
} else if (!selectionBounds) {
|
|
372
|
-
|
|
373
|
-
|
|
392
|
+
const spacedPoints = applyPointSpacing(individualPoints, minPointSpacing);
|
|
393
|
+
for (let i = 0; i < spacedPoints.length; i++) {
|
|
394
|
+
const [x, y] = spacedPoints[i];
|
|
374
395
|
context.fillStyle = color;
|
|
375
396
|
context.beginPath();
|
|
376
397
|
context.arc(x, y, pointRadius || 8, 0, 2 * Math.PI, false);
|
|
@@ -380,8 +401,9 @@ export default function drawLine(dataInRenderSpace, {
|
|
|
380
401
|
const visibleMinTime = selectionBounds.minX instanceof Date ? selectionBounds.minX.getTime() : selectionBounds.minX;
|
|
381
402
|
const visibleMaxTime = selectionBounds.maxX instanceof Date ? selectionBounds.maxX.getTime() : selectionBounds.maxX;
|
|
382
403
|
|
|
383
|
-
|
|
384
|
-
|
|
404
|
+
const spacedPoints = applyPointSpacing(individualPoints, minPointSpacing);
|
|
405
|
+
for (let i = 0; i < spacedPoints.length; i++) {
|
|
406
|
+
const [x, y] = spacedPoints[i];
|
|
385
407
|
|
|
386
408
|
let isBeforeCutoff = false;
|
|
387
409
|
if (cutoffTime < visibleMinTime) {
|
|
@@ -407,8 +429,9 @@ export default function drawLine(dataInRenderSpace, {
|
|
|
407
429
|
}
|
|
408
430
|
}
|
|
409
431
|
} else {
|
|
410
|
-
|
|
411
|
-
|
|
432
|
+
const spacedPoints = applyPointSpacing(individualPoints, minPointSpacing);
|
|
433
|
+
for (let i = 0; i < spacedPoints.length; i++) {
|
|
434
|
+
const [x, y] = spacedPoints[i];
|
|
412
435
|
context.fillStyle = color;
|
|
413
436
|
context.beginPath();
|
|
414
437
|
context.arc(x, y, pointRadius || 8, 0, 2 * Math.PI, false);
|
|
@@ -188,21 +188,6 @@ export default class GraphBodyRenderer extends Eventable {
|
|
|
188
188
|
return getIndividualPoints(true, includeBeyondBounds);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
// Apply minPointSpacing if specified
|
|
192
|
-
if (singleSeries.minPointSpacing && individualPoints.length > 1) {
|
|
193
|
-
const spacedPoints = [];
|
|
194
|
-
let lastX = -Infinity;
|
|
195
|
-
|
|
196
|
-
for (const [x, y] of individualPoints) {
|
|
197
|
-
if (x - lastX >= singleSeries.minPointSpacing) {
|
|
198
|
-
spacedPoints.push([x, y]);
|
|
199
|
-
lastX = x;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return spacedPoints;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
191
|
return individualPoints;
|
|
207
192
|
}
|
|
208
193
|
|
|
@@ -270,19 +255,6 @@ export default class GraphBodyRenderer extends Eventable {
|
|
|
270
255
|
individualPoints.unshift([beforeXCoord, beforeYCoord]);
|
|
271
256
|
}
|
|
272
257
|
|
|
273
|
-
if (singleSeries.minPointSpacing && individualPoints.length > 1) {
|
|
274
|
-
const spacedPoints = [];
|
|
275
|
-
let lastX = -Infinity;
|
|
276
|
-
|
|
277
|
-
for (const [x, y] of individualPoints) {
|
|
278
|
-
if (x - lastX >= singleSeries.minPointSpacing) {
|
|
279
|
-
spacedPoints.push([x, y]);
|
|
280
|
-
lastX = x;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
return spacedPoints;
|
|
285
|
-
}
|
|
286
258
|
return individualPoints;
|
|
287
259
|
};
|
|
288
260
|
|
|
@@ -399,6 +371,7 @@ export default class GraphBodyRenderer extends Eventable {
|
|
|
399
371
|
showIndividualPoints: typeof singleSeries.showIndividualPoints === 'boolean' ? singleSeries.showIndividualPoints : showIndividualPoints,
|
|
400
372
|
gradient: singleSeries.gradient,
|
|
401
373
|
pointRadius: singleSeries.pointRadius,
|
|
374
|
+
minPointSpacing: singleSeries.minPointSpacing,
|
|
402
375
|
highlighted,
|
|
403
376
|
width: width || singleSeries.width || defaultLineWidth,
|
|
404
377
|
shadowColor,
|
|
@@ -561,10 +534,12 @@ export default class GraphBodyRenderer extends Eventable {
|
|
|
561
534
|
highlighted,
|
|
562
535
|
showIndividualPoints: shouldShowIndividualPoints,
|
|
563
536
|
pointRadius: singleSeries.pointRadius,
|
|
537
|
+
minPointSpacing: singleSeries.minPointSpacing,
|
|
564
538
|
getIndividualPoints,
|
|
565
539
|
getRanges: singleSeries.rangeKey ? getRanges : null,
|
|
566
540
|
rendering: singleSeries.rendering // Pass rendering type for all charts
|
|
567
541
|
};
|
|
542
|
+
|
|
568
543
|
|
|
569
544
|
if (!inRenderSpace) {
|
|
570
545
|
console.error('inRenderSpace is null for line rendering');
|
|
@@ -125,7 +125,22 @@ export default class LineProgram {
|
|
|
125
125
|
const pointSize = parameters.pointRadius ? parameters.pointRadius * 2 * DPI_INCREASE : 2*(thickness+6);
|
|
126
126
|
gl.uniform1f(gl.getUniformLocation(this._circleProgram, 'pointSize'), pointSize);
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
let individualPoints = parameters.getIndividualPoints();
|
|
129
|
+
|
|
130
|
+
if (parameters.minPointSpacing && individualPoints.length > 1) {
|
|
131
|
+
const spacedPoints = [];
|
|
132
|
+
let lastX = -Infinity;
|
|
133
|
+
|
|
134
|
+
for (const point of individualPoints) {
|
|
135
|
+
const [x] = point;
|
|
136
|
+
if (x - lastX >= parameters.minPointSpacing) {
|
|
137
|
+
spacedPoints.push(point);
|
|
138
|
+
lastX = x;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
individualPoints = spacedPoints;
|
|
143
|
+
}
|
|
129
144
|
|
|
130
145
|
if (parameters.cutoffIndex !== undefined && parameters.cutoffIndex > 0 && parameters.originalData) {
|
|
131
146
|
const { originalData } = parameters;
|