billboard.js 3.16.0 → 3.17.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.
Files changed (66) hide show
  1. package/dist/billboard.css +4 -4
  2. package/dist/billboard.js +645 -82
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +12 -12
  5. package/dist/billboard.pkgd.js +1987 -786
  6. package/dist/billboard.pkgd.min.js +18 -17
  7. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  9. package/dist/plugin/billboardjs-plugin-sparkline.js +18 -2
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -4
  11. package/dist/plugin/billboardjs-plugin-stanford.js +18 -2
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +4 -4
  13. package/dist/plugin/billboardjs-plugin-tableview.js +16 -2
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +5 -5
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +16 -2
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +3 -3
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +1344 -706
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +6 -5
  19. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +1454 -800
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +8 -7
  21. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +1455 -801
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +13 -12
  23. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +1454 -802
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +10 -9
  25. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +1455 -803
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -6
  27. package/dist/theme/dark.css +4 -4
  28. package/dist/theme/dark.min.css +1 -1
  29. package/dist/theme/datalab.css +4 -4
  30. package/dist/theme/datalab.min.css +1 -1
  31. package/dist/theme/graph.css +4 -4
  32. package/dist/theme/graph.min.css +1 -1
  33. package/dist/theme/insight.css +4 -4
  34. package/dist/theme/insight.min.css +1 -1
  35. package/dist/theme/modern.css +4 -4
  36. package/dist/theme/modern.min.css +1 -1
  37. package/dist-esm/billboard.js +697 -79
  38. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  39. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +4 -2
  40. package/dist-esm/plugin/billboardjs-plugin-stanford.js +4 -2
  41. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  42. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  43. package/package.json +21 -21
  44. package/src/ChartInternal/Axis/AxisRenderer.ts +20 -13
  45. package/src/ChartInternal/Axis/AxisRendererHelper.ts +9 -4
  46. package/src/ChartInternal/data/convert.ts +3 -3
  47. package/src/ChartInternal/data/data.ts +2 -2
  48. package/src/ChartInternal/internals/color.ts +20 -14
  49. package/src/ChartInternal/internals/text.ts +40 -125
  50. package/src/ChartInternal/internals/text.util.ts +320 -0
  51. package/src/ChartInternal/shape/arc.ts +41 -19
  52. package/src/ChartInternal/shape/treemap.ts +5 -6
  53. package/src/config/Options/axis/x.ts +18 -0
  54. package/src/config/Options/axis/y.ts +17 -0
  55. package/src/config/Options/axis/y2.ts +18 -0
  56. package/src/config/Options/common/boost.ts +1 -0
  57. package/src/config/Options/data/data.ts +125 -4
  58. package/src/config/Options/shape/donut.ts +77 -1
  59. package/src/config/Options/shape/gauge.ts +69 -2
  60. package/src/config/Options/shape/pie.ts +68 -1
  61. package/src/config/Options/shape/polar.ts +68 -1
  62. package/src/config/classes.ts +2 -0
  63. package/src/module/util.ts +26 -0
  64. package/types/axis.d.ts +10 -0
  65. package/types/options.d.ts +138 -1
  66. package/types/options.shape.d.ts +302 -2
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.16.0
8
+ * @version 3.17.0
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -100,7 +100,7 @@ var Plugin = /** @class */ (function () {
100
100
  delete _this[key];
101
101
  });
102
102
  };
103
- Plugin.version = "3.16.0";
103
+ Plugin.version = "3.17.0";
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.16.0
8
+ * @version 3.17.0
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -205,6 +205,8 @@ var $TEXT = {
205
205
  text: "bb-text",
206
206
  texts: "bb-texts",
207
207
  title: "bb-title",
208
+ textBorderRect: "bb-text-border",
209
+ textLabelImage: "bb-text-label-image",
208
210
  TextOverlapping: "text-overlapping"
209
211
  };
210
212
  var $TOOLTIP = {
@@ -374,7 +376,7 @@ var Plugin = /** @class */ (function () {
374
376
  delete _this[key];
375
377
  });
376
378
  };
377
- Plugin.version = "3.16.0";
379
+ Plugin.version = "3.17.0";
378
380
  return Plugin;
379
381
  }());
