billboard.js 3.13.0 → 3.14.0-next.2

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.
Files changed (70) hide show
  1. package/README.md +1 -1
  2. package/dist/billboard.css +1 -1
  3. package/dist/billboard.js +349 -176
  4. package/dist/billboard.min.css +1 -1
  5. package/dist/billboard.min.js +10 -10
  6. package/dist/billboard.pkgd.js +572 -399
  7. package/dist/billboard.pkgd.min.js +18 -18
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.js +7 -4
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  10. package/dist/plugin/billboardjs-plugin-sparkline.js +37 -11
  11. package/dist/plugin/billboardjs-plugin-sparkline.min.js +3 -3
  12. package/dist/plugin/billboardjs-plugin-stanford.js +41 -15
  13. package/dist/plugin/billboardjs-plugin-stanford.min.js +3 -3
  14. package/dist/plugin/billboardjs-plugin-tableview.js +37 -11
  15. package/dist/plugin/billboardjs-plugin-tableview.min.js +6 -6
  16. package/dist/plugin/billboardjs-plugin-textoverlap.js +36 -10
  17. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +3 -3
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +50 -50
  19. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +138 -115
  21. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +6 -6
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +178 -155
  23. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +11 -11
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +138 -115
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +2 -2
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +150 -127
  27. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -7
  28. package/dist/theme/dark.css +1 -1
  29. package/dist/theme/dark.min.css +1 -1
  30. package/dist/theme/datalab.css +1 -1
  31. package/dist/theme/datalab.min.css +1 -1
  32. package/dist/theme/graph.css +1 -1
  33. package/dist/theme/graph.min.css +1 -1
  34. package/dist/theme/insight.css +1 -1
  35. package/dist/theme/insight.min.css +1 -1
  36. package/dist/theme/modern.css +1 -1
  37. package/dist/theme/modern.min.css +1 -1
  38. package/dist-esm/billboard.js +267 -67
  39. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +3 -3
  40. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +3 -3
  41. package/dist-esm/plugin/billboardjs-plugin-stanford.js +3 -3
  42. package/dist-esm/plugin/billboardjs-plugin-tableview.js +3 -3
  43. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +3 -3
  44. package/package.json +32 -31
  45. package/src/Chart/Chart.ts +11 -0
  46. package/src/ChartInternal/Axis/AxisRenderer.ts +6 -2
  47. package/src/ChartInternal/Axis/AxisRendererHelper.ts +13 -8
  48. package/src/ChartInternal/ChartInternal.ts +9 -7
  49. package/src/ChartInternal/data/data.ts +18 -4
  50. package/src/ChartInternal/data/load.ts +4 -0
  51. package/src/ChartInternal/interactions/eventrect.ts +11 -7
  52. package/src/ChartInternal/interactions/interaction.ts +21 -6
  53. package/src/ChartInternal/interactions/zoom.ts +11 -3
  54. package/src/ChartInternal/internals/legend.ts +16 -6
  55. package/src/ChartInternal/internals/size.ts +10 -5
  56. package/src/ChartInternal/internals/tooltip.ts +54 -2
  57. package/src/ChartInternal/internals/type.ts +2 -1
  58. package/src/ChartInternal/shape/arc.ts +2 -1
  59. package/src/ChartInternal/shape/funnel.ts +4 -2
  60. package/src/ChartInternal/shape/radar.ts +5 -1
  61. package/src/ChartInternal/shape/treemap.ts +4 -2
  62. package/src/config/Options/axis/axis.ts +30 -0
  63. package/src/config/Options/axis/y2.ts +13 -0
  64. package/src/config/Options/common/legend.ts +6 -3
  65. package/src/config/Options/common/main.ts +18 -7
  66. package/src/config/Options/interaction/interaction.ts +8 -2
  67. package/src/module/error.ts +11 -7
  68. package/src/module/util.ts +61 -7
  69. package/types/axis.d.ts +7 -0
  70. package/types/options.d.ts +15 -5
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.13.0
8
+ * @version 3.14.0-next.2
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -25,7 +25,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25
25
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
26
26
  PERFORMANCE OF THIS SOFTWARE.
27
27
  ***************************************************************************** */
28
- /* global Reflect, Promise, SuppressedError, Symbol */
28
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
29
29
 
