billboard.js 4.0.0-next.3 → 4.0.0
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/billboard.css +1 -1
- package/dist/billboard.js +240 -149
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +20 -20
- package/dist/billboard.pkgd.js +240 -149
- package/dist/billboard.pkgd.min.js +27 -27
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +11 -13
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +3 -3
- package/dist/plugin/billboardjs-plugin-stanford.js +11 -13
- package/dist/plugin/billboardjs-plugin-stanford.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-tableview.js +28 -15
- package/dist/plugin/billboardjs-plugin-tableview.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +11 -13
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +9 -9
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +11 -13
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +3 -3
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +28 -15
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +6 -6
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +2 -2
- package/dist/theme/dark.css +1 -1
- package/dist/theme/dark.min.css +1 -1
- package/dist/theme/datalab.css +1 -1
- package/dist/theme/datalab.min.css +1 -1
- package/dist/theme/graph.css +1 -1
- package/dist/theme/graph.min.css +1 -1
- package/dist/theme/insight.css +1 -1
- package/dist/theme/insight.min.css +1 -1
- package/dist/theme/modern.css +1 -1
- package/dist/theme/modern.min.css +1 -1
- package/dist-esm/Chart/Chart.js +1 -1
- package/dist-esm/Chart/api/axis.js +1 -1
- package/dist-esm/Chart/api/category.js +1 -1
- package/dist-esm/Chart/api/chart.js +1 -1
- package/dist-esm/Chart/api/color.js +1 -1
- package/dist-esm/Chart/api/data.js +1 -1
- package/dist-esm/Chart/api/export.js +1 -1
- package/dist-esm/Chart/api/flow.js +1 -1
- package/dist-esm/Chart/api/focus.js +1 -1
- package/dist-esm/Chart/api/grid.js +1 -1
- package/dist-esm/Chart/api/group.js +1 -1
- package/dist-esm/Chart/api/legend.js +1 -1
- package/dist-esm/Chart/api/load.js +1 -1
- package/dist-esm/Chart/api/regions.js +1 -1
- package/dist-esm/Chart/api/selection.js +1 -1
- package/dist-esm/Chart/api/show.js +1 -1
- package/dist-esm/Chart/api/stubs.js +53 -0
- package/dist-esm/Chart/api/subchart.js +2 -2
- package/dist-esm/Chart/api/tooltip.js +1 -1
- package/dist-esm/Chart/api/x.js +1 -1
- package/dist-esm/Chart/api/zoom.js +2 -2
- package/dist-esm/ChartInternal/Axis/Axis.js +1 -1
- package/dist-esm/ChartInternal/Axis/AxisRenderer.js +149 -96
- package/dist-esm/ChartInternal/Axis/AxisRendererHelper.js +1 -1
- package/dist-esm/ChartInternal/ChartInternal.js +8 -4
- package/dist-esm/ChartInternal/data/convert.helper.js +1 -1
- package/dist-esm/ChartInternal/data/convert.js +1 -1
- package/dist-esm/ChartInternal/data/data.js +1 -1
- package/dist-esm/ChartInternal/data/load.js +1 -1
- package/dist-esm/ChartInternal/interactions/drag.js +1 -1
- package/dist-esm/ChartInternal/interactions/eventrect.js +2 -2
- package/dist-esm/ChartInternal/interactions/flow.js +1 -1
- package/dist-esm/ChartInternal/interactions/interaction.js +1 -1
- package/dist-esm/ChartInternal/interactions/subchart.js +1 -1
- package/dist-esm/ChartInternal/interactions/zoom.js +1 -1
- package/dist-esm/ChartInternal/internals/category.js +1 -1
- package/dist-esm/ChartInternal/internals/class.js +1 -1
- package/dist-esm/ChartInternal/internals/clip.js +1 -1
- package/dist-esm/ChartInternal/internals/color.js +1 -1
- package/dist-esm/ChartInternal/internals/domain.js +1 -1
- package/dist-esm/ChartInternal/internals/format.js +1 -1
- package/dist-esm/ChartInternal/internals/grid.js +1 -1
- package/dist-esm/ChartInternal/internals/legend.js +1 -1
- package/dist-esm/ChartInternal/internals/redraw.js +1 -1
- package/dist-esm/ChartInternal/internals/region.js +1 -1
- package/dist-esm/ChartInternal/internals/scale.js +1 -1
- package/dist-esm/ChartInternal/internals/selection.js +1 -1
- package/dist-esm/ChartInternal/internals/size.axis.js +1 -1
- package/dist-esm/ChartInternal/internals/size.js +1 -1
- package/dist-esm/ChartInternal/internals/style.js +1 -1
- package/dist-esm/ChartInternal/internals/text.arc.js +1 -1
- package/dist-esm/ChartInternal/internals/text.js +1 -1
- package/dist-esm/ChartInternal/internals/text.util.js +1 -1
- package/dist-esm/ChartInternal/internals/title.js +1 -1
- package/dist-esm/ChartInternal/internals/tooltip.js +1 -1
- package/dist-esm/ChartInternal/internals/transform.js +1 -1
- package/dist-esm/ChartInternal/internals/type.js +1 -1
- package/dist-esm/ChartInternal/shape/arc.js +1 -1
- package/dist-esm/ChartInternal/shape/area.js +1 -1
- package/dist-esm/ChartInternal/shape/bar.js +1 -1
- package/dist-esm/ChartInternal/shape/bubble.js +1 -1
- package/dist-esm/ChartInternal/shape/candlestick.js +1 -1
- package/dist-esm/ChartInternal/shape/core/barRadius.js +1 -1
- package/dist-esm/ChartInternal/shape/core/bubble.js +1 -1
- package/dist-esm/ChartInternal/shape/core/candlestick.js +1 -1
- package/dist-esm/ChartInternal/shape/core/dataRegion.js +1 -1
- package/dist-esm/ChartInternal/shape/core/geometry.js +1 -1
- package/dist-esm/ChartInternal/shape/core/path.js +1 -1
- package/dist-esm/ChartInternal/shape/core/point.js +1 -1
- package/dist-esm/ChartInternal/shape/core/treemap.js +1 -1
- package/dist-esm/ChartInternal/shape/funnel.js +1 -1
- package/dist-esm/ChartInternal/shape/gauge.js +1 -1
- package/dist-esm/ChartInternal/shape/line.js +1 -1
- package/dist-esm/ChartInternal/shape/point.js +1 -1
- package/dist-esm/ChartInternal/shape/polar.js +1 -1
- package/dist-esm/ChartInternal/shape/radar.js +1 -1
- package/dist-esm/ChartInternal/shape/shape.js +6 -4
- package/dist-esm/ChartInternal/shape/treemap.js +1 -1
- package/dist-esm/canvas/CanvasAxisRenderer.js +1 -1
- package/dist-esm/canvas/CanvasEngine.js +18 -5
- package/dist-esm/canvas/CanvasPainter.js +1 -1
- package/dist-esm/canvas/CanvasRenderer.js +58 -35
- package/dist-esm/canvas/CanvasTheme.js +1 -1
- package/dist-esm/canvas/HitDetector.js +1 -1
- package/dist-esm/canvas/axisTicks.js +1 -1
- package/dist-esm/canvas/classes.js +1 -1
- package/dist-esm/canvas/color.js +1 -1
- package/dist-esm/canvas/geometry.js +1 -1
- package/dist-esm/canvas/labels.js +1 -1
- package/dist-esm/canvas/pointPattern.js +1 -1
- package/dist-esm/canvas/util.js +1 -1
- package/dist-esm/config/Options/Options.js +1 -1
- package/dist-esm/config/Options/axis/axis.js +1 -1
- package/dist-esm/config/Options/axis/x.js +1 -1
- package/dist-esm/config/Options/axis/y.js +1 -1
- package/dist-esm/config/Options/axis/y2.js +1 -13
- package/dist-esm/config/Options/common/boost.js +1 -1
- package/dist-esm/config/Options/common/color.js +1 -1
- package/dist-esm/config/Options/common/grid.js +1 -1
- package/dist-esm/config/Options/common/legend.js +1 -1
- package/dist-esm/config/Options/common/main.js +1 -1
- package/dist-esm/config/Options/common/point.js +1 -1
- package/dist-esm/config/Options/common/title.js +1 -1
- package/dist-esm/config/Options/common/tooltip.js +1 -1
- package/dist-esm/config/Options/data/axis.js +1 -1
- package/dist-esm/config/Options/data/data.js +1 -1
- package/dist-esm/config/Options/data/selection.js +1 -1
- package/dist-esm/config/Options/interaction/interaction.js +1 -1
- package/dist-esm/config/Options/interaction/subchart.js +1 -1
- package/dist-esm/config/Options/interaction/zoom.js +1 -1
- package/dist-esm/config/Options/shape/arc.js +1 -1
- package/dist-esm/config/Options/shape/area.js +1 -1
- package/dist-esm/config/Options/shape/bar.js +1 -1
- package/dist-esm/config/Options/shape/bubble.js +1 -1
- package/dist-esm/config/Options/shape/candlestick.js +1 -1
- package/dist-esm/config/Options/shape/donut.js +1 -1
- package/dist-esm/config/Options/shape/funnel.js +1 -1
- package/dist-esm/config/Options/shape/gauge.js +1 -1
- package/dist-esm/config/Options/shape/line.js +1 -1
- package/dist-esm/config/Options/shape/pie.js +1 -1
- package/dist-esm/config/Options/shape/polar.js +1 -1
- package/dist-esm/config/Options/shape/radar.js +1 -1
- package/dist-esm/config/Options/shape/scatter.js +1 -1
- package/dist-esm/config/Options/shape/spline.js +1 -1
- package/dist-esm/config/Options/shape/treemap.js +1 -1
- package/dist-esm/config/Store/Element.js +1 -1
- package/dist-esm/config/Store/State.js +1 -1
- package/dist-esm/config/Store/Store.js +1 -1
- package/dist-esm/config/classes.js +1 -1
- package/dist-esm/config/config.js +1 -1
- package/dist-esm/config/const.js +17 -2
- package/dist-esm/config/resolver/axis.core.js +1 -1
- package/dist-esm/config/resolver/axis.js +1 -1
- package/dist-esm/config/resolver/canvas.js +1 -1
- package/dist-esm/config/resolver/canvasShape.js +1 -1
- package/dist-esm/config/resolver/category.js +1 -1
- package/dist-esm/config/resolver/export.js +1 -1
- package/dist-esm/config/resolver/flow.js +1 -1
- package/dist-esm/config/resolver/grid.js +1 -1
- package/dist-esm/config/resolver/interaction/selection.js +1 -1
- package/dist-esm/config/resolver/interaction/subchart.js +1 -1
- package/dist-esm/config/resolver/interaction/zoom.js +1 -1
- package/dist-esm/config/resolver/regions.js +1 -1
- package/dist-esm/config/resolver/shape/arc.helpers.js +1 -1
- package/dist-esm/config/resolver/shape/area.js +1 -1
- package/dist-esm/config/resolver/shape/axis.helpers.js +1 -1
- package/dist-esm/config/resolver/shape/bar.js +1 -1
- package/dist-esm/config/resolver/shape/bubble.js +1 -1
- package/dist-esm/config/resolver/shape/candlestick.js +1 -1
- package/dist-esm/config/resolver/shape/donut.js +1 -1
- package/dist-esm/config/resolver/shape/funnel.js +1 -1
- package/dist-esm/config/resolver/shape/gauge.js +1 -1
- package/dist-esm/config/resolver/shape/line.js +1 -1
- package/dist-esm/config/resolver/shape/pie.js +1 -1
- package/dist-esm/config/resolver/shape/polar.js +1 -1
- package/dist-esm/config/resolver/shape/radar.js +1 -1
- package/dist-esm/config/resolver/shape/scatter.js +1 -1
- package/dist-esm/config/resolver/shape/treemap.js +1 -1
- package/dist-esm/core.js +3 -3
- package/dist-esm/index.canvas.js +2 -1
- package/dist-esm/index.esm.js +2 -1
- package/dist-esm/module/Cache.js +1 -1
- package/dist-esm/module/browser.js +1 -1
- package/dist-esm/module/dsv.js +1 -1
- package/dist-esm/module/error.js +16 -3
- package/dist-esm/module/generator.js +1 -1
- package/dist-esm/module/sanitize.js +14 -18
- package/dist-esm/module/util/brush.js +1 -1
- package/dist-esm/module/util/dom.js +1 -1
- package/dist-esm/module/util/object.js +7 -4
- package/dist-esm/module/util/type-checks.js +1 -1
- package/dist-esm/module/worker.js +32 -22
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +32 -21
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/package.json +37 -11
- package/src/ChartInternal/Axis/AxisRenderer.ts +179 -105
- package/src/ChartInternal/ChartInternal.ts +11 -3
- package/src/ChartInternal/interactions/eventrect.ts +3 -1
- package/src/ChartInternal/shape/shape.ts +5 -3
- package/src/Plugin/tableview/Options.ts +17 -1
- package/src/Plugin/tableview/index.ts +1 -1
- package/src/canvas/CanvasEngine.ts +18 -5
- package/src/canvas/CanvasRenderer.ts +71 -36
- package/src/config/Options/axis/y2.ts +0 -13
- package/src/module/sanitize.ts +13 -20
- package/src/module/util/object.ts +4 -2
- package/src/module/worker.ts +34 -24
- package/types/index.d.ts +0 -3
- package/types/plugin/tableview/options.d.ts +5 -0
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 4.0.0
|
|
8
|
+
* @version 4.0.0
|
|
9
9
|
*/
|
|
10
10
|
import { TYPE_BY_CATEGORY, TYPE } from '../../config/const.js';
|
|
11
11
|
import { isNumber, isArray, isString } from '../../module/util/type-checks.js';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 4.0.0
|
|
8
|
+
* @version 4.0.0
|
|
9
9
|
*/
|
|
10
10
|
import { KEY } from '../../../module/Cache.js';
|
|
11
11
|
import { isObject, isFunction, isNumber } from '../../../module/util/type-checks.js';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 4.0.0
|
|
8
|
+
* @version 4.0.0
|
|
9
9
|
*/
|
|
10
10
|
import { isValue, isUndefined } from '../../../module/util/type-checks.js';
|
|
11
11
|
import { parseDate } from '../../../module/util/object.js';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 4.0.0
|
|
8
|
+
* @version 4.0.0
|
|
9
9
|
*/
|
|
10
10
|
import { hierarchy, treemap, treemapResquarify, treemapSquarify, treemapSliceDice, treemapSlice, treemapDice, treemapBinary } from 'd3-hierarchy';
|
|
11
11
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 4.0.0
|
|
8
|
+
* @version 4.0.0
|
|
9
9
|
*/
|
|
10
10
|
import { select } from 'd3-selection';
|
|
11
11
|
import { $AXIS, $LEVEL, $TEXT, $COMMON, $RADAR, $SHAPE } from '../../config/classes.js';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 4.0.0
|
|
8
|
+
* @version 4.0.0
|
|
9
9
|
*/
|
|
10
10
|
import { select } from 'd3-selection';
|
|
11
11
|
import { curveStepBefore, curveStepAfter, curveStep, curveLinear, curveLinearClosed, curveNatural, curveMonotoneY, curveMonotoneX, curveCatmullRomOpen, curveCatmullRomClosed, curveCatmullRom, curveCardinalOpen, curveCardinalClosed, curveCardinal, curveBundle, curveBasisOpen, curveBasisClosed, curveBasis } from 'd3-shape';
|
|
@@ -389,12 +389,14 @@ var shape = {
|
|
|
389
389
|
getShapeOffsetData(typeFilter) {
|
|
390
390
|
const $$ = this;
|
|
391
391
|
const targets = $$.orderTargets($$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)));
|
|
392
|
-
//
|
|
392
|
+
// Same IDs can receive new values through load()/flow(), so ID-only
|
|
393
|
+
// caching can leave stacked offsets pointing at stale row maps.
|
|
394
|
+
const dataGeneration = $$.state.dataGeneration;
|
|
393
395
|
const targetIds = targets.map(t => t.id).join("_");
|
|
394
396
|
const cacheKey = `${KEY.shapeOffset}_${targetIds}`;
|
|
395
397
|
// Check if result is already cached
|
|
396
398
|
const cachedData = $$.cache.get(cacheKey);
|
|
397
|
-
if (cachedData) {
|
|
399
|
+
if (cachedData?.generation === dataGeneration) {
|
|
398
400
|
return cachedData;
|
|
399
401
|
}
|
|
400
402
|
const isStackNormalized = $$.isStackNormalized();
|
|
@@ -422,7 +424,7 @@ var shape = {
|
|
|
422
424
|
out[id] = index;
|
|
423
425
|
return out;
|
|
424
426
|
}, {});
|
|
425
|
-
const result = { indexMapByTargetId, shapeOffsetTargets };
|
|
427
|
+
const result = { generation: dataGeneration, indexMapByTargetId, shapeOffsetTargets };
|
|
426
428
|
// Cache the result
|
|
427
429
|
$$.cache.add(cacheKey, result);
|
|
428
430
|
return result;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 4.0.0
|
|
8
|
+
* @version 4.0.0
|
|
9
9
|
*/
|
|
10
10
|
import { AXIS_TICK_SIZE, AXIS_TICK_PADDING } from '../config/const.js';
|
|
11
11
|
import { getSubXTickValues, normalizeXValue, getXTickValues, getYGridTickValues, normalizeYValue, getAdditionalAxisScale, getAdditionalAxisTickFormat, getAdditionalAxisTickValues, getXScale, getXTickLineValues, getXTickLinePosition, isSameTickValue, getYTickValues } from './axisTicks.js';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 4.0.0
|
|
8
|
+
* @version 4.0.0
|
|
9
9
|
*/
|
|
10
10
|
import { document as doc, window as win } from '../module/browser.js';
|
|
11
11
|
import { $CANVAS } from './classes.js';
|
|
@@ -24,6 +24,7 @@ class CanvasEngine {
|
|
|
24
24
|
dpr = 1;
|
|
25
25
|
frame = null;
|
|
26
26
|
frameCtx = null;
|
|
27
|
+
frameValid = false;
|
|
27
28
|
/**
|
|
28
29
|
* Create and attach the canvas element.
|
|
29
30
|
* @param {HTMLElement} container Chart container
|
|
@@ -58,13 +59,14 @@ class CanvasEngine {
|
|
|
58
59
|
this.ctx.setTransform(this.dpr, 0, 0, this.dpr, 0, 0);
|
|
59
60
|
this.frame = null;
|
|
60
61
|
this.frameCtx = null;
|
|
62
|
+
this.frameValid = false;
|
|
61
63
|
}
|
|
62
64
|
/**
|
|
63
65
|
* Clear transient overlay drawings by restoring the captured frame.
|
|
64
66
|
* @private
|
|
65
67
|
*/
|
|
66
68
|
clearOverlay() {
|
|
67
|
-
this.restoreFrame();
|
|
69
|
+
this.frameValid && this.restoreFrame();
|
|
68
70
|
}
|
|
69
71
|
/**
|
|
70
72
|
* Draw transient overlay content on the single visible canvas.
|
|
@@ -73,7 +75,15 @@ class CanvasEngine {
|
|
|
73
75
|
*/
|
|
74
76
|
withOverlay(draw) {
|
|
75
77
|
const { ctx } = this;
|
|
76
|
-
this.
|
|
78
|
+
const hasFrame = this.frameValid;
|
|
79
|
+
if (hasFrame) {
|
|
80
|
+
this.clearOverlay();
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// Copy the clean frame only when an overlay is actually requested.
|
|
84
|
+
// Large filled charts make eager full-canvas copies expensive.
|
|
85
|
+
this.captureFrame();
|
|
86
|
+
}
|
|
77
87
|
ctx.save();
|
|
78
88
|
ctx.setTransform(this.dpr, 0, 0, this.dpr, 0, 0);
|
|
79
89
|
try {
|
|
@@ -91,6 +101,7 @@ class CanvasEngine {
|
|
|
91
101
|
*/
|
|
92
102
|
beginFrame(w, h) {
|
|
93
103
|
const { ctx } = this;
|
|
104
|
+
this.frameValid = false;
|
|
94
105
|
ctx.save();
|
|
95
106
|
ctx.setTransform(this.dpr, 0, 0, this.dpr, 0, 0);
|
|
96
107
|
ctx.clearRect(0, 0, w, h);
|
|
@@ -101,7 +112,6 @@ class CanvasEngine {
|
|
|
101
112
|
*/
|
|
102
113
|
endFrame() {
|
|
103
114
|
this.ctx.restore();
|
|
104
|
-
this.captureFrame();
|
|
105
115
|
}
|
|
106
116
|
/**
|
|
107
117
|
* Capture the rendered frame for focus overlay restoration.
|
|
@@ -109,6 +119,7 @@ class CanvasEngine {
|
|
|
109
119
|
*/
|
|
110
120
|
captureFrame() {
|
|
111
121
|
const { canvas } = this;
|
|
122
|
+
this.frameValid = false;
|
|
112
123
|
if (canvas.width && canvas.height) {
|
|
113
124
|
let { frame, frameCtx } = this;
|
|
114
125
|
if (!frame) {
|
|
@@ -132,6 +143,7 @@ class CanvasEngine {
|
|
|
132
143
|
frameCtx.clearRect(0, 0, canvas.width, canvas.height);
|
|
133
144
|
}
|
|
134
145
|
frameCtx.drawImage(canvas, 0, 0);
|
|
146
|
+
this.frameValid = true;
|
|
135
147
|
}
|
|
136
148
|
}
|
|
137
149
|
/**
|
|
@@ -139,7 +151,7 @@ class CanvasEngine {
|
|
|
139
151
|
* @private
|
|
140
152
|
*/
|
|
141
153
|
restoreFrame() {
|
|
142
|
-
if (!this.frame || !this.frameCtx) {
|
|
154
|
+
if (!this.frameValid || !this.frame || !this.frameCtx) {
|
|
143
155
|
return;
|
|
144
156
|
}
|
|
145
157
|
const { canvas, ctx } = this;
|
|
@@ -158,6 +170,7 @@ class CanvasEngine {
|
|
|
158
170
|
this.canvas?.remove();
|
|
159
171
|
this.frame = null;
|
|
160
172
|
this.frameCtx = null;
|
|
173
|
+
this.frameValid = false;
|
|
161
174
|
}
|
|
162
175
|
}
|
|
163
176
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 4.0.0
|
|
8
|
+
* @version 4.0.0
|
|
9
9
|
*/
|
|
10
10
|
import { getStackingBarRadiusSet, getBarRadiusInfo, getBarRadiusResolver } from '../ChartInternal/shape/core/barRadius.js';
|
|
11
11
|
import { getLineRegionSegments } from '../ChartInternal/shape/core/dataRegion.js';
|
|
@@ -126,6 +126,20 @@ function drawCanvasArea($$, target, indices, painter, isSub = false) {
|
|
|
126
126
|
generateDrawAreaPath($$, indices, isSub, ctx)(target);
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Get a target copy clipped to the current visible x range.
|
|
131
|
+
* @param {object} $$ ChartInternal instance
|
|
132
|
+
* @param {object} target Data target
|
|
133
|
+
* @returns {object} Original target or a visible values copy
|
|
134
|
+
* @private
|
|
135
|
+
*/
|
|
136
|
+
function getVisibleCanvasTarget($$, target) {
|
|
137
|
+
const range = getCanvasTargetVisibleRange($$, target);
|
|
138
|
+
return range.start === 0 && range.end === target.values.length ? target : {
|
|
139
|
+
...target,
|
|
140
|
+
values: target.values.slice(range.start, range.end)
|
|
141
|
+
};
|
|
142
|
+
}
|
|
129
143
|
/**
|
|
130
144
|
* Get focused row for a datum or target.
|
|
131
145
|
* @param {Array} focusData Focused data rows
|
|
@@ -1270,8 +1284,7 @@ class CanvasRenderer {
|
|
|
1270
1284
|
hasExpandedShapeFocus($$, selectedData) {
|
|
1271
1285
|
return !!selectedData?.some(d => d &&
|
|
1272
1286
|
(isCanvasBarType($$, d) ||
|
|
1273
|
-
isCanvasCandlestickType($$, d)
|
|
1274
|
-
(isCanvasPointType($$, d) && getPointOpacity($$, d) < 1)));
|
|
1287
|
+
isCanvasCandlestickType($$, d)));
|
|
1275
1288
|
}
|
|
1276
1289
|
/**
|
|
1277
1290
|
* Draw line strokes on canvas.
|
|
@@ -1292,7 +1305,8 @@ class CanvasRenderer {
|
|
|
1292
1305
|
}
|
|
1293
1306
|
painter.withTranslation(margin.left, margin.top, () => {
|
|
1294
1307
|
for (const target of targets) {
|
|
1295
|
-
|
|
1308
|
+
const visibleTarget = getVisibleCanvasTarget($$, target);
|
|
1309
|
+
if (!visibleTarget.values.some(hasCanvasDrawableValue.bind(null, $$))) {
|
|
1296
1310
|
continue;
|
|
1297
1311
|
}
|
|
1298
1312
|
ctx.globalAlpha = getCanvasTargetFocusOpacity($$, target);
|
|
@@ -1300,9 +1314,9 @@ class CanvasRenderer {
|
|
|
1300
1314
|
style.shape.lineFocusedWidth :
|
|
1301
1315
|
style.shape.lineWidth;
|
|
1302
1316
|
ctx.strokeStyle = $$.color(target.id);
|
|
1303
|
-
$$.config.data_regions?.[
|
|
1304
|
-
drawCanvasLineWithDataRegions($$,
|
|
1305
|
-
drawCanvasLine($$,
|
|
1317
|
+
$$.config.data_regions?.[visibleTarget.id] ?
|
|
1318
|
+
drawCanvasLineWithDataRegions($$, visibleTarget, painter) :
|
|
1319
|
+
drawCanvasLine($$, visibleTarget, indices, painter);
|
|
1306
1320
|
}
|
|
1307
1321
|
ctx.globalAlpha = 1;
|
|
1308
1322
|
});
|
|
@@ -1327,15 +1341,17 @@ class CanvasRenderer {
|
|
|
1327
1341
|
}
|
|
1328
1342
|
painter.withTranslation(margin.left, margin.top, () => {
|
|
1329
1343
|
for (const target of targets) {
|
|
1330
|
-
|
|
1344
|
+
const visibleTarget = getVisibleCanvasTarget($$, target);
|
|
1345
|
+
if (!visibleTarget.values.some(hasCanvasDrawableValue.bind(null, $$))) {
|
|
1331
1346
|
continue;
|
|
1332
1347
|
}
|
|
1333
|
-
const color = getCanvasRenderColor($$,
|
|
1348
|
+
const color = getCanvasRenderColor($$, visibleTarget, focusData);
|
|
1334
1349
|
ctx.globalAlpha = style.shape.areaOpacity * getCanvasTargetFocusOpacity($$, target);
|
|
1335
|
-
ctx.fillStyle = getCanvasLinearGradientFill($$, ctx,
|
|
1336
|
-
//
|
|
1350
|
+
ctx.fillStyle = getCanvasLinearGradientFill($$, ctx, visibleTarget, "area",
|
|
1351
|
+
// Bounds computation walks visible rows, so skip it when no gradient is set.
|
|
1352
|
+
// Use the original target so the range cache stays aligned with unsliced values.
|
|
1337
1353
|
$$.config.area_linearGradient ? getCanvasAreaBounds($$, target, indices) : null, color);
|
|
1338
|
-
drawCanvasArea($$,
|
|
1354
|
+
drawCanvasArea($$, visibleTarget, indices, painter);
|
|
1339
1355
|
}
|
|
1340
1356
|
ctx.globalAlpha = 1;
|
|
1341
1357
|
});
|
|
@@ -1594,7 +1610,6 @@ class CanvasRenderer {
|
|
|
1594
1610
|
isCanvasAreaType($$, target) ||
|
|
1595
1611
|
isCanvasCandlestickType($$, target)) &&
|
|
1596
1612
|
isCanvasRenderableTarget($$, target));
|
|
1597
|
-
// single filtering pass: keep target-local index `i`, it drives geometry lookup
|
|
1598
1613
|
const targetRows = [];
|
|
1599
1614
|
let labelCount = 0;
|
|
1600
1615
|
targets.forEach(target => {
|
|
@@ -1608,7 +1623,7 @@ class CanvasRenderer {
|
|
|
1608
1623
|
d.index >= range.start &&
|
|
1609
1624
|
d.index < range.end &&
|
|
1610
1625
|
hasCanvasDrawableValue($$, d)) {
|
|
1611
|
-
rows.push({ d,
|
|
1626
|
+
rows.push({ d, text });
|
|
1612
1627
|
}
|
|
1613
1628
|
}
|
|
1614
1629
|
labelCount += rows.length;
|
|
@@ -1622,11 +1637,11 @@ class CanvasRenderer {
|
|
|
1622
1637
|
ctx.textAlign = "center";
|
|
1623
1638
|
targetRows
|
|
1624
1639
|
.forEach(rows => {
|
|
1625
|
-
for (const { d,
|
|
1640
|
+
for (const { d, text } of rows) {
|
|
1626
1641
|
let x;
|
|
1627
1642
|
let y;
|
|
1628
1643
|
if (isCanvasBarType($$, d) && barPoints) {
|
|
1629
|
-
const geometry = getCanvasBarGeometry($$, barPoints, d,
|
|
1644
|
+
const geometry = getCanvasBarGeometry($$, barPoints, d, d.index);
|
|
1630
1645
|
if (!geometry) {
|
|
1631
1646
|
continue;
|
|
1632
1647
|
}
|
|
@@ -1651,27 +1666,28 @@ class CanvasRenderer {
|
|
|
1651
1666
|
}
|
|
1652
1667
|
else if (isCanvasCandlestickType($$, d) && candlestickPoints) {
|
|
1653
1668
|
const value = $$.getCandlestickData?.(d);
|
|
1654
|
-
const geometry = getCanvasCandlestickGeometry($$, candlestickPoints, d,
|
|
1669
|
+
const geometry = getCanvasCandlestickGeometry($$, candlestickPoints, d, d.index);
|
|
1655
1670
|
const isUp = value?._isUp;
|
|
1656
1671
|
if (!geometry) {
|
|
1657
1672
|
continue;
|
|
1658
1673
|
}
|
|
1659
|
-
const {
|
|
1674
|
+
const { wickEnd, wickStart } = geometry;
|
|
1675
|
+
const isInverted = $$.config[`axis_${$$.axis?.getId(d.id)}_inverted`];
|
|
1660
1676
|
x = $$.config.axis_rotated ?
|
|
1661
|
-
(isUp ?
|
|
1662
|
-
|
|
1677
|
+
(isUp ? wickEnd[0] + 4 : wickStart[0] - 4) :
|
|
1678
|
+
wickStart[0];
|
|
1663
1679
|
y = $$.config.axis_rotated ?
|
|
1664
|
-
|
|
1665
|
-
(isUp ?
|
|
1680
|
+
wickStart[1] + 3 :
|
|
1681
|
+
(isUp ? wickEnd[1] - 3 : wickStart[1] + 12);
|
|
1682
|
+
!$$.config.axis_rotated && isInverted &&
|
|
1683
|
+
(y += 15 * (isUp ? 1 : -1));
|
|
1666
1684
|
ctx.textAlign = $$.config.axis_rotated ?
|
|
1667
1685
|
(isUp ? "left" : "right") :
|
|
1668
1686
|
"center";
|
|
1669
|
-
ctx.textBaseline =
|
|
1670
|
-
"middle" :
|
|
1671
|
-
(isUp ? "bottom" : "top");
|
|
1687
|
+
ctx.textBaseline = "alphabetic";
|
|
1672
1688
|
}
|
|
1673
1689
|
else if (cx && cy) {
|
|
1674
|
-
({ x, y } = getShapePoint(shape.pos, d,
|
|
1690
|
+
({ x, y } = getShapePoint(shape.pos, d, d.index));
|
|
1675
1691
|
({ x, y } = getPointLabelAnchor($$, ctx, d, x, y));
|
|
1676
1692
|
}
|
|
1677
1693
|
x += getLabelPosition($$, d, "x", texts);
|
|
@@ -1889,18 +1905,25 @@ class CanvasRenderer {
|
|
|
1889
1905
|
const r = $$.pointExpandedR?.(d) ?? (baseR * 1.75);
|
|
1890
1906
|
const overColor = getCanvasOverColor($$, d);
|
|
1891
1907
|
const color = overColor || $$.color(d.id);
|
|
1908
|
+
const fill = overColor ||
|
|
1909
|
+
style.focusPoint.fill ||
|
|
1910
|
+
style.shape.pointFillColor ||
|
|
1911
|
+
color;
|
|
1912
|
+
const stroke = overColor || style.focusPoint.stroke || color;
|
|
1913
|
+
const lineWidth = style.focusPoint.lineWidth;
|
|
1914
|
+
const alpha = getPointOpacity($$, d);
|
|
1915
|
+
const hasStroke = !!stroke && (lineWidth ?? 0) > 0;
|
|
1916
|
+
const mergeSameColorStroke = pointType === "circle" &&
|
|
1917
|
+
hasStroke &&
|
|
1918
|
+
isNumber(alpha) &&
|
|
1919
|
+
alpha < 1 &&
|
|
1920
|
+
fill === stroke;
|
|
1892
1921
|
if (!isFiniteCanvasCoordinate(x, y)) {
|
|
1893
1922
|
return;
|
|
1894
1923
|
}
|
|
1895
|
-
drawPointPattern(painter, pointType, x, y, r,
|
|
1896
|
-
fill
|
|
1897
|
-
|
|
1898
|
-
style.shape.pointFillColor ||
|
|
1899
|
-
color,
|
|
1900
|
-
lineWidth: style.focusPoint.lineWidth,
|
|
1901
|
-
stroke: overColor || style.focusPoint.stroke || color,
|
|
1902
|
-
alpha: getPointOpacity($$, d)
|
|
1903
|
-
}, baseR);
|
|
1924
|
+
drawPointPattern(painter, pointType, x, y, mergeSameColorStroke ? r + (lineWidth || 0) / 2 : r, hasStroke && !mergeSameColorStroke ?
|
|
1925
|
+
{ fill, lineWidth, stroke, alpha } :
|
|
1926
|
+
{ fill, alpha }, baseR);
|
|
1904
1927
|
});
|
|
1905
1928
|
}
|
|
1906
1929
|
this.drawFocusLabels($$, selectedData);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 4.0.0
|
|
8
|
+
* @version 4.0.0
|
|
9
9
|
*/
|
|
10
10
|
import { document as doc, window as win } from '../module/browser.js';
|
|
11
11
|
import { mergeObj } from '../module/util/object.js';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 4.0.0
|
|
8
|
+
* @version 4.0.0
|
|
9
9
|
*/
|
|
10
10
|
import { getScale } from '../ChartInternal/internals/scale.js';
|
|
11
11
|
import { AXIS_DEFAULT_TICK_COUNT, AXIS_TICK_LINE_OVERLAP_PADDING } from '../config/const.js';
|
package/dist-esm/canvas/color.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 4.0.0
|
|
8
|
+
* @version 4.0.0
|
|
9
9
|
*/
|
|
10
10
|
import { getRenderRect, getCandlestickGeometry } from '../ChartInternal/shape/core/geometry.js';
|
|
11
11
|
import { isFiniteCanvasCoordinate } from './util.js';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 4.0.0
|
|
8
|
+
* @version 4.0.0
|
|
9
9
|
*/
|
|
10
10
|
import { isCanvasBubbleType, getFontSize, isCanvasCandlestickType, isCanvasLineType, isCanvasScatterType } from './util.js';
|
|
11
11
|
import { isFunction, isNumber, isString, isObject } from '../module/util/type-checks.js';
|