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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "billboard.js",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Re-usable easy interface JavaScript chart library, based on D3 v4+",
|
|
5
5
|
"homepage": "https://naver.github.io/billboard.js/",
|
|
6
6
|
"main": "dist/billboard.js",
|
|
@@ -47,7 +47,6 @@
|
|
|
47
47
|
"test": "vitest",
|
|
48
48
|
"coverage": "vitest run",
|
|
49
49
|
"coverage:ci": "cross-env NODE_ENV=CI npm run coverage",
|
|
50
|
-
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
|
|
51
50
|
"jsdoc": "node ./config/jsdoc.js",
|
|
52
51
|
"jsdoc:cmd": "jsdoc -c jsdoc.json",
|
|
53
52
|
"lint-staged": "lint-staged --config ./config/.lintstagedrc.json",
|
|
@@ -55,6 +54,8 @@
|
|
|
55
54
|
},
|
|
56
55
|
"sideEffects": [
|
|
57
56
|
"dist/**/*.css",
|
|
57
|
+
"dist-esm/Chart/api/stubs.js",
|
|
58
|
+
"src/Chart/api/stubs.ts",
|
|
58
59
|
"src/index.ts"
|
|
59
60
|
],
|
|
60
61
|
"repository": {
|
|
@@ -122,15 +123,14 @@
|
|
|
122
123
|
"@testing-library/react": "^16.3.2",
|
|
123
124
|
"@types/d3": "^7.4.3",
|
|
124
125
|
"@types/sinon": "^21.0.0",
|
|
125
|
-
"@vitest/browser": "^4.1.
|
|
126
|
-
"@vitest/browser-playwright": "^4.1.
|
|
127
|
-
"@vitest/coverage-istanbul": "^4.1.
|
|
128
|
-
"@vitest/ui": "^4.1.
|
|
126
|
+
"@vitest/browser": "^4.1.8",
|
|
127
|
+
"@vitest/browser-playwright": "^4.1.8",
|
|
128
|
+
"@vitest/coverage-istanbul": "^4.1.8",
|
|
129
|
+
"@vitest/ui": "^4.1.8",
|
|
129
130
|
"better-docs": "^2.7.3",
|
|
130
131
|
"clean-webpack-plugin": "^4.0.0",
|
|
131
132
|
"cloc": "2.6.0-cloc",
|
|
132
133
|
"core-js": "^3.49.0",
|
|
133
|
-
"coveralls": "^3.1.1",
|
|
134
134
|
"cross-env": "^10.1.0",
|
|
135
135
|
"css-loader": "^7.1.4",
|
|
136
136
|
"d3-delaunay": "^6.0.4",
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
"jsdoc": "^4.0.5",
|
|
145
145
|
"lint-staged": "^16.4.0",
|
|
146
146
|
"mini-css-extract-plugin": "^2.10.2",
|
|
147
|
-
"playwright": "^1.
|
|
147
|
+
"playwright": "^1.59.1",
|
|
148
148
|
"regenerator-runtime": "^0.14.1",
|
|
149
149
|
"rollup": "^4.60.0",
|
|
150
150
|
"rollup-plugin-delete": "^3.0.2",
|
|
@@ -158,16 +158,42 @@
|
|
|
158
158
|
"tslib": "^2.8.1",
|
|
159
159
|
"typescript": "^6.0.2",
|
|
160
160
|
"typescript-eslint": "^8.57.2",
|
|
161
|
-
"vitest": "^4.1.
|
|
161
|
+
"vitest": "^4.1.8",
|
|
162
162
|
"webpack": "^5.105.4",
|
|
163
163
|
"webpack-bundle-analyzer": "^5.3.0",
|
|
164
164
|
"webpack-clean": "^1.2.5",
|
|
165
165
|
"webpack-cli": "^7.0.2",
|
|
166
|
-
"webpack-
|
|
167
|
-
"webpack-dev-server": "^5.2.3",
|
|
166
|
+
"webpack-dev-server": "^5.2.4",
|
|
168
167
|
"webpack-merge": "^6.0.1",
|
|
169
168
|
"webpackbar": "^7.0.0",
|
|
170
169
|
"write-file-webpack-plugin": "^4.5.1"
|
|
171
170
|
},
|
|
171
|
+
"resolutions": {
|
|
172
|
+
"handlebars": "^4.7.9",
|
|
173
|
+
"underscore": "^1.13.8",
|
|
174
|
+
"lodash": "^4.18.1",
|
|
175
|
+
"lodash-es": "^4.18.1",
|
|
176
|
+
"flatted": "^3.4.2",
|
|
177
|
+
"cross-spawn": "^7.0.6",
|
|
178
|
+
"micromatch": "^4.0.8",
|
|
179
|
+
"ws": "^8.21.0",
|
|
180
|
+
"yaml": "^2.9.0",
|
|
181
|
+
"postcss": "^8.5.15",
|
|
182
|
+
"qs": "^6.15.2",
|
|
183
|
+
"follow-redirects": "^1.16.0",
|
|
184
|
+
"launch-editor": "^2.14.1",
|
|
185
|
+
"shell-quote": "^1.8.4",
|
|
186
|
+
"markdown-it": "^14.2.0",
|
|
187
|
+
"pug": "^3.0.4",
|
|
188
|
+
"pug-code-gen": "^3.0.3",
|
|
189
|
+
"vite": "^8.0.16",
|
|
190
|
+
"diff": "^8.0.3",
|
|
191
|
+
"js-yaml": "^4.1.1",
|
|
192
|
+
"@babel/helpers": "^7.29.7",
|
|
193
|
+
"@babel/runtime": "^7.29.7",
|
|
194
|
+
"@isaacs/brace-expansion": "^5.0.1",
|
|
195
|
+
"fast-uri": "3.1.2",
|
|
196
|
+
"path-to-regexp": "0.1.13"
|
|
197
|
+
},
|
|
172
198
|
"packageManager": "yarn@4.13.0"
|
|
173
199
|
}
|
|
@@ -17,6 +17,56 @@ export default class AxisRenderer {
|
|
|
17
17
|
private g;
|
|
18
18
|
private generatedTicks: (Date | number)[] = [];
|
|
19
19
|
|
|
20
|
+
private canReuseTickTextOnResize(isLeftRight: boolean): boolean {
|
|
21
|
+
const {config, params} = this;
|
|
22
|
+
const {config: chartConfig, id, owner} = params;
|
|
23
|
+
const isX = /^(x|subX)$/.test(id);
|
|
24
|
+
const type = id === "subX" ? "x" : id;
|
|
25
|
+
const customTickFormat = id === "subX" ?
|
|
26
|
+
chartConfig.subchart_axis_x_tick_format || chartConfig.axis_x_tick_format :
|
|
27
|
+
chartConfig[`axis_${type}_tick_format`];
|
|
28
|
+
const categoryAutoWrap = params.tickMultiline && params.isCategory && !isLeftRight &&
|
|
29
|
+
!(params.tickWidth > 0);
|
|
30
|
+
|
|
31
|
+
return !!(
|
|
32
|
+
owner.state.resizing &&
|
|
33
|
+
!owner.state.flowing &&
|
|
34
|
+
!isFunction(chartConfig.axis_evalTextSize) &&
|
|
35
|
+
!customTickFormat &&
|
|
36
|
+
!params.tickTitle &&
|
|
37
|
+
!(isX && chartConfig.axis_x_tick_autorotate) &&
|
|
38
|
+
!categoryAutoWrap &&
|
|
39
|
+
config.withoutTransition
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private canReuseTickNodesOnResize(tickNodes: d3Selection, ticks, isLeftRight: boolean,
|
|
44
|
+
tickShow): boolean {
|
|
45
|
+
if (
|
|
46
|
+
tickShow.tick || !tickShow.text || !this.canReuseTickTextOnResize(isLeftRight) ||
|
|
47
|
+
tickNodes.size() !== ticks.length
|
|
48
|
+
) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const nodes = tickNodes.nodes();
|
|
53
|
+
|
|
54
|
+
for (let i = 0; i < ticks.length; i++) {
|
|
55
|
+
const current = (nodes[i] as any).__data__;
|
|
56
|
+
const next = ticks[i];
|
|
57
|
+
|
|
58
|
+
if (current instanceof Date || next instanceof Date) {
|
|
59
|
+
if (+current !== +next) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
} else if (current !== next) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
|
|
20
70
|
constructor(params: any = {}) {
|
|
21
71
|
const config = {
|
|
22
72
|
innerTickSize: AXIS_TICK_SIZE,
|
|
@@ -122,133 +172,158 @@ export default class AxisRenderer {
|
|
|
122
172
|
ctx.generatedTicks = ticks;
|
|
123
173
|
|
|
124
174
|
// update selection
|
|
125
|
-
let tick: d3Selection = g.selectAll(".tick")
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
175
|
+
let tick: d3Selection = g.selectAll(".tick");
|
|
176
|
+
const canReuseTickNodes = ctx.canReuseTickNodesOnResize(
|
|
177
|
+
tick,
|
|
178
|
+
ticks,
|
|
179
|
+
isLeftRight || params.config.axis_rotated,
|
|
180
|
+
tickShow
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
if (canReuseTickNodes) {
|
|
184
|
+
tickTransform(tick, scale1);
|
|
185
|
+
} else {
|
|
186
|
+
tick = tick.data(ticks, scale1);
|
|
136
187
|
|
|
137
|
-
|
|
138
|
-
|
|
188
|
+
// enter selection
|
|
189
|
+
const tickEnter = tick
|
|
190
|
+
.enter()
|
|
191
|
+
.insert("g", ".domain")
|
|
192
|
+
.attr("class", "tick");
|
|
139
193
|
|
|
140
|
-
|
|
141
|
-
|
|
194
|
+
// MEMO: No exit transition. The reason is this transition affects max tick width calculation because old tick will be included in the ticks.
|
|
195
|
+
const tickExit = tick.exit().remove();
|
|
142
196
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
let sizeFor1Char = {w: 0, h: 0};
|
|
197
|
+
// enter + update selection
|
|
198
|
+
tick = tickEnter.merge(tick);
|
|
146
199
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
sizeFor1Char = evalTextSize.bind(ctx.params.owner.api)(tickText.node(), id);
|
|
200
|
+
tickShow.tick && tickEnter.append("line");
|
|
201
|
+
tickShow.text && tickEnter.append("text");
|
|
150
202
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
203
|
+
const hasTickChange = !tickEnter.empty() || !tickExit.empty();
|
|
204
|
+
const reuseTickText = tickShow.text && !hasTickChange &&
|
|
205
|
+
ctx.canReuseTickTextOnResize(isLeftRight || params.config.axis_rotated);
|
|
206
|
+
let sizeFor1Char = {w: 0, h: 0};
|
|
207
|
+
let textUpdate = tick.selectAll("text.__bb-empty");
|
|
155
208
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
209
|
+
if (tickShow.text && !reuseTickText) {
|
|
210
|
+
const tickText = tick.select("text");
|
|
211
|
+
const counts: number[] = [];
|
|
159
212
|
|
|
160
|
-
|
|
161
|
-
.selectAll("tspan")
|
|
162
|
-
.data((d, index) => {
|
|
163
|
-
let split;
|
|
213
|
+
textUpdate = tickText;
|
|
164
214
|
|
|
165
|
-
if (
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
215
|
+
if (isFunction(evalTextSize)) {
|
|
216
|
+
// set evalTextSize to dummy axis element to be used in .getMaxTickSize()
|
|
217
|
+
sizeFor1Char = evalTextSize.bind(ctx.params.owner.api)(tickText.node(),
|
|
218
|
+
id);
|
|
169
219
|
|
|
170
|
-
|
|
220
|
+
if (this.classList.contains($COMMON.dummy)) {
|
|
221
|
+
this.sizeFor1Char = sizeFor1Char;
|
|
222
|
+
}
|
|
171
223
|
}
|
|
172
224
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
tspan.exit().remove();
|
|
179
|
-
|
|
180
|
-
tspan = tspan
|
|
181
|
-
.enter()
|
|
182
|
-
.append("tspan")
|
|
183
|
-
.merge(tspan)
|
|
184
|
-
.text(d => d.splitted);
|
|
185
|
-
|
|
186
|
-
// set <tspan>'s position
|
|
187
|
-
tspan
|
|
188
|
-
.attr("x", isTopBottom ? 0 : tickLength * sign)
|
|
189
|
-
.attr("dx", (() => {
|
|
190
|
-
let dx = 0;
|
|
191
|
-
|
|
192
|
-
if (/(top|bottom)/.test(orient) && rotate) {
|
|
193
|
-
dx = 8 * Math.sin(Math.PI * (rotate / 180)) *
|
|
194
|
-
(orient === "top" ? -1 : 1);
|
|
225
|
+
if (!sizeFor1Char || sizeFor1Char.w === 0 || sizeFor1Char.h === 0) {
|
|
226
|
+
sizeFor1Char = ctx.helper.getSizeFor1Char(orient, tickText,
|
|
227
|
+
!!evalTextSize);
|
|
195
228
|
}
|
|
196
229
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
230
|
+
let tspan: d3Selection = tickText
|
|
231
|
+
.selectAll("tspan")
|
|
232
|
+
.data((d, index) => {
|
|
233
|
+
let split;
|
|
234
|
+
|
|
235
|
+
if (params.tickMultiline) {
|
|
236
|
+
split = splitTickText(d, scale1, ticks, isLeftRight,
|
|
237
|
+
sizeFor1Char.w);
|
|
238
|
+
} else {
|
|
239
|
+
const formatted = helper.textFormatted(d);
|
|
240
|
+
|
|
241
|
+
split = isArray(formatted) ? formatted.concat() : [formatted];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
counts[index] = split.length;
|
|
245
|
+
|
|
246
|
+
return split.map(splitted => ({index, splitted}));
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
tspan.exit().remove();
|
|
250
|
+
|
|
251
|
+
tspan = tspan
|
|
252
|
+
.enter()
|
|
253
|
+
.append("tspan")
|
|
254
|
+
.merge(tspan)
|
|
255
|
+
.text(d => d.splitted);
|
|
256
|
+
|
|
257
|
+
// set <tspan>'s position
|
|
258
|
+
tspan
|
|
259
|
+
.attr("x", isTopBottom ? 0 : tickLength * sign)
|
|
260
|
+
.attr("dx", (() => {
|
|
261
|
+
let dx = 0;
|
|
262
|
+
|
|
263
|
+
if (/(top|bottom)/.test(orient) && rotate) {
|
|
264
|
+
dx = 8 * Math.sin(Math.PI * (rotate / 180)) *
|
|
265
|
+
(orient === "top" ? -1 : 1);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return dx + (tickTextPos.x || 0);
|
|
269
|
+
})())
|
|
270
|
+
.attr("dy", (d, i) => {
|
|
271
|
+
const defValue = ".71em";
|
|
272
|
+
let dy: number | string = 0;
|
|
273
|
+
|
|
274
|
+
if (orient !== "top") {
|
|
275
|
+
dy = sizeFor1Char.h;
|
|
276
|
+
|
|
277
|
+
if (i === 0) {
|
|
278
|
+
dy = isLeftRight ?
|
|
279
|
+
-((counts[d.index] - 1) * (sizeFor1Char.h / 2) - 3) :
|
|
280
|
+
(tickTextPos.y === 0 ? defValue : 0);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return isNumber(dy) && tickTextPos.y ?
|
|
285
|
+
dy + tickTextPos.y :
|
|
286
|
+
dy || defValue;
|
|
287
|
+
});
|
|
288
|
+
}
|
|
202
289
|
|
|
203
|
-
|
|
204
|
-
dy = sizeFor1Char.h;
|
|
290
|
+
const lineUpdate = tick.select("line");
|
|
205
291
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
-((counts[d.index] - 1) * (sizeFor1Char.h / 2) - 3) :
|
|
209
|
-
(tickTextPos.y === 0 ? defValue : 0);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
292
|
+
tickEnter.select("line").attr(`${axisPx}2`, innerTickSize * sign);
|
|
293
|
+
tickEnter.select("text").attr(axisPx, tickLength * sign);
|
|
212
294
|
|
|
213
|
-
|
|
214
|
-
});
|
|
295
|
+
ctx.setTickLineTextPosition(lineUpdate, textUpdate, sizeFor1Char);
|
|
215
296
|
|
|
216
|
-
|
|
217
|
-
|
|
297
|
+
// Append <title> for tooltip display
|
|
298
|
+
if (params.tickTitle) {
|
|
299
|
+
const title = textUpdate.select("title");
|
|
300
|
+
const tickTitle = params.tickTitle;
|
|
218
301
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
ctx.setTickLineTextPosition(lineUpdate, textUpdate, sizeFor1Char);
|
|
302
|
+
(title.empty() ? textUpdate.append("title") : title)
|
|
303
|
+
.text(index => tickTitle[Number(index)]);
|
|
304
|
+
}
|
|
223
305
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
306
|
+
if (scale1.bandwidth) {
|
|
307
|
+
const x = scale1;
|
|
308
|
+
const dx = x.bandwidth() / 2;
|
|
227
309
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
310
|
+
scale0 = d => x(d) + dx;
|
|
311
|
+
scale1 = scale0;
|
|
312
|
+
} else if (scale0.bandwidth) {
|
|
313
|
+
scale0 = scale1;
|
|
314
|
+
} else {
|
|
315
|
+
tickTransform(tickExit, scale1);
|
|
316
|
+
}
|
|
231
317
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
318
|
+
// when .flow(), it should follow flow's transition config
|
|
319
|
+
// otherwise make to use ChartInternals.$T()
|
|
320
|
+
tick = params.owner.state.flowing ?
|
|
321
|
+
helper.transitionise(tick) :
|
|
322
|
+
params.owner.$T(tick);
|
|
235
323
|
|
|
236
|
-
scale0
|
|
237
|
-
|
|
238
|
-
} else if (scale0.bandwidth) {
|
|
239
|
-
scale0 = scale1;
|
|
240
|
-
} else {
|
|
241
|
-
tickTransform(tickExit, scale1);
|
|
324
|
+
tickTransform(tickEnter, scale0);
|
|
325
|
+
tickTransform(tick.style("opacity", null), scale1);
|
|
242
326
|
}
|
|
243
|
-
|
|
244
|
-
// when .flow(), it should follow flow's transition config
|
|
245
|
-
// otherwise make to use ChartInternals.$T()
|
|
246
|
-
tick = params.owner.state.flowing ?
|
|
247
|
-
helper.transitionise(tick) :
|
|
248
|
-
params.owner.$T(tick);
|
|
249
|
-
|
|
250
|
-
tickTransform(tickEnter, scale0);
|
|
251
|
-
tickTransform(tick.style("opacity", null), scale1);
|
|
252
327
|
}
|
|
253
328
|
});
|
|
254
329
|
|
|
@@ -360,7 +435,6 @@ export default class AxisRenderer {
|
|
|
360
435
|
textUpdate
|
|
361
436
|
.attr("x", 0)
|
|
362
437
|
.attr("y", yForText(rotate))
|
|
363
|
-
.style("text-anchor", textAnchorForText(rotate))
|
|
364
438
|
.style("text-anchor", (d, i, {length}) => {
|
|
365
439
|
if (!isRotated && i === 0 && (inner === true || inner.first)) {
|
|
366
440
|
return "start";
|
|
@@ -532,7 +532,7 @@ export default class ChartInternal {
|
|
|
532
532
|
$el.defs = $el.svg.append("defs");
|
|
533
533
|
|
|
534
534
|
if (hasAxis) {
|
|
535
|
-
["id", "idXAxis", "idYAxis", "
|
|
535
|
+
["id", "idXAxis", "idYAxis", "idGrid"].forEach(v => {
|
|
536
536
|
$$.appendClip($el.defs, state.clip[v]);
|
|
537
537
|
});
|
|
538
538
|
}
|
|
@@ -919,10 +919,18 @@ export default class ChartInternal {
|
|
|
919
919
|
$$.resizeFunction = resizeFunction;
|
|
920
920
|
|
|
921
921
|
// attach resize event
|
|
922
|
-
if (resize_auto === "parent") {
|
|
923
|
-
($$.resizeFunction.resizeObserver = new ResizeObserver(
|
|
922
|
+
if (resize_auto === "parent" && window.ResizeObserver) {
|
|
923
|
+
($$.resizeFunction.resizeObserver = new window.ResizeObserver(
|
|
924
|
+
$$.resizeFunction.bind($$)
|
|
925
|
+
))
|
|
924
926
|
.observe($el.chart.node().parentNode);
|
|
925
927
|
} else {
|
|
928
|
+
if (resize_auto === "parent") {
|
|
929
|
+
// ResizeObserver unavailable: parent-specific resize won't be detected
|
|
930
|
+
window.console?.warn?.(
|
|
931
|
+
"[billboard.js] resize.auto='parent' requires ResizeObserver; falling back to window resize."
|
|
932
|
+
);
|
|
933
|
+
}
|
|
926
934
|
window.addEventListener("resize", $$.resizeFunction);
|
|
927
935
|
}
|
|
928
936
|
}
|
|
@@ -274,7 +274,9 @@ export default {
|
|
|
274
274
|
// width/height must be part of the key: resize keeps the domain but moves coords.
|
|
275
275
|
const xDomain = xScale?.domain();
|
|
276
276
|
const fingerprint = xDomain ?
|
|
277
|
-
`${xDomain[0]}_${
|
|
277
|
+
`${xDomain[0]}_${
|
|
278
|
+
xDomain[1]
|
|
279
|
+
}_${state.width}_${state.height}_${$$.data.targets.length}_${state.dataGeneration}_${
|
|
278
280
|
[...state.hiddenTargetIds].join(",")
|
|
279
281
|
}` :
|
|
280
282
|
null;
|
|
@@ -499,14 +499,16 @@ export default {
|
|
|
499
499
|
$$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))
|
|
500
500
|
);
|
|
501
501
|
|
|
502
|
-
//
|
|
502
|
+
// Same IDs can receive new values through load()/flow(), so ID-only
|
|
503
|
+
// caching can leave stacked offsets pointing at stale row maps.
|
|
504
|
+
const dataGeneration = $$.state.dataGeneration;
|
|
503
505
|
const targetIds = targets.map(t => t.id).join("_");
|
|
504
506
|
const cacheKey = `${KEY.shapeOffset}_${targetIds}`;
|
|
505
507
|
|
|
506
508
|
// Check if result is already cached
|
|
507
509
|
const cachedData = $$.cache.get(cacheKey);
|
|
508
510
|
|
|
509
|
-
if (cachedData) {
|
|
511
|
+
if (cachedData?.generation === dataGeneration) {
|
|
510
512
|
return cachedData;
|
|
511
513
|
}
|
|
512
514
|
|
|
@@ -542,7 +544,7 @@ export default {
|
|
|
542
544
|
return out;
|
|
543
545
|
}, {});
|
|
544
546
|
|
|
545
|
-
const result = {indexMapByTargetId, shapeOffsetTargets};
|
|
547
|
+
const result = {generation: dataGeneration, indexMapByTargetId, shapeOffsetTargets};
|
|
546
548
|
|
|
547
549
|
// Cache the result
|
|
548
550
|
$$.cache.add(cacheKey, result);
|
|
@@ -112,7 +112,23 @@ export default class Options {
|
|
|
112
112
|
* @example
|
|
113
113
|
* nullString: "N/A"
|
|
114
114
|
*/
|
|
115
|
-
nullString: "-"
|
|
115
|
+
nullString: "-",
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Set number format function.
|
|
119
|
+
* @name numberFormat
|
|
120
|
+
* @memberof plugin-tableview
|
|
121
|
+
* @type {function}
|
|
122
|
+
* @returns {string}
|
|
123
|
+
* @default function(v) { // will return formatted value according to locale settings }
|
|
124
|
+
* @example
|
|
125
|
+
* numberFormat: function(v) {
|
|
126
|
+
* return v.toLocaleString();
|
|
127
|
+
* }
|
|
128
|
+
*/
|
|
129
|
+
numberFormat: function(v: number): string {
|
|
130
|
+
return v.toLocaleString();
|
|
131
|
+
}
|
|
116
132
|
};
|
|
117
133
|
}
|
|
118
134
|
}
|
|
@@ -134,7 +134,7 @@ export default class TableView extends Plugin {
|
|
|
134
134
|
tplProcess(i ? tpl.tbody : tpl.tbodyHeader, {
|
|
135
135
|
value: i === 0 ?
|
|
136
136
|
config.categoryFormat.bind(this)(d) :
|
|
137
|
-
(isNumber(d) ?
|
|
137
|
+
(isNumber(d) ? config.numberFormat.bind(this)(d) : config.nullString)
|
|
138
138
|
})
|
|
139
139
|
).join("")
|
|
140
140
|
}</tr>`;
|
|
@@ -16,6 +16,7 @@ export default class CanvasEngine {
|
|
|
16
16
|
private dpr = 1;
|
|
17
17
|
private frame: HTMLCanvasElement | null = null;
|
|
18
18
|
private frameCtx: CanvasRenderingContext2D | null = null;
|
|
19
|
+
private frameValid = false;
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Create and attach the canvas element.
|
|
@@ -56,6 +57,7 @@ export default class CanvasEngine {
|
|
|
56
57
|
this.ctx.setTransform(this.dpr, 0, 0, this.dpr, 0, 0);
|
|
57
58
|
this.frame = null;
|
|
58
59
|
this.frameCtx = null;
|
|
60
|
+
this.frameValid = false;
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
/**
|
|
@@ -63,7 +65,7 @@ export default class CanvasEngine {
|
|
|
63
65
|
* @private
|
|
64
66
|
*/
|
|
65
67
|
clearOverlay(): void {
|
|
66
|
-
this.restoreFrame();
|
|
68
|
+
this.frameValid && this.restoreFrame();
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
/**
|
|
@@ -73,8 +75,15 @@ export default class CanvasEngine {
|
|
|
73
75
|
*/
|
|
74
76
|
withOverlay(draw: (ctx: CanvasRenderingContext2D) => void): void {
|
|
75
77
|
const {ctx} = this;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
const hasFrame = this.frameValid;
|
|
79
|
+
|
|
80
|
+
if (hasFrame) {
|
|
81
|
+
this.clearOverlay();
|
|
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
|
+
}
|
|
78
87
|
ctx.save();
|
|
79
88
|
ctx.setTransform(this.dpr, 0, 0, this.dpr, 0, 0);
|
|
80
89
|
try {
|
|
@@ -93,6 +102,7 @@ export default class CanvasEngine {
|
|
|
93
102
|
beginFrame(w: number, h: number): void {
|
|
94
103
|
const {ctx} = this;
|
|
95
104
|
|
|
105
|
+
this.frameValid = false;
|
|
96
106
|
ctx.save();
|
|
97
107
|
ctx.setTransform(this.dpr, 0, 0, this.dpr, 0, 0);
|
|
98
108
|
ctx.clearRect(0, 0, w, h);
|
|
@@ -104,7 +114,6 @@ export default class CanvasEngine {
|
|
|
104
114
|
*/
|
|
105
115
|
endFrame(): void {
|
|
106
116
|
this.ctx.restore();
|
|
107
|
-
this.captureFrame();
|
|
108
117
|
}
|
|
109
118
|
|
|
110
119
|
/**
|
|
@@ -114,6 +123,8 @@ export default class CanvasEngine {
|
|
|
114
123
|
captureFrame(): void {
|
|
115
124
|
const {canvas} = this;
|
|
116
125
|
|
|
126
|
+
this.frameValid = false;
|
|
127
|
+
|
|
117
128
|
if (canvas.width && canvas.height) {
|
|
118
129
|
let {frame, frameCtx} = this;
|
|
119
130
|
|
|
@@ -142,6 +153,7 @@ export default class CanvasEngine {
|
|
|
142
153
|
}
|
|
143
154
|
|
|
144
155
|
frameCtx.drawImage(canvas, 0, 0);
|
|
156
|
+
this.frameValid = true;
|
|
145
157
|
}
|
|
146
158
|
}
|
|
147
159
|
|
|
@@ -150,7 +162,7 @@ export default class CanvasEngine {
|
|
|
150
162
|
* @private
|
|
151
163
|
*/
|
|
152
164
|
restoreFrame(): void {
|
|
153
|
-
if (!this.frame || !this.frameCtx) {
|
|
165
|
+
if (!this.frameValid || !this.frame || !this.frameCtx) {
|
|
154
166
|
return;
|
|
155
167
|
}
|
|
156
168
|
|
|
@@ -172,5 +184,6 @@ export default class CanvasEngine {
|
|
|
172
184
|
this.canvas?.remove();
|
|
173
185
|
this.frame = null;
|
|
174
186
|
this.frameCtx = null;
|
|
187
|
+
this.frameValid = false;
|
|
175
188
|
}
|
|
176
189
|
}
|