30
30
  var extendStatics = function(d, b) {
31
31
  extendStatics = Object.setPrototypeOf ||
@@ -100,7 +100,7 @@ var Plugin = /** @class */ (function () {
100
100
  delete _this[key];
101
101
  });
102
102
  };
103
- Plugin.version = "3.13.0";
103
+ Plugin.version = "3.14.0-next.2";
104
104
  return Plugin;
105
105
  }());
106
106
 
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.13.0
8
+ * @version 3.14.0-next.2
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -23,7 +23,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
23
23
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
24
24
  PERFORMANCE OF THIS SOFTWARE.
25
25
  ***************************************************************************** */
26
- /* global Reflect, Promise, SuppressedError, Symbol */
26
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
27
27
 
28
28
  var extendStatics = function(d, b) {
29
29
  extendStatics = Object.setPrototypeOf ||
@@ -443,7 +443,7 @@ var Plugin = /** @class */ (function () {
443
443
  delete _this[key];
444
444
  });
445
445
  };
446
- Plugin.version = "3.13.0";
446
+ Plugin.version = "3.14.0-next.2";
447
447
  return Plugin;
448
448
  }());
449
449
 
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.13.0
8
+ * @version 3.14.0-next.2
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -29,7 +29,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
29
29
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
30
30
  PERFORMANCE OF THIS SOFTWARE.
31
31
  ***************************************************************************** */
32
- /* global Reflect, Promise, SuppressedError, Symbol */
32
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
33
33
 
34
34
  var extendStatics = function(d, b) {
35
35
  extendStatics = Object.setPrototypeOf ||
@@ -501,7 +501,7 @@ var Plugin = /** @class */ (function () {
501
501
  delete _this[key];
502
502
  });
503
503
  };
504
- Plugin.version = "3.13.0";
504
+ Plugin.version = "3.14.0-next.2";
505
505
  return Plugin;
506
506
  }());
507
507
 
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.13.0
8
+ * @version 3.14.0-next.2
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -23,7 +23,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
23
23
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
24
24
  PERFORMANCE OF THIS SOFTWARE.
25
25
  ***************************************************************************** */
26
- /* global Reflect, Promise, SuppressedError, Symbol */
26
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
27
27
 
28
28
  var extendStatics = function(d, b) {
29
29
  extendStatics = Object.setPrototypeOf ||
@@ -290,7 +290,7 @@ var Plugin = /** @class */ (function () {
290
290
  delete _this[key];
291
291
  });
292
292
  };
293
- Plugin.version = "3.13.0";
293
+ Plugin.version = "3.14.0-next.2";
294
294
  return Plugin;
295
295
  }());
296
296
 
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.13.0
8
+ * @version 3.14.0-next.2
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -26,7 +26,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
26
26
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
27
27
  PERFORMANCE OF THIS SOFTWARE.
28
28
  ***************************************************************************** */
29
- /* global Reflect, Promise, SuppressedError, Symbol */
29
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
30
30
 
31
31
  var extendStatics = function(d, b) {
32
32
  extendStatics = Object.setPrototypeOf ||
@@ -267,7 +267,7 @@ var Plugin = /** @class */ (function () {
267
267
  delete _this[key];
268
268
  });
269
269
  };
270
- Plugin.version = "3.13.0";
270
+ Plugin.version = "3.14.0-next.2";
271
271
  return Plugin;
272
272
  }());
273
273
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "billboard.js",
3
- "version": "3.13.0",
3
+ "version": "3.14.0-next.2",
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",
@@ -41,6 +41,7 @@
41
41
  "loc": "cloc --by-file src",
42
42
  "test": "vitest",
43
43
  "coverage": "vitest run",
44
+ "coverage:ci": "cross-env NODE_ENV=CI npm run coverage",
44
45
  "coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
45
46
  "jsdoc": "node ./config/jsdoc.js",
46
47
  "jsdoc:cmd": "jsdoc -c jsdoc.json",
@@ -84,8 +85,8 @@
84
85
  "license": "MIT",
85
86
  "readmeFilename": "README.md",
86
87
  "dependencies": {
87
- "@types/d3-selection": "^3.0.10",
88
- "@types/d3-transition": "^3.0.8",
88
+ "@types/d3-selection": "^3.0.11",
89
+ "@types/d3-transition": "^3.0.9",
89
90
  "d3-axis": "^3.0.0",
90
91
  "d3-brush": "^3.0.0",
91
92
  "d3-drag": "^3.0.0",
@@ -101,12 +102,12 @@
101
102
  "d3-zoom": "^3.0.0"
102
103
  },
