billboard.js 3.4.1 → 3.5.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.
Files changed (53) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +3283 -1110
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +7416 -4949
  6. package/dist/billboard.pkgd.min.js +3 -2
  7. package/dist/plugin/billboardjs-plugin-bubblecompare.js +29 -13
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  9. package/dist/plugin/billboardjs-plugin-sparkline.js +259 -89
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +329 -106
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +223 -71
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +219 -72
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +3940 -3793
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +4219 -3882
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +4392 -3930
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +4187 -3868
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +4195 -3872
  22. package/dist/theme/datalab.css +1 -1
  23. package/dist/theme/datalab.min.css +1 -1
  24. package/dist/theme/graph.css +1 -1
  25. package/dist/theme/graph.min.css +1 -1
  26. package/dist/theme/insight.css +1 -1
  27. package/dist/theme/insight.min.css +1 -1
  28. package/dist-esm/billboard.js +206 -41
  29. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +47 -75
  30. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +66 -85
  31. package/dist-esm/plugin/billboardjs-plugin-stanford.js +50 -76
  32. package/dist-esm/plugin/billboardjs-plugin-tableview.js +47 -75
  33. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +47 -75
  34. package/package.json +34 -34
  35. package/src/Chart/api/data.ts +2 -2
  36. package/src/ChartInternal/Axis/AxisRenderer.ts +29 -3
  37. package/src/ChartInternal/ChartInternal.ts +8 -1
  38. package/src/ChartInternal/interactions/zoom.ts +17 -4
  39. package/src/ChartInternal/internals/color.ts +3 -2
  40. package/src/ChartInternal/internals/grid.ts +5 -3
  41. package/src/ChartInternal/internals/redraw.ts +5 -2
  42. package/src/ChartInternal/internals/scale.ts +3 -1
  43. package/src/ChartInternal/internals/size.axis.ts +5 -2
  44. package/src/ChartInternal/internals/text.ts +115 -15
  45. package/src/ChartInternal/shape/bar.ts +12 -5
  46. package/src/Plugin/sparkline/index.ts +22 -11
  47. package/src/Plugin/stanford/index.ts +10 -7
  48. package/src/config/Options/common/main.ts +15 -1
  49. package/src/config/Options/common/tooltip.ts +1 -1
  50. package/src/config/Options/data/data.ts +11 -3
  51. package/src/module/generator.ts +12 -5
  52. package/types/chart.d.ts +2 -2
  53. package/types/options.d.ts +21 -8
@@ -5,11 +5,11 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.4.1
8
+ * @version 3.5.0-next.1
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
12
- /*! *****************************************************************************
12
+ /******************************************************************************
13
13
  Copyright (c) Microsoft Corporation.
14
14
 
15
15
  Permission to use, copy, modify, and/or distribute this software for any
@@ -80,12 +80,10 @@ function __spreadArray(to, from, pack) {
80
80
  * Copyright (c) 2017 ~ present NAVER Corp.
81
81
  * billboard.js project is licensed under the MIT license
82
82
  */
83
-
84
83
  /**
85
84
  * Base class to generate billboard.js plugin
86
85
  * @class Plugin
87
86
  */
88
-
89
87
  /**
90
88
  * Version info string for plugin
91
89
  * @name version
@@ -95,77 +93,51 @@ function __spreadArray(to, from, pack) {
95
93
  * @example
96
94
  * bb.plugin.stanford.version; // ex) 1.9.0
97
95
  */
