billboard.js 4.0.2 → 4.1.0-next.1
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/README.md +82 -7
- package/dist/billboard.css +1 -1
- package/dist/billboard.js +1938 -557
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +19 -25
- package/dist/billboard.pkgd.js +1934 -742
- package/dist/billboard.pkgd.min.js +24 -30
- package/dist/billboard.react.js +205 -0
- package/dist/billboard.react.min.js +9 -0
- package/dist/billboard.worker.js +10 -0
- 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 +3 -2
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +3 -3
- package/dist/plugin/billboardjs-plugin-stanford.js +3 -2
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +57 -27
- package/dist/plugin/billboardjs-plugin-tableview.min.js +5 -5
- package/dist/plugin/billboardjs-plugin-textoverlap.js +72 -54
- 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 +3 -2
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +3 -3
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +3 -2
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +57 -27
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +11 -11
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +65 -3556
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +8 -8
- 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 +134 -152
- package/dist-esm/Chart/api/axis.js +217 -237
- package/dist-esm/Chart/api/category.js +54 -54
- package/dist-esm/Chart/api/chart.js +172 -215
- package/dist-esm/Chart/api/color.js +21 -21
- package/dist-esm/Chart/api/data.js +172 -173
- package/dist-esm/Chart/api/export.js +242 -262
- package/dist-esm/Chart/api/flow.js +198 -254
- package/dist-esm/Chart/api/focus.js +136 -147
- package/dist-esm/Chart/api/grid.js +191 -190
- package/dist-esm/Chart/api/group.js +31 -34
- package/dist-esm/Chart/api/legend.js +54 -63
- package/dist-esm/Chart/api/load.js +237 -257
- package/dist-esm/Chart/api/regions.js +148 -168
- package/dist-esm/Chart/api/selection.js +181 -139
- package/dist-esm/Chart/api/show.js +133 -147
- package/dist-esm/Chart/api/stubs.js +43 -42
- package/dist-esm/Chart/api/subchart.js +155 -172
- package/dist-esm/Chart/api/tooltip.js +132 -177
- package/dist-esm/Chart/api/x.js +67 -71
- package/dist-esm/Chart/api/zoom.js +183 -220
- package/dist-esm/ChartInternal/Axis/Axis.js +1059 -1266
- package/dist-esm/ChartInternal/Axis/AxisRenderer.js +408 -540
- package/dist-esm/ChartInternal/Axis/AxisRendererHelper.js +113 -149
- package/dist-esm/ChartInternal/ChartInternal.js +573 -749
- package/dist-esm/ChartInternal/data/convert.helper.js +133 -159
- package/dist-esm/ChartInternal/data/convert.js +200 -229
- package/dist-esm/ChartInternal/data/data.js +970 -1147
- package/dist-esm/ChartInternal/data/load.js +145 -197
- package/dist-esm/ChartInternal/interactions/drag.js +86 -122
- package/dist-esm/ChartInternal/interactions/eventrect.js +455 -621
- package/dist-esm/ChartInternal/interactions/flow.js +151 -215
- package/dist-esm/ChartInternal/interactions/interaction.js +214 -252
- package/dist-esm/ChartInternal/interactions/subchart.js +425 -300
- package/dist-esm/ChartInternal/interactions/zoom.js +321 -440
- package/dist-esm/ChartInternal/internals/category.js +18 -18
- package/dist-esm/ChartInternal/internals/class.js +89 -99
- package/dist-esm/ChartInternal/internals/clip.js +88 -119
- package/dist-esm/ChartInternal/internals/color.js +233 -288
- package/dist-esm/ChartInternal/internals/domain.js +452 -588
- package/dist-esm/ChartInternal/internals/format.js +64 -77
- package/dist-esm/ChartInternal/internals/grid.js +333 -457
- package/dist-esm/ChartInternal/internals/legend.js +675 -927
- package/dist-esm/ChartInternal/internals/redraw.js +200 -289
- package/dist-esm/ChartInternal/internals/region.js +106 -159
- package/dist-esm/ChartInternal/internals/scale.js +186 -215
- package/dist-esm/ChartInternal/internals/selection.js +132 -159
- package/dist-esm/ChartInternal/internals/size.axis.js +92 -139
- package/dist-esm/ChartInternal/internals/size.js +286 -394
- package/dist-esm/ChartInternal/internals/style.js +39 -41
- package/dist-esm/ChartInternal/internals/subchart.util.js +49 -0
- package/dist-esm/ChartInternal/internals/text.arc.js +155 -219
- package/dist-esm/ChartInternal/internals/text.js +368 -528
- package/dist-esm/ChartInternal/internals/text.util.js +179 -239
- package/dist-esm/ChartInternal/internals/title.js +96 -121
- package/dist-esm/ChartInternal/internals/tooltip.js +450 -586
- package/dist-esm/ChartInternal/internals/transform.js +79 -97
- package/dist-esm/ChartInternal/internals/type.js +286 -245
- package/dist-esm/ChartInternal/shape/arc.js +825 -1112
- package/dist-esm/ChartInternal/shape/area.js +73 -94
- package/dist-esm/ChartInternal/shape/bar.js +227 -272
- package/dist-esm/ChartInternal/shape/bubble.js +9 -8
- package/dist-esm/ChartInternal/shape/candlestick.js +110 -138
- package/dist-esm/ChartInternal/shape/core/barRadius.js +197 -133
- package/dist-esm/ChartInternal/shape/core/bubble.js +64 -73
- package/dist-esm/ChartInternal/shape/core/candlestick.js +93 -86
- package/dist-esm/ChartInternal/shape/core/dataRegion.js +68 -75
- package/dist-esm/ChartInternal/shape/core/geometry.js +112 -112
- package/dist-esm/ChartInternal/shape/core/path.js +142 -115
- package/dist-esm/ChartInternal/shape/core/point.js +105 -125
- package/dist-esm/ChartInternal/shape/core/treemap.js +83 -88
- package/dist-esm/ChartInternal/shape/funnel.js +310 -338
- package/dist-esm/ChartInternal/shape/gauge.js +71 -103
- package/dist-esm/ChartInternal/shape/line.js +208 -278
- package/dist-esm/ChartInternal/shape/point.js +310 -413
- package/dist-esm/ChartInternal/shape/polar.js +84 -109
- package/dist-esm/ChartInternal/shape/radar.js +228 -318
- package/dist-esm/ChartInternal/shape/shape.js +782 -828
- package/dist-esm/ChartInternal/shape/treemap.js +152 -190
- package/dist-esm/canvas/CanvasAxisRenderer.js +1180 -1328
- package/dist-esm/canvas/CanvasEngine.js +148 -166
- package/dist-esm/canvas/CanvasPainter.js +395 -411
- package/dist-esm/canvas/CanvasRenderer.js +1584 -1834
- package/dist-esm/canvas/CanvasTheme.js +899 -802
- package/dist-esm/canvas/HitDetector.js +394 -463
- package/dist-esm/canvas/axisTicks.js +672 -786
- package/dist-esm/canvas/classes.js +19 -17
- package/dist-esm/canvas/color.js +40 -59
- package/dist-esm/canvas/geometry.js +38 -38
- package/dist-esm/canvas/labels.js +318 -371
- package/dist-esm/canvas/pointPattern.js +578 -580
- package/dist-esm/canvas/util.js +242 -262
- package/dist-esm/config/Options/Options.js +29 -32
- package/dist-esm/config/Options/axis/axis.js +101 -101
- package/dist-esm/config/Options/axis/x.js +759 -755
- package/dist-esm/config/Options/axis/y.js +525 -522
- package/dist-esm/config/Options/axis/y2.js +501 -485
- package/dist-esm/config/Options/common/boost.js +93 -32
- package/dist-esm/config/Options/common/color.js +88 -87
- package/dist-esm/config/Options/common/grid.js +74 -73
- package/dist-esm/config/Options/common/legend.js +180 -179
- package/dist-esm/config/Options/common/main.js +474 -473
- package/dist-esm/config/Options/common/point.js +160 -159
- package/dist-esm/config/Options/common/title.js +47 -46
- package/dist-esm/config/Options/common/tooltip.js +253 -252
- package/dist-esm/config/Options/data/axis.js +173 -172
- package/dist-esm/config/Options/data/data.js +958 -957
- package/dist-esm/config/Options/data/selection.js +131 -130
- package/dist-esm/config/Options/interaction/interaction.js +53 -52
- package/dist-esm/config/Options/interaction/subchart.js +164 -73
- package/dist-esm/config/Options/interaction/zoom.js +86 -85
- package/dist-esm/config/Options/shape/arc.js +150 -149
- package/dist-esm/config/Options/shape/area.js +69 -68
- package/dist-esm/config/Options/shape/bar.js +147 -146
- package/dist-esm/config/Options/shape/bubble.js +35 -34
- package/dist-esm/config/Options/shape/candlestick.js +61 -60
- package/dist-esm/config/Options/shape/donut.js +181 -180
- package/dist-esm/config/Options/shape/funnel.js +49 -48
- package/dist-esm/config/Options/shape/gauge.js +237 -236
- package/dist-esm/config/Options/shape/line.js +58 -57
- package/dist-esm/config/Options/shape/pie.js +185 -184
- package/dist-esm/config/Options/shape/polar.js +167 -166
- package/dist-esm/config/Options/shape/radar.js +76 -75
- package/dist-esm/config/Options/shape/scatter.js +36 -36
- package/dist-esm/config/Options/shape/spline.js +46 -46
- package/dist-esm/config/Options/shape/treemap.js +80 -79
- package/dist-esm/config/Store/Element.js +64 -62
- package/dist-esm/config/Store/State.js +189 -200
- package/dist-esm/config/Store/Store.js +25 -26
- package/dist-esm/config/classes.js +157 -155
- package/dist-esm/config/config.js +26 -35
- package/dist-esm/config/const.js +120 -128
- package/dist-esm/config/resolver/axis.core.js +25 -25
- package/dist-esm/config/resolver/axis.js +26 -27
- package/dist-esm/config/resolver/canvas.js +2071 -2472
- package/dist-esm/config/resolver/canvasShape.js +201 -177
- package/dist-esm/config/resolver/category.js +26 -27
- package/dist-esm/config/resolver/export.js +24 -26
- package/dist-esm/config/resolver/flow.js +29 -31
- package/dist-esm/config/resolver/grid.js +34 -35
- package/dist-esm/config/resolver/interaction/selection.js +17 -17
- package/dist-esm/config/resolver/interaction/subchart.js +17 -17
- package/dist-esm/config/resolver/interaction/zoom.js +17 -17
- package/dist-esm/config/resolver/regions.js +30 -31
- package/dist-esm/config/resolver/shape/arc.helpers.js +19 -19
- package/dist-esm/config/resolver/shape/area.js +17 -17
- package/dist-esm/config/resolver/shape/axis.helpers.js +28 -25
- package/dist-esm/config/resolver/shape/bar.js +13 -13
- package/dist-esm/config/resolver/shape/bubble.js +18 -14
- package/dist-esm/config/resolver/shape/candlestick.js +13 -13
- package/dist-esm/config/resolver/shape/donut.js +11 -11
- package/dist-esm/config/resolver/shape/funnel.js +11 -11
- package/dist-esm/config/resolver/shape/gauge.js +12 -12
- package/dist-esm/config/resolver/shape/line.js +10 -10
- package/dist-esm/config/resolver/shape/pie.js +11 -11
- package/dist-esm/config/resolver/shape/polar.js +12 -12
- package/dist-esm/config/resolver/shape/radar.js +22 -14
- package/dist-esm/config/resolver/shape/scatter.js +13 -13
- package/dist-esm/config/resolver/shape/treemap.js +11 -11
- package/dist-esm/core.js +208 -211
- package/dist-esm/index.canvas.js +14 -13
- package/dist-esm/index.esm.js +25 -24
- package/dist-esm/module/Cache.js +117 -129
- package/dist-esm/module/browser.js +30 -35
- package/dist-esm/module/dsv.js +107 -127
- package/dist-esm/module/error.js +45 -52
- package/dist-esm/module/generator.js +75 -83
- package/dist-esm/module/sanitize.js +302 -399
- package/dist-esm/module/util/brush.js +27 -38
- package/dist-esm/module/util/dom.js +288 -348
- package/dist-esm/module/util/object.js +277 -341
- package/dist-esm/module/util/type-checks.js +21 -25
- package/dist-esm/module/worker.js +312 -130
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +185 -198
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +442 -450
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +813 -950
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +708 -788
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +344 -301
- package/dist-esm/react/index.js +157 -0
- package/package.json +28 -8
- package/src/Chart/api/focus.ts +8 -12
- package/src/Chart/api/selection.ts +130 -5
- package/src/ChartInternal/Axis/Axis.ts +164 -65
- package/src/ChartInternal/Axis/AxisRenderer.ts +41 -8
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +1 -1
- package/src/ChartInternal/ChartInternal.ts +1 -1
- package/src/ChartInternal/data/convert.ts +54 -4
- package/src/ChartInternal/data/data.ts +19 -6
- package/src/ChartInternal/interactions/eventrect.ts +6 -0
- package/src/ChartInternal/interactions/subchart.ts +437 -66
- package/src/ChartInternal/internals/color.ts +7 -6
- package/src/ChartInternal/internals/domain.ts +15 -3
- package/src/ChartInternal/internals/grid.ts +21 -1
- package/src/ChartInternal/internals/scale.ts +9 -2
- package/src/ChartInternal/internals/selection.ts +1 -1
- package/src/ChartInternal/internals/subchart.util.ts +55 -0
- package/src/ChartInternal/internals/text.arc.ts +3 -1
- package/src/ChartInternal/internals/text.ts +19 -6
- package/src/ChartInternal/internals/transform.ts +8 -2
- package/src/ChartInternal/internals/type.ts +131 -33
- package/src/ChartInternal/shape/IShape.ts +6 -3
- package/src/ChartInternal/shape/bar.ts +87 -37
- package/src/ChartInternal/shape/core/barRadius.ts +129 -0
- package/src/ChartInternal/shape/core/candlestick.ts +1 -1
- package/src/ChartInternal/shape/core/path.ts +76 -9
- package/src/ChartInternal/shape/funnel.ts +2 -3
- package/src/ChartInternal/shape/line.ts +1 -1
- package/src/ChartInternal/shape/point.ts +27 -13
- package/src/ChartInternal/shape/shape.ts +172 -18
- package/src/Plugin/stanford/index.ts +0 -4
- package/src/Plugin/tableview/index.ts +85 -3
- package/src/Plugin/textoverlap/index.ts +9 -15
- package/src/canvas/CanvasAxisRenderer.ts +184 -36
- package/src/canvas/CanvasRenderer.ts +247 -160
- package/src/canvas/CanvasTheme.ts +212 -0
- package/src/canvas/axisTicks.ts +122 -40
- package/src/config/Options/axis/y2.ts +13 -0
- package/src/config/Options/common/boost.ts +64 -4
- package/src/config/Options/common/color.ts +2 -2
- package/src/config/Options/interaction/subchart.ts +98 -1
- package/src/config/Options/shape/gauge.ts +1 -1
- package/src/config/Options/shape/treemap.ts +2 -2
- package/src/config/Store/Element.ts +3 -1
- package/src/config/Store/State.ts +1 -0
- package/src/config/classes.ts +1 -0
- package/src/config/resolver/canvas.ts +92 -10
- package/src/module/voronoi.ts +119 -0
- package/src/module/worker.entry.ts +61 -0
- package/src/module/worker.ts +346 -63
- package/src/react/index.ts +193 -0
- package/types/options.d.ts +206 -3
- package/types/react/index.d.ts +27 -0
package/dist-esm/canvas/util.js
CHANGED
|
@@ -5,334 +5,314 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 4.0.
|
|
8
|
+
* @version 4.1.0-next.1
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
11
|
-
|
|
10
|
+
import { TYPE, TYPE_BY_CATEGORY } from "../config/const.js";
|
|
11
|
+
//#region src/canvas/util.ts
|
|
12
12
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const DENSE_SCATTER_POINT_CULL_THRESHOLD =
|
|
13
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
14
|
+
* billboard.js project is licensed under the MIT license
|
|
15
|
+
*/
|
|
16
|
+
const DENSE_SCATTER_POINT_CULL_THRESHOLD = 1e5;
|
|
17
17
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
* Get font size from canvas font shorthand.
|
|
19
|
+
* `parseFloat()` alone fails for style/weight-prefixed shorthands like "bold 20px sans-serif".
|
|
20
|
+
* @param {string} font Canvas font shorthand
|
|
21
|
+
* @returns {number} Font size
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
24
|
function getFontSize(font) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const match = /(\d+(?:\.\d+)?)px/.exec(font);
|
|
26
|
+
const size = match ? parseFloat(match[1]) : parseFloat(font);
|
|
27
|
+
return Number.isFinite(size) ? size : 12;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
* Get cached or generated shape indices for a canvas target type.
|
|
31
|
+
* @param {object} $$ ChartInternal instance
|
|
32
|
+
* @param {object} shape Cached draw shape object
|
|
33
|
+
* @param {string} type Shape type key
|
|
34
|
+
* @param {function} typeFilter Target type filter
|
|
35
|
+
* @returns {object} Shape indices
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
38
|
function getCanvasShapeIndices($$, shape, type, typeFilter) {
|
|
39
|
-
|
|
39
|
+
return shape.indices[type] || $$.getShapeIndices(typeFilter);
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
* Check if grouped data can be handled for a canvas target.
|
|
43
|
+
* @param {object} $$ ChartInternal instance
|
|
44
|
+
* @param {object|string} target Data target, data row or id
|
|
45
|
+
* @param {Array} groupedTypeFilters Supported grouped target filters
|
|
46
|
+
* @returns {boolean} Whether target is supported
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
49
|
function isCanvasTargetSupported($$, target, groupedTypeFilters = []) {
|
|
50
|
-
|
|
51
|
-
return !$$.isGrouped?.(id) || groupedTypeFilters.some(filter => filter($$, target));
|
|
50
|
+
return !$$.isGrouped?.(typeof target === "string" ? target : target?.id) || groupedTypeFilters.some((filter) => filter($$, target));
|
|
52
51
|
}
|
|
53
52
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
* Get the effective chart type for a canvas target.
|
|
54
|
+
* @param {object} config Config object
|
|
55
|
+
* @param {object|string} target Data target, data row or id
|
|
56
|
+
* @returns {string} Chart type
|
|
57
|
+
* @private
|
|
58
|
+
*/
|
|
60
59
|
function getCanvasTargetType(config, target) {
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
const id = typeof target === "string" ? target : target?.id;
|
|
61
|
+
return id && config.data_types?.[id] || config.data_type || TYPE.LINE;
|
|
63
62
|
}
|
|
64
63
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
* Convert a scale-domain value into a number usable for binary searches.
|
|
65
|
+
* @param {number|Date|string} value Scale-domain value
|
|
66
|
+
* @returns {number|null} Comparable number
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
70
69
|
function getCanvasComparableValue(value) {
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
const comparable = +value;
|
|
71
|
+
return Number.isFinite(comparable) ? comparable : null;
|
|
73
72
|
}
|
|
74
73
|
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
* Get the current comparable x domain.
|
|
75
|
+
* @param {object} $$ ChartInternal instance
|
|
76
|
+
* @returns {Array|null} Comparable domain
|
|
77
|
+
* @private
|
|
78
|
+
*/
|
|
80
79
|
function getCanvasComparableXDomain($$) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
const domain = ($$.scale.zoom || $$.scale.x)?.domain?.();
|
|
81
|
+
const start = getCanvasComparableValue(domain?.[0]);
|
|
82
|
+
const end = getCanvasComparableValue(domain?.[1]);
|
|
83
|
+
return start === null || end === null ? null : [Math.min(start, end), Math.max(start, end)];
|
|
85
84
|
}
|
|
86
85
|
/**
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
* Get the row x value as a comparable number.
|
|
87
|
+
* @param {object} row Data row
|
|
88
|
+
* @returns {number|null} Comparable x value
|
|
89
|
+
* @private
|
|
90
|
+
*/
|
|
92
91
|
function getComparableRowX(row) {
|
|
93
|
-
|
|
92
|
+
return getCanvasComparableValue(row?.x);
|
|
94
93
|
}
|
|
95
94
|
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
* Find the first sorted row whose x value is not before the target.
|
|
96
|
+
* @param {Array} values Data rows sorted by x
|
|
97
|
+
* @param {number} target Target x value
|
|
98
|
+
* @param {boolean} ascending Whether rows are ascending by x
|
|
99
|
+
* @returns {number} Row index
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
103
102
|
function lowerBoundCanvasRows(values, target, ascending) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
high = mid;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return low;
|
|
103
|
+
let low = 0;
|
|
104
|
+
let high = values.length;
|
|
105
|
+
while (low < high) {
|
|
106
|
+
const mid = low + high >> 1;
|
|
107
|
+
const value = getComparableRowX(values[mid]);
|
|
108
|
+
if (value === null) return 0;
|
|
109
|
+
if (ascending ? value < target : value > target) low = mid + 1;
|
|
110
|
+
else high = mid;
|
|
111
|
+
}
|
|
112
|
+
return low;
|
|
120
113
|
}
|
|
121
114
|
/**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
115
|
+
* Find the first sorted row whose x value is after the target.
|
|
116
|
+
* @param {Array} values Data rows sorted by x
|
|
117
|
+
* @param {number} target Target x value
|
|
118
|
+
* @param {boolean} ascending Whether rows are ascending by x
|
|
119
|
+
* @returns {number} Row index
|
|
120
|
+
* @private
|
|
121
|
+
*/
|
|
129
122
|
function upperBoundCanvasRows(values, target, ascending) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
high = mid;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return low;
|
|
123
|
+
let low = 0;
|
|
124
|
+
let high = values.length;
|
|
125
|
+
while (low < high) {
|
|
126
|
+
const mid = low + high >> 1;
|
|
127
|
+
const value = getComparableRowX(values[mid]);
|
|
128
|
+
if (value === null) return values.length;
|
|
129
|
+
if (ascending ? value <= target : value >= target) low = mid + 1;
|
|
130
|
+
else high = mid;
|
|
131
|
+
}
|
|
132
|
+
return low;
|
|
146
133
|
}
|
|
147
134
|
/**
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
135
|
+
* Get the visible row range for the current x domain.
|
|
136
|
+
* @param {object} $$ ChartInternal instance
|
|
137
|
+
* @param {object} target Data target
|
|
138
|
+
* @param {number} padding Extra rows to include around the domain edge
|
|
139
|
+
* @returns {object} Half-open row range
|
|
140
|
+
* @private
|
|
141
|
+
*/
|
|
155
142
|
function getCanvasTargetVisibleRange($$, target, padding = 1) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
return range;
|
|
143
|
+
const values = target?.values || [];
|
|
144
|
+
const fullRange = {
|
|
145
|
+
start: 0,
|
|
146
|
+
end: values.length
|
|
147
|
+
};
|
|
148
|
+
const domain = getCanvasComparableXDomain($$);
|
|
149
|
+
if (!values.length || !domain) return fullRange;
|
|
150
|
+
const state = $$.state;
|
|
151
|
+
const cache = state._canvasVisibleRangeCache || (state._canvasVisibleRangeCache = /* @__PURE__ */ new Map());
|
|
152
|
+
const key = [
|
|
153
|
+
target.id,
|
|
154
|
+
values.length,
|
|
155
|
+
state.dataGeneration,
|
|
156
|
+
domain[0],
|
|
157
|
+
domain[1],
|
|
158
|
+
padding
|
|
159
|
+
].join(":");
|
|
160
|
+
const cached = cache.get(target.id);
|
|
161
|
+
if (cached?.key === key) return cached.range;
|
|
162
|
+
const first = getComparableRowX(values[0]);
|
|
163
|
+
const last = getComparableRowX(values[values.length - 1]);
|
|
164
|
+
if (first === null || last === null) return fullRange;
|
|
165
|
+
const ascending = first <= last;
|
|
166
|
+
const start = lowerBoundCanvasRows(values, domain[0], ascending);
|
|
167
|
+
const end = upperBoundCanvasRows(values, domain[1], ascending);
|
|
168
|
+
const range = {
|
|
169
|
+
start: Math.max(0, Math.min(start, end) - padding),
|
|
170
|
+
end: Math.min(values.length, Math.max(start, end) + padding)
|
|
171
|
+
};
|
|
172
|
+
cache.set(target.id, {
|
|
173
|
+
key,
|
|
174
|
+
range
|
|
175
|
+
});
|
|
176
|
+
return range;
|
|
191
177
|
}
|
|
192
178
|
/**
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
179
|
+
* Check if a target should be handled as a canvas bar.
|
|
180
|
+
* @param {object} $$ ChartInternal instance
|
|
181
|
+
* @param {object|string} target Data target, data row or id
|
|
182
|
+
* @returns {boolean} Whether target is a bar
|
|
183
|
+
* @private
|
|
184
|
+
*/
|
|
199
185
|
function isCanvasBarType($$, target) {
|
|
200
|
-
|
|
186
|
+
return getCanvasTargetType($$.config, target) === TYPE.BAR;
|
|
201
187
|
}
|
|
202
188
|
/**
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
189
|
+
* Check if a target should be handled as a canvas area.
|
|
190
|
+
* @param {object} $$ ChartInternal instance
|
|
191
|
+
* @param {object|string} target Data target, data row or id
|
|
192
|
+
* @returns {boolean} Whether target is an area
|
|
193
|
+
* @private
|
|
194
|
+
*/
|
|
209
195
|
function isCanvasAreaType($$, target) {
|
|
210
|
-
|
|
196
|
+
return TYPE_BY_CATEGORY.Area.indexOf(getCanvasTargetType($$.config, target)) > -1;
|
|
211
197
|
}
|
|
212
198
|
/**
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
199
|
+
* Check if a target should be handled as a canvas line.
|
|
200
|
+
* Area charts are line-like because they also draw a stroke and points.
|
|
201
|
+
* @param {object} $$ ChartInternal instance
|
|
202
|
+
* @param {object|string} target Data target, data row or id
|
|
203
|
+
* @returns {boolean} Whether target is line-like
|
|
204
|
+
* @private
|
|
205
|
+
*/
|
|
220
206
|
function isCanvasLineType($$, target) {
|
|
221
|
-
|
|
222
|
-
|
|
207
|
+
const type = getCanvasTargetType($$.config, target);
|
|
208
|
+
return TYPE_BY_CATEGORY.Line.indexOf(type) > -1;
|
|
223
209
|
}
|
|
224
210
|
/**
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
211
|
+
* Check if a target should be handled as a canvas scatter point.
|
|
212
|
+
* @param {object} $$ ChartInternal instance
|
|
213
|
+
* @param {object|string} target Data target, data row or id
|
|
214
|
+
* @returns {boolean} Whether target is scatter
|
|
215
|
+
* @private
|
|
216
|
+
*/
|
|
231
217
|
function isCanvasScatterType($$, target) {
|
|
232
|
-
|
|
218
|
+
return getCanvasTargetType($$.config, target) === TYPE.SCATTER;
|
|
233
219
|
}
|
|
234
220
|
/**
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
221
|
+
* Check if a target should be handled as a canvas bubble point.
|
|
222
|
+
* @param {object} $$ ChartInternal instance
|
|
223
|
+
* @param {object|string} target Data target, data row or id
|
|
224
|
+
* @returns {boolean} Whether target is bubble
|
|
225
|
+
* @private
|
|
226
|
+
*/
|
|
241
227
|
function isCanvasBubbleType($$, target) {
|
|
242
|
-
|
|
228
|
+
return getCanvasTargetType($$.config, target) === TYPE.BUBBLE;
|
|
243
229
|
}
|
|
244
230
|
/**
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
231
|
+
* Check if a target should be handled as a canvas point.
|
|
232
|
+
* @param {object} $$ ChartInternal instance
|
|
233
|
+
* @param {object|string} target Data target, data row or id
|
|
234
|
+
* @returns {boolean} Whether target is point-like
|
|
235
|
+
* @private
|
|
236
|
+
*/
|
|
251
237
|
function isCanvasPointType($$, target) {
|
|
252
|
-
|
|
253
|
-
isCanvasScatterType($$, target) ||
|
|
254
|
-
isCanvasBubbleType($$, target);
|
|
238
|
+
return isCanvasLineType($$, target) || isCanvasScatterType($$, target) || isCanvasBubbleType($$, target);
|
|
255
239
|
}
|
|
256
240
|
/**
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
241
|
+
* Check if a target should be handled as a canvas candlestick.
|
|
242
|
+
* @param {object} $$ ChartInternal instance
|
|
243
|
+
* @param {object|string} target Data target, data row or id
|
|
244
|
+
* @returns {boolean} Whether target is candlestick
|
|
245
|
+
* @private
|
|
246
|
+
*/
|
|
263
247
|
function isCanvasCandlestickType($$, target) {
|
|
264
|
-
|
|
248
|
+
return getCanvasTargetType($$.config, target) === TYPE.CANDLESTICK;
|
|
265
249
|
}
|
|
266
250
|
/**
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
251
|
+
* Check if a target should be handled as a canvas treemap.
|
|
252
|
+
* @param {object} $$ ChartInternal instance
|
|
253
|
+
* @param {object|string} target Data target, data row or id
|
|
254
|
+
* @returns {boolean} Whether target is treemap
|
|
255
|
+
* @private
|
|
256
|
+
*/
|
|
273
257
|
function isCanvasTreemapType($$, target) {
|
|
274
|
-
|
|
258
|
+
return getCanvasTargetType($$.config, target) === TYPE.TREEMAP;
|
|
275
259
|
}
|
|
276
260
|
/**
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
261
|
+
* Check if a data row has a drawable base value.
|
|
262
|
+
* @param {object} $$ ChartInternal instance
|
|
263
|
+
* @param {object} d Data row
|
|
264
|
+
* @returns {boolean} Whether the row can be drawn or hit-tested
|
|
265
|
+
* @private
|
|
266
|
+
*/
|
|
283
267
|
function hasCanvasDrawableValue($$, d) {
|
|
284
|
-
|
|
285
|
-
|
|
268
|
+
const value = $$.getBaseValue(d);
|
|
269
|
+
return value !== null && value !== void 0;
|
|
286
270
|
}
|
|
287
271
|
/**
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
272
|
+
* Check if coordinates can be used on canvas.
|
|
273
|
+
* @param {number} x X coordinate
|
|
274
|
+
* @param {number} y Y coordinate
|
|
275
|
+
* @returns {boolean} Whether both coordinates are finite
|
|
276
|
+
* @private
|
|
277
|
+
*/
|
|
294
278
|
function isFiniteCanvasCoordinate(x, y) {
|
|
295
|
-
|
|
279
|
+
return Number.isFinite(x) && Number.isFinite(y);
|
|
296
280
|
}
|
|
297
281
|
/**
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
282
|
+
* Create an occupancy grid for dense point center culling.
|
|
283
|
+
* @param {number} width Plot width
|
|
284
|
+
* @param {number} height Plot height
|
|
285
|
+
* @param {number} radius Point radius
|
|
286
|
+
* @returns {object} Occupancy grid
|
|
287
|
+
* @private
|
|
288
|
+
*/
|
|
305
289
|
function createCanvasPointOccupancyGrid(width, height, radius) {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
290
|
+
const offset = Math.ceil(radius) + 1;
|
|
291
|
+
const gridWidth = Math.max(1, Math.ceil(width) + offset * 2 + 1);
|
|
292
|
+
const gridHeight = Math.max(1, Math.ceil(height) + offset * 2 + 1);
|
|
293
|
+
return {
|
|
294
|
+
data: new Uint8Array(gridWidth * gridHeight),
|
|
295
|
+
height: gridHeight,
|
|
296
|
+
offset,
|
|
297
|
+
width: gridWidth
|
|
298
|
+
};
|
|
315
299
|
}
|
|
316
300
|
/**
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
301
|
+
* Mark a point center in the occupancy grid.
|
|
302
|
+
* @param {object} grid Occupancy grid
|
|
303
|
+
* @param {number} x Point x coordinate
|
|
304
|
+
* @param {number} y Point y coordinate
|
|
305
|
+
* @returns {boolean} Whether this center has not been marked yet
|
|
306
|
+
* @private
|
|
307
|
+
*/
|
|
324
308
|
function markCanvasPointOccupancy(grid, x, y) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
return false;
|
|
333
|
-
}
|
|
334
|
-
grid.data[index] = 1;
|
|
335
|
-
return true;
|
|
309
|
+
const px = Math.round(x) + grid.offset;
|
|
310
|
+
const py = Math.round(y) + grid.offset;
|
|
311
|
+
if (px < 0 || px >= grid.width || py < 0 || py >= grid.height) return false;
|
|
312
|
+
const index = py * grid.width + px;
|
|
313
|
+
if (grid.data[index]) return false;
|
|
314
|
+
grid.data[index] = 1;
|
|
315
|
+
return true;
|
|
336
316
|
}
|
|
337
|
-
|
|
317
|
+
//#endregion
|
|
338
318
|
export { DENSE_SCATTER_POINT_CULL_THRESHOLD, createCanvasPointOccupancyGrid, getCanvasComparableValue, getCanvasComparableXDomain, getCanvasShapeIndices, getCanvasTargetType, getCanvasTargetVisibleRange, getFontSize, hasCanvasDrawableValue, isCanvasAreaType, isCanvasBarType, isCanvasBubbleType, isCanvasCandlestickType, isCanvasLineType, isCanvasPointType, isCanvasScatterType, isCanvasTargetSupported, isCanvasTreemapType, isFiniteCanvasCoordinate, markCanvasPointOccupancy };
|
|
@@ -5,39 +5,36 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 4.0.
|
|
8
|
+
* @version 4.1.0-next.1
|
|
9
9
|
*/
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
|
|
10
|
+
import { deepClone } from "../../module/util/object.js";
|
|
11
|
+
import boost_default from "./common/boost.js";
|
|
12
|
+
import color_default from "./common/color.js";
|
|
13
|
+
import legend_default from "./common/legend.js";
|
|
14
|
+
import main_default from "./common/main.js";
|
|
15
|
+
import title_default from "./common/title.js";
|
|
16
|
+
import tooltip_default from "./common/tooltip.js";
|
|
17
|
+
import data_default from "./data/data.js";
|
|
18
|
+
import interaction_default from "./interaction/interaction.js";
|
|
19
|
+
//#region src/config/Options/Options.ts
|
|
20
20
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// common
|
|
21
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
22
|
+
* billboard.js project is licensed under the MIT license
|
|
23
|
+
*/
|
|
25
24
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class Options {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
25
|
+
* Class to set options on generating chart.
|
|
26
|
+
* - It's instantiated internally, not exposed for public.
|
|
27
|
+
* @class Options
|
|
28
|
+
* @see {@link bb.generate} to use these options on generating the chart
|
|
29
|
+
*/
|
|
30
|
+
var Options = class Options {
|
|
31
|
+
static data = {};
|
|
32
|
+
static setOptions(options) {
|
|
33
|
+
for (let i = 0; i < options.length; i++) Object.assign(this.data, options[i]);
|
|
34
|
+
}
|
|
35
|
+
constructor() {
|
|
36
|
+
return deepClone(main_default, boost_default, data_default, color_default, interaction_default, legend_default, title_default, tooltip_default, Options.data);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
43
40
|
export { Options as default };
|