380
382
 
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.16.0
8
+ * @version 3.17.0
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -211,6 +211,8 @@ var $TEXT = {
211
211
  text: "bb-text",
212
212
  texts: "bb-texts",
213
213
  title: "bb-title",
214
+ textBorderRect: "bb-text-border",
215
+ textLabelImage: "bb-text-label-image",
214
216
  TextOverlapping: "text-overlapping"
215
217
  };
216
218
  var $TOOLTIP = {
@@ -432,7 +434,7 @@ var Plugin = /** @class */ (function () {
432
434
  delete _this[key];
433
435
  });
434
436
  };
435
- Plugin.version = "3.16.0";
437
+ Plugin.version = "3.17.0";
436
438
  return Plugin;
437
439
  }());
438
440
 
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.16.0
8
+ * @version 3.17.0
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -217,7 +217,7 @@ var Plugin = /** @class */ (function () {
217
217
  delete _this[key];
218
218
  });
219
219
  };
220
- Plugin.version = "3.16.0";
220
+ Plugin.version = "3.17.0";
221
221
  return Plugin;
222
222
  }());
223
223
 
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.16.0
8
+ * @version 3.17.0
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -204,7 +204,7 @@ var Plugin = /** @class */ (function () {
204
204
  delete _this[key];
205
205
  });
206
206
  };
207
- Plugin.version = "3.16.0";
207
+ Plugin.version = "3.17.0";
208
208
  return Plugin;
209
209
  }());