98
- var Plugin = /*#__PURE__*/function () {
99
- /**
100
- * Version info string for plugin
101
- * @name version
102
- * @static
103
- * @memberof Plugin
104
- * @type {String}
105
- * @example
106
- * bb.plugin.stanford.version; // ex) 1.9.0
107
- */
108
-
109
- /**
110
- * Constructor
111
- * @param {Any} options config option object
112
- * @private
113
- */
114
- function Plugin(options) {
115
- if (options === void 0) {
116
- options = {};
96
+ var Plugin = /** @class */ (function () {
97
+ /**
98
+ * Constructor
99
+ * @param {Any} options config option object
100
+ * @private
101
+ */
102
+ function Plugin(options) {
103
+ if (options === void 0) { options = {}; }
104
+ this.options = options;
117
105
  }
118
- this.options = options;
119
- }
120
- /**
121
- * Lifecycle hook for 'beforeInit' phase.
122
- * @private
123
- */
124
-
125
-
126
- var _proto = Plugin.prototype;
127
-
128
- _proto.$beforeInit = function $beforeInit() {}
129
- /**
130
- * Lifecycle hook for 'init' phase.
131
- * @private
132
- */
133
- ;
134
-
135
- _proto.$init = function $init() {}
136
- /**
137
- * Lifecycle hook for 'afterInit' phase.
138
- * @private
139
- */
140
- ;
141
-
142
- _proto.$afterInit = function $afterInit() {}
143
- /**
144
- * Lifecycle hook for 'redraw' phase.
145
- * @private
146
- */
147
- ;
148
-
149
- _proto.$redraw = function $redraw() {}
150
- /**
151
- * Lifecycle hook for 'willDestroy' phase.
152
- * @private
153
- */
154
- ;
155
-
156
- _proto.$willDestroy = function $willDestroy() {
157
- var _this = this;
158
-
159
- Object.keys(this).forEach(function (key) {
160
- _this[key] = null;
161
- delete _this[key];
162
- });
163
- };
164
-
165
- return Plugin;
166
- }();
167
-
168
- Plugin.version = "#3.4.1#";
106
+ /**
107
+ * Lifecycle hook for 'beforeInit' phase.
108
+ * @private
109
+ */
110
+ Plugin.prototype.$beforeInit = function () { };
111
+ /**
112
+ * Lifecycle hook for 'init' phase.
113
+ * @private
114
+ */
115
+ Plugin.prototype.$init = function () { };
116
+ /**
117
+ * Lifecycle hook for 'afterInit' phase.
118
+ * @private
119
+ */
120
+ Plugin.prototype.$afterInit = function () { };
121
+ /**
122
+ * Lifecycle hook for 'redraw' phase.
123
+ * @private
124
+ */
125
+ Plugin.prototype.$redraw = function () { };
126
+ /**
127
+ * Lifecycle hook for 'willDestroy' phase.
128
+ * @private
129
+ */
130
+ Plugin.prototype.$willDestroy = function () {
131
+ var _this = this;
132
+ Object.keys(this).forEach(function (key) {
133
+ _this[key] = null;
134
+ delete _this[key];
135
+ });
136
+ };
137
+ Plugin.version = "3.5.0-next.1";
138
+ return Plugin;
139
+ }());
140
+ var Plugin$1 = Plugin;
169
141
 
170
142
  /**
171
143
  * Copyright (c) 2021 ~ present NAVER Corp.
@@ -573,6 +545,6 @@ var TableView = /** @class */ (function (_super) {
573
545
  }
574
546
  };
575
547
  return TableView;
576
- }(Plugin));
548
+ }(Plugin$1));
577
549
 
578
550
  export { TableView as default };
@@ -5,14 +5,14 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.4.1
8
+ * @version 3.5.0-next.1
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
12
12
  import { Delaunay } from 'd3-delaunay';
13
13
  import { polygonCentroid, polygonArea } from 'd3-polygon';
14
14
 
15
- /*! *****************************************************************************
15
+ /******************************************************************************
16
16
  Copyright (c) Microsoft Corporation.
17
17
 
18
18
  Permission to use, copy, modify, and/or distribute this software for any
@@ -211,12 +211,10 @@ function loadConfig(config) {
211
211
  * Copyright (c) 2017 ~ present NAVER Corp.
212
212
  * billboard.js project is licensed under the MIT license
213
213
  */
214
-
215
214
  /**
216
215
  * Base class to generate billboard.js plugin
217
216
  * @class Plugin
218
217
  */
219
-
220
218
  /**
221
219
  * Version info string for plugin
222
220
  * @name version
@@ -226,77 +224,51 @@ function loadConfig(config) {
226
224
  * @example
227
225
  * bb.plugin.stanford.version; // ex) 1.9.0
228
226
  */