103
104
  "devDependencies": {
104
- "@commitlint/cli": "^19.4.0",
105
- "@commitlint/config-conventional": "^19.2.2",
106
- "@eslint/js": "^9.9.0",
107
- "@rollup/plugin-node-resolve": "^15.2.3",
108
- "@rollup/plugin-replace": "^5.0.7",
109
- "@rollup/plugin-typescript": "^11.1.6",
105
+ "@commitlint/cli": "^19.5.0",
106
+ "@commitlint/config-conventional": "^19.5.0",
107
+ "@eslint/js": "^9.12.0",
108
+ "@rollup/plugin-node-resolve": "^15.3.0",
109
+ "@rollup/plugin-replace": "^6.0.1",
110
+ "@rollup/plugin-typescript": "^12.1.1",
110
111
  "@semantic-release/changelog": "^6.0.3",
111
112
  "@semantic-release/commit-analyzer": "^13.0.0",
112
113
  "@semantic-release/exec": "^6.0.3",
@@ -114,12 +115,12 @@
114
115
  "@semantic-release/npm": "^12.0.1",
115
116
  "@semantic-release/release-notes-generator": "^14.0.1",
116
117
  "@testing-library/dom": "^10.4.0",
117
- "@testing-library/react": "^16.0.0",
118
+ "@testing-library/react": "^16.0.1",
118
119
  "@types/d3": "^7.4.3",
119
120
  "@types/sinon": "^17.0.3",
120
- "@vitest/browser": "^2.0.5",
121
- "@vitest/coverage-istanbul": "^2.0.5",
122
- "@vitest/ui": "^2.0.5",
121
+ "@vitest/browser": "^2.1.3",
122
+ "@vitest/coverage-istanbul": "^2.1.3",
123
+ "@vitest/ui": "^2.1.3",
123
124
  "better-docs": "^2.7.3",
124
125
  "clean-webpack-plugin": "^4.0.0",
125
126
  "cloc": "2.2.0-cloc",
@@ -134,34 +135,34 @@
134
135
  "docdash": "^2.0.2",
135
136
  "dprint": "^0.47.2",
136
137
  "esbuild-loader": "^4.2.2",
137
- "eslint": "^9.9.0",
138
- "eslint-plugin-import": "^2.29.1",
139
- "eslint-plugin-jsdoc": "^50.2.2",
140
- "husky": "^9.1.5",
138
+ "eslint": "^9.12.0",
139
+ "eslint-plugin-import": "^2.31.0",
140
+ "eslint-plugin-jsdoc": "^50.4.1",
141
+ "husky": "^9.1.6",
141
142
  "jsdoc": "^4.0.3",
142
- "lint-staged": "^15.2.9",
143
+ "lint-staged": "^15.2.10",
143
144
  "mini-css-extract-plugin": "^2.9.1",
144
- "playwright": "^1.46.1",
145
+ "playwright": "^1.48.0",
145
146
  "regenerator-runtime": "^0.14.1",
146
- "rollup": "^4.21.0",
147
- "rollup-plugin-delete": "^2.0.0",
148
- "sass": "^1.77.8",
149
- "sass-loader": "^16.0.1",
150
- "semantic-release": "^24.1.0",
147
+ "rollup": "^4.24.0",
148
+ "rollup-plugin-delete": "^2.1.0",
149
+ "sass": "^1.79.5",
150
+ "sass-loader": "^16.0.2",
151
+ "semantic-release": "^24.1.2",
151
152
  "simulant": "^0.2.2",
152
- "sinon": "^18.0.0",
153
+ "sinon": "^19.0.2",
153
154
  "string-replace-loader": "^3.1.0",
154
155
  "style-loader": "^4.0.0",
155
- "tslib": "^2.6.3",
156
- "typescript": "^5.5.4",
157
- "typescript-eslint": "^8.2.0",
158
- "vitest": "^2.0.5",
159
- "webpack": "^5.93.0",
156
+ "tslib": "^2.8.0",
157
+ "typescript": "^5.6.3",
158
+ "typescript-eslint": "^8.9.0",
159
+ "vitest": "^2.1.3",
160
+ "webpack": "^5.95.0",
160
161
  "webpack-bundle-analyzer": "^4.10.2",
161
162
  "webpack-clean": "^1.2.5",
162
163
  "webpack-cli": "^5.1.4",
163
164
  "webpack-common-shake": "^2.1.0",
164
- "webpack-dev-server": "^5.0.4",
165
+ "webpack-dev-server": "^5.1.0",
165
166
  "webpack-merge": "^6.0.1",
166
167
  "webpackbar": "^6.0.1",
167
168
  "write-file-webpack-plugin": "^4.5.1"
@@ -110,6 +110,7 @@ export default class Chart {
110
110
 
111
111
  constructor(options) {
112
112
  const $$ = new ChartInternal(this);
113
+ // let hook = () => {};
113
114
 
114
115
  this.internal = $$;
115
116
 
@@ -120,6 +121,10 @@ export default class Chart {
120
121
  const isChild = target !== argThis;
121
122
  const isNotNil = notEmpty(fn[key]);
122
123
  const hasChild = isNotNil && Object.keys(fn[key]).length > 0;
124
+ // const hookFn = function(...params) {
125
+ // hook();
126
+ // return fn[key].bind(argThis)(...params);
127
+ // }
123
128
 
124
129
  if (isFunc && ((!isChild && hasChild) || isChild)) {
125
130
  target[key] = fn[key].bind(argThis);
@@ -137,6 +142,12 @@ export default class Chart {
137
142
 
138
143
  $$.beforeInit();
139
144
  $$.init();
145
+
146
+ // if ($$.config.render.lazy !== false && hasStyle($$.$el.chart, {"display": "none", "visibility": "hidden"})) {
147
+ // hook = () => {
148
+ // logError(`The call of APIs won't work. Please, make sure if chart element is %cvisible.`);
149
+ // };
150
+ // }
140
151
  }
141
152
  }
142
153
 
@@ -81,6 +81,7 @@ export default class AxisRenderer {
81
81
  tick: axisShow ? params.config[`${prefix}_tick_show`] : false,
82
82
  text: axisShow ? params.config[`${prefix}_tick_text_show`] : false
83
83
  };
84
+ const evalTextSize = params.config.axis_evalTextSize;
84
85
 
85
86
  let $g;
86
87
 
@@ -136,10 +137,13 @@ export default class AxisRenderer {
136
137
  tickShow.tick && tickEnter.append("line");
137
138
  tickShow.text && tickEnter.append("text");
138
139
 
139
- const sizeFor1Char = Helper.getSizeFor1Char(tick);
140
+ const tickText = tick.select("text");
141
+ const sizeFor1Char = isFunction(evalTextSize) ?
142
+ evalTextSize.bind(ctx.params.owner.api)(tickText.node()) :
143
+ Helper.getSizeFor1Char(tickText, evalTextSize);
140
144
  const counts: number[] = [];
141
145
 
142
- let tspan: d3Selection = tick.select("text")
146
+ let tspan: d3Selection = tickText
143
147
  .selectAll("tspan")
144
148
  .data((d, index) => {
145
149
  const split = params.tickMultiline ?
@@ -30,20 +30,21 @@ export default class AxisRendererHelper {
30
30
 
31
31
  /**
32
32
  * Compute a character dimension
33
- * @param {d3.selection} node <g class=tick> node
33
+ * @param {d3.selection} text SVG text selection
34
+ * @param {boolean} memoize memoize the calculated size
34
35
  * @returns {{w: number, h: number}}
35
36
  * @private
36
37
  */
37
- static getSizeFor1Char(node?) {
38
+ static getSizeFor1Char(text: d3Selection, memoize = true): {w: number, h: number} {
38
39
  // default size for one character
39
40
  const size = {
40
41
  w: 5.5,
41
42
  h: 11.5
42
43
  };
43
44
 
44
- !node.empty() && node.select("text")
45
+ !text.empty() && text
45
46
  .text("0")
46
- .call(el => {
47
+ .call((el: d3Selection) => {
47
48
  try {
48
49
  const {width, height} = el.node().getBBox();
49
50
 
@@ -56,7 +57,9 @@ export default class AxisRendererHelper {
56
57
  }
57
58
  });
58
59
 
59
- this.getSizeFor1Char = () => size;
60
+ if (memoize) {
61
+ this.getSizeFor1Char = () => size;
62
+ }
60
63
 
61
64
  return size;
62
65
  }
@@ -74,9 +77,11 @@ export default class AxisRendererHelper {
74
77
  value => `translate(0,${value})`;
75
78
 
76
79
  return (selection, scale) => {
77
- selection.attr("transform", d => (
78
- isValue(d) ? fn(Math.ceil(scale(d))) : null
79
- ));
80
+ selection.attr("transform", d => {
81
+ const x = scale(d);
82
+
83
+ return isValue(d) ? fn(Math.ceil(x)) : null;
84
+ });
80
85
  };
81
86
  }
82
87
 
@@ -10,7 +10,7 @@ import {
10
10
  utcFormat as d3UtcFormat,
11
11
  utcParse as d3UtcParse
12
12
  } from "d3-time-format";
13
- import type {d3Selection} from "../../types/types";
13
+ import type {d3Selection, d3Transition} from "../../types/types";
14
14
  import {$CIRCLE, $COMMON, $TEXT} from "../config/classes";
15
15
  import Options from "../config/Options/Options";
16
16
  import Store from "../config/Store/Store";
@@ -25,6 +25,7 @@ import {
25
25
  extend,
26
26
  getOption,
27
27
  getRandom,
28
+ hasStyle,
28
29
  isFunction,
29
30
  isObject,
30
31
  isString,
@@ -138,7 +139,8 @@ export default class ChartInternal {
138
139
  * @returns {d3Selection}
139
140
  * @private
140
141
  */
141
- $T(selection: SVGElement | d3Selection, force?: boolean, name?: string): d3Selection {
142
+ $T(selection: SVGElement | d3Selection | d3Transition, force?: boolean,
143
+ name?: string): d3Selection {
142
144
  const {config, state} = this;
143
145
  const duration = config.transition_duration;
144
146
  const subchart = config.subchart_show;
@@ -161,6 +163,7 @@ export default class ChartInternal {
161
163
  state.rendered &&
162
164
  !subchart;
163
165
 
166
+ // @ts-ignore
164
167
  t = (transit ? t.transition(name).duration(duration) : t) as d3Selection;
165
168
  }
166
169
 
@@ -253,10 +256,9 @@ export default class ChartInternal {
253
256
  initToRender(forced?: boolean): void {
254
257
  const $$ = <any>this;
255
258
  const {config, state, $el: {chart}} = $$;
256
- const isHidden = () =>
257
- chart.style("display") === "none" || chart.style("visibility") === "hidden";
259
+ const isHidden = () => hasStyle(chart, {display: "none", visibility: "hidden"});
258
260
 
259
- const isLazy = config.render.lazy || isHidden();
261
+ const isLazy = config.render.lazy === false ? false : config.render.lazy || isHidden();
260
262
  const MutationObserver = window.MutationObserver;
261
263
 
262
264
  if (isLazy && MutationObserver && config.render.observe !== false && !forced) {
@@ -437,7 +439,7 @@ export default class ChartInternal {
437
439
  $el.defs = $el.svg.append("defs");
438
440
 
439
441
  if (hasAxis) {
440
- ["id", "idXAxis", "idYAxis", "idGrid"].forEach(v => {
442
+ ["id", "idXAxis", "idYAxis", "idY2Axis", "idGrid"].forEach(v => {
441
443
  $$.appendClip($el.defs, state.clip[v]);
442
444
  });
443
445
  }
@@ -791,7 +793,7 @@ export default class ChartInternal {
791
793
 
792
794
  list.push(() => callFn(config.onresize, $$.api));
793
795
 
794
- if (config.resize_auto) {
796
+ if (config.resize_auto === true) {
795
797
  list.push(() => {
796
798
  state.resizing = true;
797
799
 
@@ -8,8 +8,10 @@ import {KEY} from "../../module/Cache";
8
8
  import {
9
9
  findIndex,
10
10
  getScrollPosition,
11
+ getTransformCTM,
11
12
  getUnique,
12
13
  hasValue,
14
+ hasViewBox,
13
15
  isArray,
14
16
  isBoolean,
15
17
  isDefined,
@@ -701,7 +703,11 @@ export default {
701
703
  */
702
704
  getDataIndexFromEvent(event): number {
703
705
  const $$ = this;
704
- const {$el, config, state: {hasRadar, inputType, eventReceiver: {coords, rect}}} = $$;
706
+ const {
707
+ $el,
708
+ config,
709
+ state: {hasRadar, inputType, eventReceiver: {coords, rect}}
710
+ } = $$;
705
711
  let index;
706
712
 
707
713
  if (hasRadar) {
@@ -724,11 +730,19 @@ export default {
724
730
  event.changedTouches[0] :
725
731
  event;
726
732
 
733
+ let point = isRotated ?
734
+ e.clientY + scrollPos.y - rect.top :
735
+ e.clientX + scrollPos.x - rect.left;
736
+
737
+ if (hasViewBox($el.svg)) {
738
+ const pos = [point, 0];
739
+ isRotated && pos.reverse();
740
+ point = getTransformCTM($el.svg.node(), ...pos)[isRotated ? "y" : "x"];
741
+ }
742
+
727
743
  index = findIndex(
728
744
  coords,
729
- isRotated ?
730
- e.clientY + scrollPos.y - rect.top :
731
- e.clientX + scrollPos.x - rect.left,
745
+ point,
732
746
  0,
733
747
  coords.length - 1,
734
748
  isRotated
@@ -102,6 +102,10 @@ export default {
102
102
  }
103
103
 
104
104
  $$.updateCurrentZoomTransform(zoomState.x, zoomState.currentDomain);
105
+
106
+ // https://github.com/naver/billboard.js/issues/3878
107
+ } else if (org.xScale) {
108
+ org.xScale.domain(org.xDomain);
105
109
  }
106
110
 
107
111
  // Update current state chart type and elements list after redraw
@@ -388,7 +388,7 @@ export default {
388
388
  return $$.isWithinShape(this, d);
389
389
  });
390
390
 
391
- if (shapeAtIndex.empty() && !isTooltipGrouped) {
391
+ if (shapeAtIndex.empty() && !isTooltipGrouped && config.interaction_onout) {
392
392
  $$.hideGridFocus?.();
393
393
  $$.hideTooltip();
394
394
 
@@ -591,7 +591,10 @@ export default {
591
591
  state.event = event;
592
592
 
593
593
  // chart is destroyed
594
- if (!config || $$.hasArcType() || eventReceiver.currentIdx === -1) {
594
+ if (
595
+ !config || $$.hasArcType() || eventReceiver.currentIdx === -1 ||
596
+ !config.interaction_onout
597
+ ) {
595
598
  return;
596
599
  }
597
600
 
@@ -637,7 +640,7 @@ export default {
637
640
  */
638
641
  generateEventRectsForMultipleXs(eventRectEnter): void {
639
642
  const $$ = this;
640
- const {state} = $$;
643
+ const {config, state} = $$;
641
644
 
642
645
  eventRectEnter
643
646
  .on("click", function(event) {
@@ -656,7 +659,7 @@ export default {
656
659
  state.event = event;
657
660
 
658
661
  // chart is destroyed
659
- if (!$$.config || $$.hasArcType()) {
662
+ if (!$$.config || $$.hasArcType() || !config.interaction_onout) {
660
663
  return;
661
664
  }
662
665
 
@@ -668,6 +671,7 @@ export default {
668
671
  clickHandlerForMultipleXS(ctx): void {
669
672
  const $$ = ctx;
670
673
  const {config, state} = $$;
674
+ const pointSensitivity = config.point_sensitivity;
671
675
  const targetsToShow = $$.filterTargetsToShow($$.data.targets);
672
676
 
673
677
  if ($$.hasArcType(targetsToShow)) {
@@ -676,9 +680,9 @@ export default {
676
680
 
677
681
  const mouse = getPointer(state.event, this);
678
682
  const closest = $$.findClosestFromTargets(targetsToShow, mouse);
679
- const sensitivity = config.point_sensitivity === "radius" ?
680
- closest.r :
681
- config.point_sensitivity;
683
+ const sensitivity = pointSensitivity === "radius" ? closest?.r : (
684
+ isFunction(pointSensitivity) ? closest && pointSensitivity(closest) : pointSensitivity
685
+ );
682
686
 
683
687
  if (!closest) {
684
688
  return;
@@ -6,7 +6,14 @@ import {drag as d3Drag} from "d3-drag";
6
6
  import {select as d3Select} from "d3-selection";
7
7
  import {$ARC, $AXIS, $COMMON, $SHAPE} from "../../config/classes";
8
8
  import {KEY} from "../../module/Cache";
9
- import {emulateEvent, getPointer, isNumber, isObject} from "../../module/util";
9
+ import {
10
+ emulateEvent,
11
+ getPointer,
12
+ getTransformCTM,
13
+ hasViewBox,
14
+ isNumber,
15
+ isObject
16
+ } from "../../module/util";
10
17
  import type {IArcDataRow} from "../data/IData";
11
18
 
12
19
  export default {
@@ -152,11 +159,11 @@ export default {
152
159
  d3Drag()
153
160
  .on("drag", function(event) {
154
161
  state.event = event;
155
- $$.drag(getPointer(event, this));
162
+ $$.drag(getPointer(event, <SVGElement>this));
156
163
  })
157
164
  .on("start", function(event) {
158
165
  state.event = event;
159
- $$.dragstart(getPointer(event, this));
166
+ $$.dragstart(getPointer(event, <SVGElement>this));
160
167
  })
161
168
  .on("end", event => {
162
169
  state.event = event;
@@ -183,7 +190,7 @@ export default {
183
190
  hasRadar,
184
191
  hasTreemap
185
192
  },
186
- $el: {eventRect, funnel, radar, treemap}
193
+ $el: {eventRect, funnel, radar, svg, treemap}
187
194
  } = $$;
188
195
  let element = (
189
196
  ((hasFunnel || hasTreemap) && eventReceiver.rect) ||
@@ -211,12 +218,20 @@ export default {
211
218
  }
212
219
  }
213
220
 
214
- const x = left + (mouse ? mouse[0] : 0) + (
221
+ let x = left + (mouse ? mouse[0] : 0) + (
215
222
  isMultipleX || isRotated ? 0 : (width / 2)
216
223
  );
217
224
 
218
225
  // value 4, is to adjust coordinate value set from: scale.ts - updateScales(): $$.getResettedPadding(1)
219
- const y = top + (mouse ? mouse[1] : 0) + (isRotated ? 4 : 0);
226
+ let y = top + (mouse ? mouse[1] : 0) + (isRotated ? 4 : 0);
227
+
228
+ if (hasViewBox(svg)) {
229
+ const ctm = getTransformCTM($$.$el.svg.node(), x, y, false);
230
+
231
+ x = ctm.x;
232
+ y = ctm.y;
233
+ }
234
+
220
235
  const params = {
221
236
  screenX: x,
222
237
  screenY: y,
@@ -23,7 +23,9 @@ export default {
23
23
  $$.scale.zoom = null;
24
24
 
25
25
  $$.generateZoom();
26
- $$.initZoomBehaviour();
26
+
27
+ $$.config.zoom_type === "drag" &&
28
+ $$.initZoomBehaviour();
27
29
  },
28
30
 
29
31
  /**
@@ -72,6 +74,7 @@ export default {
72
74
  const ratio = diffDomain($$.scale.x.orgDomain()) / diffDomain($$.getZoomDomain());
73
75
  const extent = this.orgScaleExtent();
74
76
 
77
+ // https://d3js.org/d3-zoom#zoom_scaleExtent
75
78
  this.scaleExtent([extent[0] * ratio, extent[1] * ratio]);
76
79
 
77
80
  return this;
@@ -96,6 +99,11 @@ export default {
96
99
  isRotated ? "rescaleY" : "rescaleX"
97
100
  ](org.xScale || scale.x);
98
101
 
102
+ // prevent drag zoom to be out of range
103
+ if (newScale.domain().some(v => /(Invalid Date|NaN)/.test(v.toString()))) {
104
+ return;
105
+ }
106
+
99
107
  const domain = $$.trimXDomain(newScale.domain());
100
108
  const rescale = config.zoom_rescale;
101
109
 
@@ -381,7 +389,7 @@ export default {
381
389
  .attr("height", isRotated ? 0 : state.height);
382
390
  }
383
391
 
384
- start = getPointer(event, this)[prop.index];
392
+ start = getPointer(event, this as SVGAElement)[prop.index];
385
393
  end = start;
386
394
 
387
395
  zoomRect
@@ -391,7 +399,7 @@ export default {
391
399
  $$.onZoomStart(event);
392
400
  })
393
401
  .on("drag", function(event) {
394
- end = getPointer(event, this)[prop.index];
402
+ end = getPointer(event, this as SVGAElement)[prop.index];
395
403
 
396
404
  zoomRect
397
405
  .attr(prop.axis, Math.min(start, end))