210
210
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "billboard.js",
3
- "version": "3.16.0",
3
+ "version": "3.17.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",
@@ -104,17 +104,17 @@
104
104
  "devDependencies": {
105
105
  "@commitlint/cli": "^19.8.1",
106
106
  "@commitlint/config-conventional": "^19.8.1",
107
- "@eslint/js": "^9.29.0",
107
+ "@eslint/js": "^9.35.0",
108
108
  "@rollup/plugin-node-resolve": "^16.0.1",
109
109
  "@rollup/plugin-replace": "^6.0.2",
110
- "@rollup/plugin-typescript": "^12.1.3",
110
+ "@rollup/plugin-typescript": "^12.1.4",
111
111
  "@semantic-release/changelog": "^6.0.3",
112
112
  "@semantic-release/commit-analyzer": "^13.0.1",
113
113
  "@semantic-release/exec": "^7.1.0",
114
114
  "@semantic-release/git": "^10.0.1",
115
- "@semantic-release/npm": "^12.0.1",
116
- "@semantic-release/release-notes-generator": "^14.0.3",
117
- "@testing-library/dom": "^10.4.0",
115
+ "@semantic-release/npm": "^12.0.2",
116
+ "@semantic-release/release-notes-generator": "^14.1.0",
117
+ "@testing-library/dom": "^10.4.1",
118
118
  "@testing-library/react": "^16.3.0",
119
119
  "@types/d3": "^7.4.3",
120
120
  "@types/sinon": "^17.0.4",
@@ -123,41 +123,41 @@
123
123
  "@vitest/ui": "^3.2.4",
124
124
  "better-docs": "^2.7.3",
125
125
  "clean-webpack-plugin": "^4.0.0",
126
- "cloc": "2.4.0-cloc",
127
- "core-js": "^3.43.0",
126
+ "cloc": "2.6.0-cloc",
127
+ "core-js": "^3.45.1",
128
128
  "coveralls": "^3.1.1",
129
- "cross-env": "^7.0.3",
129
+ "cross-env": "^10.0.0",
130
130
  "css-loader": "^7.1.2",
131
131
  "d3-color": "^3.1.0",
132
132
  "d3-delaunay": "^6.0.4",
133
133
  "d3-format": "^3.1.0",
134
134
  "d3-polygon": "^3.0.1",
135
135
  "docdash": "^2.0.2",
136
- "dprint": "^0.50.0",
136
+ "dprint": "^0.50.1",
137
137
  "esbuild-loader": "^4.3.0",
138
- "eslint": "^9.29.0",
138
+ "eslint": "^9.35.0",
139
139
  "eslint-plugin-import": "^2.32.0",
140
- "eslint-plugin-jsdoc": "^51.2.3",
140
+ "eslint-plugin-jsdoc": "^54.5.0",
141
141
  "husky": "^9.1.7",
142
142
  "jsdoc": "^4.0.4",
143
- "lint-staged": "^16.1.2",
144
- "mini-css-extract-plugin": "^2.9.2",
145
- "playwright": "^1.53.1",
143
+ "lint-staged": "^16.1.6",
144
+ "mini-css-extract-plugin": "^2.9.4",
145
+ "playwright": "^1.55.0",
146
146
  "regenerator-runtime": "^0.14.1",
147
- "rollup": "^4.44.0",
147
+ "rollup": "^4.50.1",
148
148
  "rollup-plugin-delete": "^3.0.1",
149
- "sass": "^1.89.2",
149
+ "sass": "^1.92.1",
150
150
  "sass-loader": "^16.0.5",
151
- "semantic-release": "^24.2.5",
151
+ "semantic-release": "^24.2.7",
152
152
  "simulant": "^0.2.2",
153
153
  "sinon": "^21.0.0",
154
154
  "string-replace-loader": "^3.2.0",
155
155
  "style-loader": "^4.0.0",
156
156
  "tslib": "^2.8.1",
157
- "typescript": "^5.8.3",
158
- "typescript-eslint": "^8.35.0",
157
+ "typescript": "^5.9.2",
158
+ "typescript-eslint": "^8.42.0",
159
159
  "vitest": "^3.2.4",
160
- "webpack": "^5.99.9",
160
+ "webpack": "^5.101.3",
161
161
  "webpack-bundle-analyzer": "^4.10.2",
162
162
  "webpack-clean": "^1.2.5",
163
163
  "webpack-cli": "^6.0.1",
@@ -141,7 +141,7 @@ export default class AxisRenderer {
141
141
 
142
142
  const tickText = tick.select("text");
143
143
  const counts: number[] = [];
144
- let sizeFor1Char: {w: number, h: number} | undefined;
144
+ let sizeFor1Char = {w: 0, h: 0};
145
145
 
146
146
  if (isFunction(evalTextSize)) {
147
147
  // set evalTextSize to dummy axis element to be used in .getMaxTickSize()
@@ -152,8 +152,8 @@ export default class AxisRenderer {
152
152
  }
153
153
  }
154
154
 
155
- if (!sizeFor1Char) {
156
- sizeFor1Char = Helper.getSizeFor1Char(tickText, !!evalTextSize);
155
+ if (!sizeFor1Char || sizeFor1Char.w === 0 || sizeFor1Char.h === 0) {
156
+ sizeFor1Char = ctx.helper.getSizeFor1Char(orient, tickText, !!evalTextSize);
157
157
  }
158
158
 
159
159
  let tspan: d3Selection = tickText
@@ -216,7 +216,7 @@ export default class AxisRenderer {
216
216
  tickEnter.select("line").attr(`${axisPx}2`, innerTickSize * sign);
217
217
  tickEnter.select("text").attr(axisPx, tickLength * sign);
218
218
 
219
- ctx.setTickLineTextPosition(lineUpdate, textUpdate);
219
+ ctx.setTickLineTextPosition(lineUpdate, textUpdate, sizeFor1Char);
220
220
 
221
221
  // Append <title> for tooltip display
222
222
  if (params.tickTitle) {
@@ -312,12 +312,16 @@ export default class AxisRenderer {
312
312
  * Set tick's line & text position
313
313
  * @param {d3.selection} lineUpdate Line selection
314
314
  * @param {d3.selection} textUpdate Text selection
315
+ * @param {object} sizeFor1Char Size for 1 char
315
316
  * @private
316
317
  */
317
- setTickLineTextPosition(lineUpdate, textUpdate): void {
318
+ setTickLineTextPosition(lineUpdate, textUpdate, sizeFor1Char): void {
318
319
  const tickPos = this.getTickXY();
319
320
  const {innerTickSize, orient, tickLength, tickOffset} = this.config;
321
+ const axisId = this.params.id;
320
322
  const rotate = this.params.tickTextRotate;
323
+ const baseHeight = 6;
324
+ const charHeight = (sizeFor1Char.h / 2) - baseHeight;
321
325
 
322
326
  const textAnchorForText = r => {
323
327
  const value = ["start", "end"];
@@ -329,8 +333,9 @@ export default class AxisRenderer {
329
333
  const textTransform = r => (r ? `rotate(${r})` : null);
330
334
  const yForText = r => {
331
335
  const r2 = r / (orient === "bottom" ? 15 : 23);
336
+ const y = r ? 11.5 - 2.5 * r2 * (r > 0 ? 1 : -1) : tickLength;
332
337
 
333
- return r ? 11.5 - 2.5 * r2 * (r > 0 ? 1 : -1) : tickLength;
338
+ return y;
334
339
  };
335
340
 
336
341
  const {
@@ -340,12 +345,14 @@ export default class AxisRenderer {
340
345
  }
341
346
  } = this.params.owner;
342
347
 
348
+ const tickLineInner = this.params.config[`axis_${axisId}_tick_inner`];
349
+
343
350
  switch (orient) {
344
351
  case "bottom":
345
352
  lineUpdate
346
353
  .attr("x1", tickPos.x)
347
354
  .attr("x2", tickPos.x)
348
- .attr("y2", this.getTickSize.bind(this));
355
+ .attr("y2", d => this.getTickSize.bind(this)(d) * (tickLineInner ? -1 : 1));
349
356
 
350
357
  textUpdate
351
358
  .attr("x", 0)
@@ -367,33 +374,33 @@ export default class AxisRenderer {
367
374
  case "top":
368
375
  lineUpdate
369
376
  .attr("x2", 0)
370
- .attr("y2", -innerTickSize);
377
+ .attr("y2", tickLineInner ? innerTickSize : -innerTickSize);
371
378
 
372
379
  textUpdate
373
380
  .attr("x", 0)
374
- .attr("y", -yForText(rotate) * 2)
381
+ .attr("y", -(yForText(rotate) + charHeight + baseHeight))
375
382
  .style("text-anchor", textAnchorForText(rotate))
376
383
  .attr("transform", textTransform(rotate));
377
384
  break;
378
385
  case "left":
379
386
  lineUpdate
380
- .attr("x2", -innerTickSize)
387
+ .attr("x2", tickLineInner ? innerTickSize : -innerTickSize)
381
388
  .attr("y1", tickPos.y)
382
389
  .attr("y2", tickPos.y);
383
390
 
384
391
  textUpdate
385
392
  .attr("x", -tickLength)
386
- .attr("y", tickOffset)
393
+ .attr("y", tickOffset + (isRotated ? charHeight / 4 : charHeight))
387
394
  .style("text-anchor", "end");
388
395
  break;
389
396
  case "right":
390
397
  lineUpdate
391
- .attr("x2", innerTickSize)
398
+ .attr("x2", tickLineInner ? -innerTickSize : innerTickSize)
392
399
  .attr("y2", 0);
393
400
 
394
401
  textUpdate
395
402
  .attr("x", tickLength)
396
- .attr("y", 0)
403
+ .attr("y", charHeight)
397
404
  .style("text-anchor", "start");
398
405
  }
399
406
  }
@@ -11,6 +11,7 @@ export default class AxisRendererHelper {
11
11
  private owner;
12
12
  private config;
13
13
  private scale;
14
+ private charSize = {};
14
15
 
15
16
  constructor(owner) {
16
17
  const scale = getScale();
@@ -30,18 +31,24 @@ export default class AxisRendererHelper {
30
31
 
31
32
  /**
32
33
  * Compute a character dimension
34
+ * @param {string} orient Axis orientation
33
35
  * @param {d3.selection} text SVG text selection
34
36
  * @param {boolean} memoize memoize the calculated size
35
37
  * @returns {{w: number, h: number}}
36
38
  * @private
37
39
  */
38
- static getSizeFor1Char(text: d3Selection, memoize = true): {w: number, h: number} {
40
+ getSizeFor1Char(orient: "top" | "bottom" | "left" | "right", text: d3Selection,
41
+ memoize = true): {w: number, h: number} {
39
42
  // default size for one character
40
43
  const size = {
41
44
  w: 5.5,
42
45
  h: 11.5
43
46
  };
44
47
 
48
+ if (this.charSize[orient] && memoize) {
49
+ return this.charSize[orient];
50
+ }
51
+
45
52
  !text.empty() && text
46
53
  .text("0")
47
54
  .call((el: d3Selection) => {
@@ -57,9 +64,7 @@ export default class AxisRendererHelper {
57
64
  }
58
65
  });
59
66
 
60
- if (memoize) {
61
- this.getSizeFor1Char = () => size;
62
- }
67
+ this.charSize[orient] = size;
63
68
 
64
69
  return size;
65
70
  }
@@ -112,14 +112,14 @@ export default {
112
112
  url(data.url, data.mimeType, data.headers, getDataKeyForJson(data.keys, config),
113
113
  callback);
114
114
  } else if (data.json) {
115
- runWorker(useWorker, json, callback, [columns, rows])(
115
+ runWorker(data.json.length ? useWorker : false, json, callback, [columns, rows])(
116
116
  data.json,
117
117
  getDataKeyForJson(data.keys, config)
118
118
  );
119
119
  } else if (data.rows) {
120
- runWorker(useWorker, rows, callback)(data.rows);
120
+ runWorker(data.rows.length ? useWorker : false, rows, callback)(data.rows);
121
121
  } else if (data.columns) {
122
- runWorker(useWorker, columns, callback)(data.columns);
122
+ runWorker(data.columns.length ? useWorker : false, columns, callback)(data.columns);
123
123
  } else if (args.bindto) {
124
124
  throw Error("url or json or rows or columns is required.");
125
125
  }
@@ -440,7 +440,7 @@ export default {
440
440
  return targets.map(d => d.id);
441
441
  },
442
442
 
443
- mapToTargetIds(ids) {
443
+ mapToTargetIds(ids?: string[] | string): string[] {
444
444
  const $$ = this;
445
445
 
446
446
  return ids ? (isArray(ids) ? ids.concat() : [ids]) : $$.mapToIds($$.data.targets);
@@ -989,7 +989,7 @@ export default {
989
989
  * @returns {number} Ratio value
990
990
  * @private
991
991
  */
992
- getRatio(type: string, d, asPercent = false): number {
992
+ getRatio(type: "arc" | "index" | "radar" | "bar" | "treemap", d, asPercent = false): number {
993
993
  const $$ = this;
994
994
  const {config, state} = $$;
995
995
  const api = $$.api;
@@ -178,18 +178,18 @@ export default {
178
178
 
179
179
  /**
180
180
  * Append data backgound color filter definition
181
- * @param {string|object} color Color string
181
+ * @param {string|object|Function} color Color string, object, or function
182
182
  * @param {object} attr filter attribute
183
183
  * @private
184
184
  */
185
- generateTextBGColorFilter(color: string | object, attr = {
185
+ generateTextBGColorFilter(color: string | {[key: string]: string} | Function, attr = {
186
186
  x: 0,
187
187
  y: 0,
188
188
  width: 1,
189
189
  height: 1
190
190
  }): void {
191
191
  const $$ = this;
192
- const {$el, state} = $$;
192
+ const {$el: {defs}, state} = $$;
193
193
 
194
194
  if (color) {
195
195
  let ids: string[] = [];
@@ -198,25 +198,31 @@ export default {
198
198
  ids.push("");
199
199
  } else if (isObject(color)) {
200
200
  ids = Object.keys(color);
201
+ } else if (isFunction(color)) {
202
+ ids = $$.mapToTargetIds();
201
203
  }
202
204
 
203
205
  ids.forEach(v => {
204
206
  const id = `${state.datetimeId}-labels-bg${$$.getTargetSelectorSuffix(v)}${
205
207
  isString(color) ? $$.getTargetSelectorSuffix(color) : ""
206
208
  }`;
207
-
208
- $el.defs.append("filter")
209
- .attr("x", attr.x)
210
- .attr("y", attr.y)
211
- .attr("width", attr.width)
212
- .attr("height", attr.height)
213
- .attr("id", id)
214
- .html(
215
- `<feFlood flood-color="${v === "" ? color : color[v]}" />
216
- <feComposite in="SourceGraphic" />`
217
- );
209
+ const colorValue = v === "" ? color : color?.[v] || "";
210
+
211
+ if (defs.select(`#${id}`).empty()) {
212
+ defs.append("filter")
213
+ .attr("x", attr.x)
214
+ .attr("y", attr.y)
215
+ .attr("width", attr.width)
216
+ .attr("height", attr.height)
217
+ .attr("id", id)
218
+ .html(
219
+ `<feFlood flood-color="${colorValue}" />
220
+ <feComposite in="SourceGraphic" />`
221
+ );
222
+ }
218
223
  });
219
224
  }
225
+ // Note: For function type, filters will be created dynamically in updateTextBGColor
220
226
  },
221
227
 
222
228
  /**