229
- var Plugin = /*#__PURE__*/function () {
230
- /**
231
- * Version info string for plugin
232
- * @name version
233
- * @static
234
- * @memberof Plugin
235
- * @type {String}
236
- * @example
237
- * bb.plugin.stanford.version; // ex) 1.9.0
238
- */
239
-
240
- /**
241
- * Constructor
242
- * @param {Any} options config option object
243
- * @private
244
- */
245
- function Plugin(options) {
246
- if (options === void 0) {
247
- options = {};
227
+ var Plugin = /** @class */ (function () {
228
+ /**
229
+ * Constructor
230
+ * @param {Any} options config option object
231
+ * @private
232
+ */
233
+ function Plugin(options) {
234
+ if (options === void 0) { options = {}; }
235
+ this.options = options;
248
236
  }
249
- this.options = options;
250
- }
251
- /**
252
- * Lifecycle hook for 'beforeInit' phase.
253
- * @private
254
- */
255
-
256
-
257
- var _proto = Plugin.prototype;
258
-
259
- _proto.$beforeInit = function $beforeInit() {}
260
- /**
261
- * Lifecycle hook for 'init' phase.
262
- * @private
263
- */
264
- ;
265
-
266
- _proto.$init = function $init() {}
267
- /**
268
- * Lifecycle hook for 'afterInit' phase.
269
- * @private
270
- */
271
- ;
272
-
273
- _proto.$afterInit = function $afterInit() {}
274
- /**
275
- * Lifecycle hook for 'redraw' phase.
276
- * @private
277
- */
278
- ;
279
-
280
- _proto.$redraw = function $redraw() {}
281
- /**
282
- * Lifecycle hook for 'willDestroy' phase.
283
- * @private
284
- */
285
- ;
286
-
287
- _proto.$willDestroy = function $willDestroy() {
288
- var _this = this;
289
-
290
- Object.keys(this).forEach(function (key) {
291
- _this[key] = null;
292
- delete _this[key];
293
- });
294
- };
295
-
296
- return Plugin;
297
- }();
298
-
299
- Plugin.version = "#3.4.1#";
237
+ /**
238
+ * Lifecycle hook for 'beforeInit' phase.
239
+ * @private
240
+ */
241
+ Plugin.prototype.$beforeInit = function () { };
242
+ /**
243
+ * Lifecycle hook for 'init' phase.
244
+ * @private
245
+ */
246
+ Plugin.prototype.$init = function () { };
247
+ /**
248
+ * Lifecycle hook for 'afterInit' phase.
249
+ * @private
250
+ */
251
+ Plugin.prototype.$afterInit = function () { };
252
+ /**
253
+ * Lifecycle hook for 'redraw' phase.
254
+ * @private
255
+ */
256
+ Plugin.prototype.$redraw = function () { };
257
+ /**
258
+ * Lifecycle hook for 'willDestroy' phase.
259
+ * @private
260
+ */
261
+ Plugin.prototype.$willDestroy = function () {
262
+ var _this = this;
263
+ Object.keys(this).forEach(function (key) {
264
+ _this[key] = null;
265
+ delete _this[key];
266
+ });
267
+ };
268
+ Plugin.version = "3.5.0-next.1";
269
+ return Plugin;
270
+ }());
271
+ var Plugin$1 = Plugin;
300
272
 
301
273
  /**
302
274
  * Copyright (c) 2017 ~ present NAVER Corp.
@@ -457,6 +429,6 @@ var TextOverlap = /** @class */ (function (_super) {
457
429
  });
458
430
  };
459
431
  return TextOverlap;
460
- }(Plugin));
432
+ }(Plugin$1));
461
433
 
462
434
  export { TextOverlap as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "billboard.js",
3
- "version": "3.4.1",
3
+ "version": "3.5.0-next.1",
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",
@@ -95,18 +95,18 @@
95
95
  "d3-zoom": "^3.0.0"
96
96
  },
