billboard.js 3.4.0-next.2 → 3.4.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 (40) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +47 -18
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +93 -32
  6. package/dist/billboard.pkgd.min.js +2 -2
  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 +9 -5
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +9 -5
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +9 -5
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +9 -5
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +2 -2
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +55 -19
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +55 -19
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +55 -19
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +55 -19
  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 +38 -18
  29. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  30. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
  31. package/dist-esm/plugin/billboardjs-plugin-stanford.js +7 -4
  32. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  33. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  34. package/package.json +8 -8
  35. package/src/ChartInternal/ChartInternal.ts +19 -8
  36. package/src/ChartInternal/shape/arc.ts +1 -1
  37. package/src/ChartInternal/shape/bar.ts +1 -1
  38. package/src/ChartInternal/shape/point.ts +6 -3
  39. package/src/module/generator.ts +7 -1
  40. package/src/module/util.ts +4 -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.4.0-next.2
8
+ * @version 3.4.0
9
9
  */
10
10
  import { timeParse, utcParse, timeFormat, utcFormat } from 'd3-time-format';
11
11
  import { pointer, select, namespaces, selectAll } from 'd3-selection';
@@ -739,13 +739,16 @@ function tplProcess(tpl, data) {
739
739
  * @private
740
740
  */
741
741
  function parseDate(date) {
742
+ var _a;
742
743
  var parsedDate;
743
744
  if (date instanceof Date) {
744
745
  parsedDate = date;
745
746
  }
746
747
  else if (isString(date)) {
747
- var _a = this, config = _a.config, format = _a.format;
748
- parsedDate = format.dataTime(config.data_xFormat)(date);
748
+ var _b = this, config = _b.config, format = _b.format;
749
+ // if fails to parse, try by new Date()
750
+ // https://github.com/naver/billboard.js/issues/1714
751
+ parsedDate = (_a = format.dataTime(config.data_xFormat)(date)) !== null && _a !== void 0 ? _a : new Date(date);
749
752
  }
750
753
  else if (isNumber(date) && !isNaN(date)) {
751
754
  parsedDate = new Date(+date);
@@ -762,7 +765,7 @@ function parseDate(date) {
762
765
  * @private
763
766
  */
764
767
  function isTabVisible() {
765
- return !doc.hidden;
768
+ return (doc === null || doc === void 0 ? void 0 : doc.hidden) === false || (doc === null || doc === void 0 ? void 0 : doc.visibilityState) === "visible";
766
769
  }
767
770
  /**
768
771
  * Get the current input type
@@ -3067,6 +3070,11 @@ function generateWait() {
3067
3070
  done++;
3068
3071
  continue;
3069
3072
  }
3073
+ // when tab isn't visible exit loop
3074
+ if (isTabVisible() === false) {
3075
+ done = transitionsToWait.length;
3076
+ break;
3077
+ }
3070
3078
  try {
3071
3079
  t.transition();
3072
3080
  }
@@ -8661,21 +8669,28 @@ var ChartInternal = /** @class */ (function () {
8661
8669
  }
8662
8670
  helper(type_1);
8663
8671
  }
8664
- // circle
8665
- if ($$.hasType("bubble") || $$.hasType("scatter")) {
8672
+ // Point types
8673
+ var hasPointType = $$.hasType("bubble") || $$.hasType("scatter");
8674
+ if (hasPointType) {
8666
8675
  (_a = $$.updateTargetForCircle) === null || _a === void 0 ? void 0 : _a.call($$);
8667
8676
  }
8668
8677
  // Fade-in each chart
8669
- $$.showTargets();
8678
+ $$.filterTargetsToShowAtInit(hasPointType);
8670
8679
  };
8671
8680
  /**
8672
- * Display targeted elements
8681
+ * Display targeted elements at initialization
8682
+ * @param {boolean} hasPointType whether has point type(bubble, scatter) or not
8673
8683
  * @private
8674
8684
  */
8675
- ChartInternal.prototype.showTargets = function () {
8685
+ ChartInternal.prototype.filterTargetsToShowAtInit = function (hasPointType) {
8686
+ if (hasPointType === void 0) { hasPointType = false; }
8676
8687
  var $$ = this;
8677
8688
  var svg = $$.$el.svg, $T = $$.$T;
8678
- $T(svg.selectAll(".".concat($COMMON.target))
8689
+ var selector = ".".concat($COMMON.target);
8690
+ if (hasPointType) {
8691
+ selector += ", .".concat($CIRCLE.chartCircles, " > .").concat($CIRCLE.circles);
8692
+ }
8693
+ $T(svg.selectAll(selector)
8679
8694
  .filter(function (d) { return $$.isTargetToShow(d.id); })).style("opacity", null);
8680
8695
  };
8681
8696
  ChartInternal.prototype.getWithOption = function (options) {
@@ -8706,8 +8721,9 @@ var ChartInternal = /** @class */ (function () {
8706
8721
  ChartInternal.prototype.initialOpacity = function (d) {
8707
8722
  var $$ = this;
8708
8723
  var withoutFadeIn = $$.state.withoutFadeIn;
8709
- return $$.getBaseValue(d) !== null &&
8724
+ var r = $$.getBaseValue(d) !== null &&
8710
8725
  withoutFadeIn[d.id] ? null : "0";
8726
+ return r;
8711
8727
  };
8712
8728
  ChartInternal.prototype.bindResize = function () {
8713
8729
  var $$ = this;
@@ -15691,7 +15707,7 @@ var shapeArc = {
15691
15707
  },
15692
15708
  /**
15693
15709
  * Set transform attributes to arc label text
15694
- * @param {Object} d Data object
15710
+ * @param {object} d Data object
15695
15711
  * @returns {string} Translate attribute string
15696
15712
  * @private
15697
15713
  */
@@ -16493,7 +16509,7 @@ var shapeBar = {
16493
16509
  },
16494
16510
  /**
16495
16511
  * Determine if given stacking bar data is radius type
16496
- * @param {Object} d Data row
16512
+ * @param {object} d Data row
16497
16513
  * @returns {boolean}
16498
16514
  */
16499
16515
  isStackingRadiusData: function (d) {
@@ -17251,8 +17267,7 @@ var shapePoint = {
17251
17267
  var mainCircle = $el.main.select(".".concat($CIRCLE.chartCircles))
17252
17268
  .style("pointer-events", "none")
17253
17269
  .selectAll(".".concat($CIRCLE.circles))
17254
- .data(targets)
17255
- .attr("class", classCircles);
17270
+ .data(targets);
17256
17271
  mainCircle.exit().remove();
17257
17272
  enterNode = mainCircle.enter();
17258
17273
  }
@@ -17261,7 +17276,12 @@ var shapePoint = {
17261
17276
  .attr("class", function (d) { return $$.generateClass($SELECT.selectedCircles, d.id); });
17262
17277
  enterNode.append("g")
17263
17278
  .attr("class", classCircles)
17264
- .style("cursor", function (d) { return (isFunction(isSelectable) && isSelectable(d) ? "pointer" : null); });
17279
+ .style("cursor", function (d) { return (isFunction(isSelectable) && isSelectable(d) ? "pointer" : null); })
17280
+ .style("opacity", function () {
17281
+ var _a;
17282
+ // if the parent node is .bb-chart-circles (bubble, scatter), initialize <g bb-circles> with opacity "0"
17283
+ return ((_a = this.parentNode) === null || _a === void 0 ? void 0 : _a.classList.contains("bb-chart-circles")) ? "0" : null;
17284
+ });
17265
17285
  // Update date for selected circles
17266
17286
  selectionEnabled && targets.forEach(function (t) {
17267
17287
  $el.main.selectAll(".".concat($SELECT.selectedCircles).concat($$.getTargetSelectorSuffix(t.id)))
@@ -20717,7 +20737,7 @@ var zoomModule = function () {
20717
20737
  var defaults = {};
20718
20738
  /**
20719
20739
  * @namespace bb
20720
- * @version 3.4.0-next.2
20740
+ * @version 3.4.0
20721
20741
  */
20722
20742
  var bb = {
20723
20743
  /**
@@ -20727,7 +20747,7 @@ var bb = {
20727
20747
  * bb.version; // "1.0.0"
20728
20748
  * @memberof bb
20729
20749
  */
20730
- version: "3.4.0-next.2",
20750
+ version: "3.4.0",
20731
20751
  /**
20732
20752
  * Generate chart
20733
20753
  * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.4.0-next.2
8
+ * @version 3.4.0
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -142,7 +142,7 @@ var Plugin = /*#__PURE__*/function () {
142
142
  return Plugin;
143
143
  }();
144
144
 
145
- Plugin.version = "#3.4.0-next.2#";
145
+ Plugin.version = "#3.4.0#";
146
146
 
147
147
  /**
148
148
  * Bubble compare diagram plugin.<br>
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.4.0-next.2
8
+ * @version 3.4.0
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -317,7 +317,7 @@ var Plugin = /*#__PURE__*/function () {
317
317
  return Plugin;
318
318
  }();
319
319
 
320
- Plugin.version = "#3.4.0-next.2#";
320
+ Plugin.version = "#3.4.0#";
321
321
 
322
322
  /**
323
323
  * Copyright (c) 2021 ~ present NAVER Corp.
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.4.0-next.2
8
+ * @version 3.4.0
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -375,13 +375,16 @@ var getRange = function (start, end, step) {
375
375
  * @private
376
376
  */
377
377
  function parseDate(date) {
378
+ var _a;
378
379
  var parsedDate;
379
380
  if (date instanceof Date) {
380
381
  parsedDate = date;
381
382
  }
382
383
  else if (isString(date)) {
383
- var _a = this, config = _a.config, format = _a.format;
384
- parsedDate = format.dataTime(config.data_xFormat)(date);
384
+ var _b = this, config = _b.config, format = _b.format;
385
+ // if fails to parse, try by new Date()
386
+ // https://github.com/naver/billboard.js/issues/1714
387
+ parsedDate = (_a = format.dataTime(config.data_xFormat)(date)) !== null && _a !== void 0 ? _a : new Date(date);
385
388
  }
386
389
  else if (isNumber(date) && !isNaN(date)) {
387
390
  parsedDate = new Date(+date);
@@ -517,7 +520,7 @@ var Plugin = /*#__PURE__*/function () {
517
520
  return Plugin;
518
521
  }();
519
522
 
520
- Plugin.version = "#3.4.0-next.2#";
523
+ Plugin.version = "#3.4.0#";
521
524
 
522
525
  /**
523
526
  * Copyright (c) 2017 ~ present NAVER Corp.
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.4.0-next.2
8
+ * @version 3.4.0
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -165,7 +165,7 @@ var Plugin = /*#__PURE__*/function () {
165
165
  return Plugin;
166
166
  }();
167
167
 
168
- Plugin.version = "#3.4.0-next.2#";
168
+ Plugin.version = "#3.4.0#";
169
169
 
170
170
  /**
171
171
  * Copyright (c) 2021 ~ present NAVER Corp.
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.4.0-next.2
8
+ * @version 3.4.0
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -296,7 +296,7 @@ var Plugin = /*#__PURE__*/function () {
296
296
  return Plugin;
297
297
  }();
298
298
 
299
- Plugin.version = "#3.4.0-next.2#";
299
+ Plugin.version = "#3.4.0#";
300
300
 
301
301
  /**
302
302
  * Copyright (c) 2017 ~ present NAVER Corp.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "billboard.js",
3
- "version": "3.4.0-next.2",
3
+ "version": "3.4.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",
@@ -119,10 +119,10 @@
119
119
  "@types/d3": "^7.1.0",
120
120
  "@types/mocha": "^9.0.0",
121
121
  "@types/sinon": "^10.0.11",
122
- "@typescript-eslint/eslint-plugin": "^5.16.0",
123
- "@typescript-eslint/parser": "^5.16.0",
122
+ "@typescript-eslint/eslint-plugin": "^5.17.0",
123
+ "@typescript-eslint/parser": "^5.17.0",
124
124
  "babel-helper-modules": "^6.0.0",
125
- "babel-loader": "^8.2.3",
125
+ "babel-loader": "^8.2.4",
126
126
  "babel-plugin-add-module-exports": "^1.0.4",
127
127
  "babel-plugin-minify-constant-folding": "^0.5.0",
128
128
  "babel-plugin-minify-dead-code-elimination": "^0.5.1",
@@ -141,16 +141,16 @@
141
141
  "cross-env": "^7.0.3",
142
142
  "css-loader": "^6.7.1",
143
143
  "css-minimizer-webpack-plugin": "^3.3.1",
144
- "d3-color": "^3.0.1",
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.11.0",
150
+ "eslint": "^8.12.0",
151
151
  "eslint-config-naver": "^2.1.0",
152
152
  "eslint-plugin-import": "^2.25.4",
153
- "eslint-plugin-jsdoc": "^38.0.6",
153
+ "eslint-plugin-jsdoc": "^38.1.3",
154
154
  "eslint-webpack-plugin": "^3.1.1",
155
155
  "exports-loader": "^3.1.0",
156
156
  "hammer-simulator": "0.0.1",
@@ -183,7 +183,7 @@
183
183
  "style-loader": "^3.3.1",
184
184
  "terser-webpack-plugin": "^5.3.1",
185
185
  "tslib": "^2.3.1",
186
- "typescript": "^4.6.2",
186
+ "typescript": "^4.6.3",
187
187
  "webpack": "^5.70.0",
188
188
  "webpack-bundle-analyzer": "^4.5.0",
189
189
  "webpack-clean": "^1.2.5",
@@ -12,7 +12,7 @@ import {
12
12
  import {select as d3Select} from "d3-selection";
13
13
  import {d3Selection} from "../../types/types";
14
14
  import {checkModuleImport} from "../module/error";
15
- import {$COMMON, $TEXT} from "../config/classes";
15
+ import {$COMMON, $CIRCLE, $TEXT} from "../config/classes";
16
16
  import Store from "../config/Store/Store";
17
17
  import Options from "../config/Options/Options";
18
18
  import {document, window} from "../module/browser";
@@ -338,6 +338,7 @@ export default class ChartInternal {
338
338
  $$.mapToIds($$.data.targets) : config.data_hide
339
339
  );
340
340
  }
341
+
341
342
  if (config.legend_hide) {
342
343
  $$.addHiddenLegendIds(
343
344
  config.legend_hide === true ?
@@ -641,24 +642,32 @@ export default class ChartInternal {
641
642
  helper(type);
642
643
  }
643
644
 
644
- // circle
645
- if ($$.hasType("bubble") || $$.hasType("scatter")) {
645
+ // Point types
646
+ const hasPointType = $$.hasType("bubble") || $$.hasType("scatter");
647
+
648
+ if (hasPointType) {
646
649
  $$.updateTargetForCircle?.();
647
650
  }
648
651
 
649
652
  // Fade-in each chart
650
- $$.showTargets();
653
+ $$.filterTargetsToShowAtInit(hasPointType);
651
654
  }
652
655
 
653
656
  /**
654
- * Display targeted elements
657
+ * Display targeted elements at initialization
658
+ * @param {boolean} hasPointType whether has point type(bubble, scatter) or not
655
659
  * @private
656
660
  */
657
- showTargets(): void {
661
+ filterTargetsToShowAtInit(hasPointType: boolean = false): void {
658
662
  const $$ = <any> this;
659
663
  const {$el: {svg}, $T} = $$;
664
+ let selector = `.${$COMMON.target}`;
660
665
 
661
- $T(svg.selectAll(`.${$COMMON.target}`)
666
+ if (hasPointType) {
667
+ selector += `, .${$CIRCLE.chartCircles} > .${$CIRCLE.circles}`;
668
+ }
669
+
670
+ $T(svg.selectAll(selector)
662
671
  .filter(d => $$.isTargetToShow(d.id))
663
672
  ).style("opacity", null);
664
673
  }
@@ -697,8 +706,10 @@ export default class ChartInternal {
697
706
  const $$ = <any> this;
698
707
  const {withoutFadeIn} = $$.state;
699
708
 
700
- return $$.getBaseValue(d) !== null &&
709
+ const r = $$.getBaseValue(d) !== null &&
701
710
  withoutFadeIn[d.id] ? null : "0";
711
+
712
+ return r;
702
713
  }
703
714
 
704
715
  bindResize(): void {
@@ -288,7 +288,7 @@ export default {
288
288
 
289
289
  /**
290
290
  * Set transform attributes to arc label text
291
- * @param {Object} d Data object
291
+ * @param {object} d Data object
292
292
  * @returns {string} Translate attribute string
293
293
  * @private
294
294
  */
@@ -183,7 +183,7 @@ export default {
183
183
 
184
184
  /**
185
185
  * Determine if given stacking bar data is radius type
186
- * @param {Object} d Data row
186
+ * @param {object} d Data row
187
187
  * @returns {boolean}
188
188
  */
189
189
  isStackingRadiusData(d: IDataRow): boolean {
@@ -89,8 +89,7 @@ export default {
89
89
  const mainCircle = $el.main.select(`.${$CIRCLE.chartCircles}`)
90
90
  .style("pointer-events", "none")
91
91
  .selectAll(`.${$CIRCLE.circles}`)
92
- .data(targets)
93
- .attr("class", classCircles);
92
+ .data(targets);
94
93
 
95
94
  mainCircle.exit().remove();
96
95
  enterNode = mainCircle.enter();
@@ -102,7 +101,11 @@ export default {
102
101
 
103
102
  enterNode.append("g")
104
103
  .attr("class", classCircles)
105
- .style("cursor", d => (isFunction(isSelectable) && isSelectable(d) ? "pointer" : null));
104
+ .style("cursor", d => (isFunction(isSelectable) && isSelectable(d) ? "pointer" : null))
105
+ .style("opacity", function() {
106
+ // if the parent node is .bb-chart-circles (bubble, scatter), initialize <g bb-circles> with opacity "0"
107
+ return this.parentNode?.classList.contains("bb-chart-circles") ? "0" : null;
108
+ });
106
109
 
107
110
  // Update date for selected circles
108
111
  selectionEnabled && targets.forEach(t => {
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import {d3Transition} from "../../types/types";
6
6
  import {window} from "./browser";
7
- import {isArray} from "./util";
7
+ import {isArray, isTabVisible} from "./util";
8
8
 
9
9
  const {setTimeout, clearTimeout} = window;
10
10
 
@@ -66,6 +66,12 @@ export function generateWait() {
66
66
  continue;
67
67
  }
68
68
 
69
+ // when tab isn't visible exit loop
70
+ if (isTabVisible() === false) {
71
+ done = transitionsToWait.length;
72
+ break;
73
+ }
74
+
69
75
  try {
70
76
  t.transition();
71
77
  } catch (e) {
@@ -702,7 +702,9 @@ function parseDate(date: Date | string | number | any): Date {
702
702
  } else if (isString(date)) {
703
703
  const {config, format} = this;
704
704
 
705
- parsedDate = format.dataTime(config.data_xFormat)(date);
705
+ // if fails to parse, try by new Date()
706
+ // https://github.com/naver/billboard.js/issues/1714
707
+ parsedDate = format.dataTime(config.data_xFormat)(date) ?? new Date(date);
706
708
  } else if (isNumber(date) && !isNaN(date)) {
707
709
  parsedDate = new Date(+date);
708
710
  }
@@ -721,7 +723,7 @@ function parseDate(date: Date | string | number | any): Date {
721
723
  * @private
722
724
  */
723
725
  function isTabVisible(): boolean {
724
- return !document.hidden;
726
+ return document?.hidden === false || document?.visibilityState === "visible";
725
727
  }
726
728
 
727
729
  /**