97
97
  "devDependencies": {
98
- "@babel/core": "^7.17.9",
98
+ "@babel/core": "^7.18.0",
99
99
  "@babel/eslint-parser": "^7.17.0",
100
- "@babel/plugin-proposal-class-properties": "^7.16.7",
101
- "@babel/plugin-proposal-object-rest-spread": "^7.17.3",
102
- "@babel/plugin-transform-runtime": "^7.17.0",
103
- "@babel/preset-env": "^7.16.8",
104
- "@babel/preset-typescript": "^7.16.7",
105
- "@babel/runtime": "^7.17.9",
100
+ "@babel/plugin-proposal-class-properties": "^7.17.12",
101
+ "@babel/plugin-proposal-object-rest-spread": "^7.18.0",
102
+ "@babel/plugin-transform-runtime": "^7.18.0",
103
+ "@babel/preset-env": "^7.18.0",
104
+ "@babel/preset-typescript": "^7.17.12",
105
+ "@babel/runtime": "^7.18.0",
106
106
  "@commitlint/cli": "^15.0.0",
107
- "@commitlint/config-conventional": "^16.2.1",
107
+ "@commitlint/config-conventional": "^17.0.2",
108
108
  "@rollup/plugin-babel": "^5.3.1",
109
- "@rollup/plugin-node-resolve": "^13.2.0",
109
+ "@rollup/plugin-node-resolve": "^13.2.1",
110
110
  "@rollup/plugin-replace": "^4.0.0",
111
111
  "@rollup/plugin-typescript": "^8.3.2",
112
112
  "@semantic-release/changelog": "^6.0.1",
@@ -116,49 +116,49 @@
116
116
  "@semantic-release/npm": "^9.0.1",
117
117
  "@semantic-release/release-notes-generator": "^10.0.3",
118
118
  "@types/chai": "^4.3.1",
119
- "@types/d3": "^7.1.0",
120
- "@types/mocha": "^9.0.0",
119
+ "@types/d3": "^7.4.0",
120
+ "@types/mocha": "^9.1.1",
121
121
  "@types/sinon": "^10.0.11",
122
- "@typescript-eslint/eslint-plugin": "^5.19.0",
123
- "@typescript-eslint/parser": "^5.19.0",
122
+ "@typescript-eslint/eslint-plugin": "^5.27.1",
123
+ "@typescript-eslint/parser": "^5.27.1",
124
124
  "babel-helper-modules": "^6.0.0",
125
- "babel-loader": "^8.2.4",
125
+ "babel-loader": "^8.2.5",
126
126
  "babel-plugin-add-module-exports": "^1.0.4",
127
127
  "babel-plugin-minify-constant-folding": "^0.5.0",
128
- "babel-plugin-minify-dead-code-elimination": "^0.5.1",
128
+ "babel-plugin-minify-dead-code-elimination": "^0.5.2",
129
129
  "babel-plugin-minify-guarded-expressions": "^0.4.4",
130
130
  "babel-plugin-minify-numeric-literals": "^0.4.3",
131
131
  "babel-plugin-minify-type-constructors": "^0.4.3",
132
132
  "babel-plugin-transform-inline-consecutive-adds": "^0.4.3",
133
- "babel-plugin-transform-merge-sibling-variables": "^6.9.4",
133
+ "babel-plugin-transform-merge-sibling-variables": "^6.9.5",
134
134
  "babel-plugin-transform-minify-booleans": "^6.9.4",
135
135
  "better-docs": "^2.7.2",
136
136
  "chai": "^4.3.4",
137
137
  "clean-webpack-plugin": "^4.0.0",
138
138
  "cloc": "^2.9.0",
139
- "core-js": "^3.21.1",
139
+ "core-js": "^3.22.8",
140
140
  "coveralls": "^3.1.1",
141
141
  "cross-env": "^7.0.3",
142
142
  "css-loader": "^6.7.1",
143
- "css-minimizer-webpack-plugin": "^3.3.1",
143
+ "css-minimizer-webpack-plugin": "^4.0.0",
144
144
  "d3-color": "^3.1.0",
145
145
  "d3-delaunay": "^6.0.2",
146
146
  "d3-format": "^3.1.0",
147
147
  "d3-polygon": "^3.0.1",
148
148
  "docdash": "^1.2.0",
149
149
  "dtslint": "^4.2.1",
150
- "eslint": "^8.13.0",
150
+ "eslint": "^8.17.0",
151
151
  "eslint-config-naver": "^2.1.0",
152
152
  "eslint-plugin-import": "^2.26.0",
153
- "eslint-plugin-jsdoc": "^39.2.1",
153
+ "eslint-plugin-jsdoc": "^39.3.0",
154
154
  "eslint-webpack-plugin": "^3.1.1",
155
- "exports-loader": "^3.1.0",
155
+ "exports-loader": "^4.0.0",
156
156
  "hammer-simulator": "0.0.1",
157
- "husky": "^7.0.4",
157
+ "husky": "^8.0.1",
158
158
  "istanbul-instrumenter-loader": "^3.0.1",
159
- "istanbul-lib-instrument": "^5.1.0",
159
+ "istanbul-lib-instrument": "^5.2.0",
160
160
  "jsdoc": "^3.6.10",
161
- "karma": "^6.3.18",
161
+ "karma": "^6.3.20",
162
162
  "karma-chai": "^0.1.0",
163
163
  "karma-chrome-launcher": "^3.1.1",
164
164
  "karma-coverage-istanbul-reporter": "^3.0.3",
@@ -170,26 +170,26 @@
170
170
  "karma-webpack": "^5.0.0",
171
171
  "lite-fixture": "^1.0.2",
172
172
  "mini-css-extract-plugin": "^2.6.0",
173
- "mocha": "^9.2.2",
173
+ "mocha": "^10.0.0",
174
174
  "node-sass": "^7.0.1",
175
175
  "regenerator-runtime": "^0.13.7",
176
- "rollup": "^2.70.1",
176
+ "rollup": "^2.75.5",
177
177
  "rollup-plugin-delete": "^2.0.0",
178
- "sass-loader": "^12.6.0",
178
+ "sass-loader": "^13.0.0",
179
179
  "semantic-release": "^19.0.2",
180
180
  "simulant": "^0.2.2",
181
- "sinon": "^13.0.1",
181
+ "sinon": "^14.0.0",
182
182
  "string-replace-loader": "^3.1.0",
183
183
  "style-loader": "^3.3.1",
184
- "terser-webpack-plugin": "^5.3.1",
185
- "tslib": "^2.3.1",
186
- "typescript": "^4.6.3",
187
- "webpack": "^5.72.0",
184
+ "terser-webpack-plugin": "^5.3.3",
185
+ "tslib": "^2.4.0",
186
+ "typescript": "4.6.2",
187
+ "webpack": "^5.73.0",
188
188
  "webpack-bundle-analyzer": "^4.5.0",
189
189
  "webpack-clean": "^1.2.5",
190
190
  "webpack-cli": "^4.9.1",
191
191
  "webpack-common-shake": "^2.1.0",
192
- "webpack-dev-server": "^4.8.1",
192
+ "webpack-dev-server": "^4.9.2",
193
193
  "webpack-merge": "^5.8.0",
194
194
  "webpackbar": "^5.0.2",
195
195
  "write-file-webpack-plugin": "^4.5.1"
@@ -97,7 +97,7 @@ extend(data, {
97
97
  * @function data․names
98
98
  * @instance
99
99
  * @memberof Chart
100
- * @param {object} names If this argument is given, the names of data will be updated. If not given, the current names will be returned. The format of this argument is the same as
100
+ * @param {object} names If this argument is given, the names of data will be updated. If not given, the current names will be returned. The format of this argument is the same as [data.names](./Options.html#.data%25E2%2580%25A4names).
101
101
  * @returns {object} Corresponding names according its key value, if specified names values.
102
102
  * @example
103
103
  * // Get current names
@@ -110,7 +110,7 @@ extend(data, {
110
110
  * data2: "New Name 2"
111
111
  *});
112
112
  */
113
- names: function(names?: Array<{ [key: string]: string; }>): {[key: string]: string} {
113
+ names: function(names?: Array<{ [key: string]: string|null; }>): {[key: string]: string|null} {
114
114
  const $$ = this.internal;
115
115
 
116
116
  return $$.updateDataAttributes("names", names);
@@ -13,6 +13,7 @@ export default class AxisRenderer {
13
13
  private config;
14
14
  private params;
15
15
  private g;
16
+ private generatedTicks: (Date|number)[];
16
17
 
17
18
  constructor(params: any = {}) {
18
19
  const config = {
@@ -46,10 +47,10 @@ export default class AxisRenderer {
46
47
  */
47
48
  create(g: d3Selection): void {
48
49
  const ctx = this;
49
- const {config, helper, params} = this;
50
+ const {config, helper, params} = ctx;
50
51
  const {scale} = helper;
51
52
  const {orient} = config;
52
- const splitTickText = this.splitTickText.bind(this);
53
+ const splitTickText = this.splitTickText.bind(ctx);
53
54
  const isLeftRight = /^(left|right)$/.test(orient);
54
55
  const isTopBottom = /^(top|bottom)$/.test(orient);
55
56
 
@@ -113,6 +114,9 @@ export default class AxisRenderer {
113
114
  // count of tick data in array
114
115
  const ticks = config.tickValues || helper.generateTicks(scale1, isLeftRight);
115
116
 
117
+ // set generated ticks
118
+ ctx.generatedTicks = ticks;
119
+
116
120
  // update selection
117
121
  let tick: d3Selection = g.selectAll(".tick")
118
122
  .data(ticks, scale1);
@@ -228,6 +232,28 @@ export default class AxisRenderer {
228
232
  this.g = $g;
229
233
  }
230
234
 
235
+ /**
236
+ * Get generated ticks
237
+ * @param {number} count Count of ticks
238
+ * @returns {Array} Generated ticks
239
+ * @private
240
+ */
241
+ getGeneratedTicks(count: number): (Date|number)[] {
242
+ const len = this.generatedTicks.length - 1;
243
+ let res = this.generatedTicks;
244
+
245
+ if (len > count) {
246
+ const interval = Math.round((len / count) - 0.1);
247
+
248
+ res = this.generatedTicks
249
+ .map((v, i) => (i % interval === 0 ? v : null))
250
+ .filter(v => v !== null)
251
+ .splice(0, count) as (Date|number)[];
252
+ }
253
+
254
+ return res;
255
+ }
256
+
231
257
  /**
232
258
  * Get tick x/y coordinate
233
259
  * @returns {{x: number, y: number}}
@@ -505,7 +531,7 @@ export default class AxisRenderer {
505
531
  return this;
506
532
  }
507
533
 
508
- tickValues(x?): AxisRenderer | (number|Date|string)[] {
534
+ tickValues(x?: (number|Date|string)[]|Function): AxisRenderer | (number|Date|string)[] {
509
535
  const {config} = this;
510
536
 
511
537
  if (isFunction(x)) {
@@ -715,7 +715,7 @@ export default class ChartInternal {
715
715
  bindResize(): void {
716
716
  const $$ = <any> this;
717
717
  const {config, state} = $$;
718
- const resizeFunction = generateResize();
718
+ const resizeFunction = generateResize(config.resize_timer);
719
719
  const list: Function[] = [];
720
720
 
721
721
  list.push(() => callFn(config.onresize, $$, $$.api));
@@ -723,6 +723,13 @@ export default class ChartInternal {
723
723
  if (config.resize_auto) {
724
724
  list.push(() => {
725
725
  state.resizing = true;
726
+
727
+ // https://github.com/naver/billboard.js/issues/2650
728
+ if (config.legend_show) {
729
+ $$.updateSizes();
730
+ $$.updateLegend();
731
+ }
732
+
726
733
  $$.api.flush(false);
727
734
  });
728
735
  }
@@ -3,7 +3,7 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
5
  import {drag as d3Drag} from "d3-drag";
6
- import {zoomIdentity as d3ZoomIdentity, zoom as d3Zoom} from "d3-zoom";
6
+ import {zoomIdentity as d3ZoomIdentity, zoom as d3Zoom, ZoomTransform as d3ZoomTransform} from "d3-zoom";
7
7
  import {$COMMON, $ZOOM} from "../../config/classes";
8
8
  import {callFn, diffDomain, getPointer, isFunction} from "../../module/util";
9
9
 
@@ -75,16 +75,19 @@ export default {
75
75
  /**
76
76
  * Update scale according zoom transform value
77
77
  * @param {object} transform transform object
78
+ * @param {boolean} correctTransform if the d3 transform should be updated after rescaling
78
79
  * @private
79
80
  */
80
81
  // @ts-ignore
81
- zoom.updateTransformScale = (transform: object): void => {
82
+ zoom.updateTransformScale = (transform: d3ZoomTransform, correctTransform: boolean): void => {
83
+ const isRotated = config.axis_rotated;
84
+
82
85
  // in case of resize, update range of orgXScale
83
86
  org.xScale?.range(scale.x.range());
84
87
 
85
88
  // rescale from the original scale
86
89
  const newScale = transform[
87
- config.axis_rotated ? "rescaleY" : "rescaleX"
90
+ isRotated ? "rescaleY" : "rescaleX"
88
91
  ](org.xScale || scale.x);
89
92
 
90
93
  const domain = $$.trimXDomain(newScale.domain());
@@ -92,6 +95,16 @@ export default {
92
95
 
93
96
  newScale.domain(domain, org.xDomain);
94
97
 
98
+ // prevent chart from panning off the edge and feeling "stuck"
99
+ // https://github.com/naver/billboard.js/issues/2588
100
+ if (correctTransform) {
101
+ const t = newScale(scale.x.domain()[0]);
102
+ const tX = isRotated ? transform.x : t;
103
+ const tY = isRotated ? t : transform.y;
104
+
105
+ $$.$el.eventRect.property("__zoom", d3ZoomIdentity.translate(tX, tY).scale(transform.k));
106
+ }
107
+
95
108
  if (!$$.state.xTickOffset) {
96
109
  $$.state.xTickOffset = $$.axis.x.tickOffset();
97
110
  }
@@ -172,7 +185,7 @@ export default {
172
185
  scale.x.domain(org.xDomain);
173
186
  }
174
187
 
175
- $$.zoom.updateTransformScale(transform);
188
+ $$.zoom.updateTransformScale(transform, config.zoom_type === "wheel" && sourceEvent);
176
189
 
177
190
  // do zoom transiton when:
178
191
  // - zoom type 'drag'
@@ -8,6 +8,7 @@ import {document, window} from "../../module/browser";
8
8
  import {$ARC, $COLOR, $SHAPE} from "../../config/classes";
9
9
  import {KEY} from "../../module/Cache";
10
10
  import {notEmpty, isFunction, isObject, isString} from "../../module/util";
11
+ import {IArcData, IDataRow} from "../data/IData";
11
12
 
12
13
  /**
13
14
  * Set pattern's background color
@@ -103,8 +104,8 @@ export default {
103
104
  $$.patterns = colorizedPatterns;
104
105
  }
105
106
 
106
- return function(d) {
107
- const id: string = d.id || d.data?.id || d;
107
+ return function(d: IDataRow | IArcData | string): string {
108
+ const id: string = (d as IDataRow).id || (d as IArcData).data?.id || d as string;
108
109
  const isLine = $$.isTypeOf(id, ["line", "spline", "step"]) || !config.data_types[id];
109
110
  let color;
110
111
 
@@ -133,10 +133,12 @@ export default {
133
133
 
134
134
  updateYGrid(): void {
135
135
  const $$ = this;
136
- const {config, state, $el: {grid, main}} = $$;
136
+ const {axis, config, scale, state, $el: {grid, main}} = $$;
137
137
  const isRotated = config.axis_rotated;
138
- const gridValues = $$.axis.y.tickValues() || $$.scale.y.ticks(config.grid_y_ticks);
139
- const pos = d => Math.ceil($$.scale.y(d));
138
+ const pos = d => Math.ceil(scale.y(d));
139
+
140
+ const gridValues =
141
+ axis.y.getGeneratedTicks(config.grid_y_ticks) || $$.scale.y.ticks(config.grid_y_ticks);
140
142
 
141
143
  grid.y = main.select(`.${$GRID.ygrids}`)
142
144
  .selectAll(`.${$GRID.ygrid}`)