billboard.js 3.7.4 → 3.8.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 (73) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +420 -256
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +2115 -1544
  6. package/dist/billboard.pkgd.min.js +3 -3
  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 +22 -19
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +22 -19
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +22 -19
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +22 -19
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +1696 -1289
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +1717 -1307
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +1718 -1308
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +1719 -1309
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +1752 -1325
  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 +359 -211
  29. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  30. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +4 -9
  31. package/dist-esm/plugin/billboardjs-plugin-stanford.js +6 -11
  32. package/dist-esm/plugin/billboardjs-plugin-tableview.js +7 -12
  33. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -7
  34. package/package.json +33 -33
  35. package/src/Chart/api/focus.ts +4 -4
  36. package/src/Chart/api/grid.ts +206 -0
  37. package/src/Chart/api/load.ts +31 -21
  38. package/src/Chart/api/regions.ts +28 -24
  39. package/src/Chart/api/zoom.ts +18 -3
  40. package/src/ChartInternal/Axis/Axis.ts +1 -0
  41. package/src/ChartInternal/Axis/AxisRenderer.ts +7 -2
  42. package/src/ChartInternal/ChartInternal.ts +1 -1
  43. package/src/ChartInternal/data/IData.ts +1 -1
  44. package/src/ChartInternal/data/convert.ts +6 -3
  45. package/src/ChartInternal/data/data.ts +22 -19
  46. package/src/ChartInternal/data/load.ts +19 -4
  47. package/src/ChartInternal/interactions/eventrect.ts +5 -0
  48. package/src/ChartInternal/interactions/subchart.ts +3 -2
  49. package/src/ChartInternal/interactions/zoom.ts +10 -3
  50. package/src/ChartInternal/internals/clip.ts +3 -2
  51. package/src/ChartInternal/internals/domain.ts +17 -8
  52. package/src/ChartInternal/internals/legend.ts +4 -1
  53. package/src/ChartInternal/internals/redraw.ts +0 -16
  54. package/src/ChartInternal/internals/scale.ts +7 -4
  55. package/src/ChartInternal/internals/size.axis.ts +14 -4
  56. package/src/ChartInternal/internals/size.ts +41 -18
  57. package/src/ChartInternal/internals/transform.ts +1 -1
  58. package/src/ChartInternal/internals/type.ts +10 -0
  59. package/src/ChartInternal/shape/bar.ts +2 -3
  60. package/src/config/Options/axis/x.ts +17 -0
  61. package/src/config/Options/axis/y.ts +2 -1
  62. package/src/config/Options/axis/y2.ts +2 -1
  63. package/src/config/Options/common/main.ts +19 -1
  64. package/src/config/Options/data/axis.ts +10 -1
  65. package/src/config/resolver/axis.ts +2 -4
  66. package/src/module/browser.ts +13 -5
  67. package/src/module/generator.ts +3 -3
  68. package/src/module/util.ts +7 -4
  69. package/types/axis.d.ts +8 -7
  70. package/types/chart.d.ts +6 -1
  71. package/types/options.d.ts +6 -0
  72. package/src/Chart/api/grid.x.ts +0 -90
  73. package/src/Chart/api/grid.y.ts +0 -92
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.7.4
8
+ * @version 3.8.0-next.1
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -104,7 +104,7 @@ var Plugin = /** @class */ (function () {
104
104
  delete _this[key];
105
105
  });
106
106
  };
107
- Plugin.version = "3.7.4";
107
+ Plugin.version = "3.8.0-next.1";
108
108
  return Plugin;
109
109
  }());
110
110
  var Plugin$1 = Plugin;
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.7.4
8
+ * @version 3.8.0-next.1
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -154,7 +154,7 @@ var $EVENT = {
154
154
  eventRect: "bb-event-rect",
155
155
  eventRects: "bb-event-rects",
156
156
  eventRectsMultiple: "bb-event-rects-multiple",
157
- eventRectsSingle: "bb-event-rects-single"
157
+ eventRectsSingle: "bb-event-rects-single",
158
158
  };
159
159
  var $FOCUS = {
160
160
  focused: "bb-focused",
@@ -190,7 +190,7 @@ var $SELECT = {
190
190
  };
191
191
  var $SHAPE = {
192
192
  shape: "bb-shape",
193
- shapes: "bb-shapes"
193
+ shapes: "bb-shapes",
194
194
  };
195
195
  var $SUBCHART = {
196
196
  brush: "bb-brush",
@@ -278,7 +278,7 @@ var Plugin = /** @class */ (function () {
278
278
  delete _this[key];
279
279
  });
280
280
  };
281
- Plugin.version = "3.7.4";
281
+ Plugin.version = "3.8.0-next.1";
282
282
  return Plugin;
283
283
  }());
284
284
  var Plugin$1 = Plugin;
@@ -325,11 +325,6 @@ var win = (function () {
325
325
  (typeof self === "object" && self !== null && self.Object === Object && self);
326
326
  return root || Function("return this")();
327
327
  })();
328
- /* eslint-enable no-new-func, no-undef */
329
- // fallback for non-supported environments
330
- win.requestIdleCallback = win.requestIdleCallback || (function (cb) { return setTimeout(cb, 1); });
331
- // win.cancelIdleCallback = win.cancelIdleCallback || (id => clearTimeout(id));
332
- win.requestAnimationFrame = win.requestAnimationFrame || (function (cb) { return setTimeout(cb, 1); });
333
328
  var doc = win === null || win === void 0 ? void 0 : win.document;
334
329
 
335
330
  var isDefined = function (v) { return typeof v !== "undefined"; };
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.7.4
8
+ * @version 3.8.0-next.1
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -160,7 +160,7 @@ var $EVENT = {
160
160
  eventRect: "bb-event-rect",
161
161
  eventRects: "bb-event-rects",
162
162
  eventRectsMultiple: "bb-event-rects-multiple",
163
- eventRectsSingle: "bb-event-rects-single"
163
+ eventRectsSingle: "bb-event-rects-single",
164
164
  };
165
165
  var $FOCUS = {
166
166
  focused: "bb-focused",
@@ -196,7 +196,7 @@ var $SELECT = {
196
196
  };
197
197
  var $SHAPE = {
198
198
  shape: "bb-shape",
199
- shapes: "bb-shapes"
199
+ shapes: "bb-shapes",
200
200
  };
201
201
  var $SUBCHART = {
202
202
  brush: "bb-brush",
@@ -236,11 +236,6 @@ var win = (function () {
236
236
  (typeof self === "object" && self !== null && self.Object === Object && self);
237
237
  return root || Function("return this")();
238
238
  })();
239
- /* eslint-enable no-new-func, no-undef */
240
- // fallback for non-supported environments
241
- win.requestIdleCallback = win.requestIdleCallback || (function (cb) { return setTimeout(cb, 1); });
242
- // win.cancelIdleCallback = win.cancelIdleCallback || (id => clearTimeout(id));
243
- win.requestAnimationFrame = win.requestAnimationFrame || (function (cb) { return setTimeout(cb, 1); });
244
239
  var doc = win === null || win === void 0 ? void 0 : win.document;
245
240
 
246
241
  var isFunction = function (v) { return typeof v === "function"; };
@@ -486,7 +481,7 @@ var Plugin = /** @class */ (function () {
486
481
  delete _this[key];
487
482
  });
488
483
  };
489
- Plugin.version = "3.7.4";
484
+ Plugin.version = "3.8.0-next.1";
490
485
  return Plugin;
491
486
  }());
492
487
  var Plugin$1 = Plugin;
@@ -787,7 +782,7 @@ var Elements = /** @class */ (function () {
787
782
  .style("opacity", "0");
788
783
  stanfordLineEnter
789
784
  .merge(stanfordLine)
790
- .attr("class", function (d) { return CLASS.stanfordLine + (d["class"] ? " ".concat(d["class"]) : ""); })
785
+ .attr("class", function (d) { return CLASS.stanfordLine + (d.class ? " ".concat(d.class) : ""); })
791
786
  .select("line")
792
787
  .transition()
793
788
  .duration(duration)
@@ -824,7 +819,7 @@ var Elements = /** @class */ (function () {
824
819
  stanfordRegion = stanfordRegionEnter.merge(stanfordRegion);
825
820
  // update
826
821
  stanfordRegion
827
- .attr("class", function (d) { return CLASS.stanfordRegion + (d["class"] ? " ".concat(d["class"]) : ""); })
822
+ .attr("class", function (d) { return CLASS.stanfordRegion + (d.class ? " ".concat(d.class) : ""); })
828
823
  .select("polygon")
829
824
  .transition()
830
825
  .duration(duration)
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.7.4
8
+ * @version 3.8.0-next.1
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -121,7 +121,7 @@ var Plugin = /** @class */ (function () {
121
121
  delete _this[key];
122
122
  });
123
123
  };
124
- Plugin.version = "3.7.4";
124
+ Plugin.version = "3.8.0-next.1";
125
125
  return Plugin;
126
126
  }());
127
127
  var Plugin$1 = Plugin;
@@ -191,7 +191,7 @@ var Options = /** @class */ (function () {
191
191
  * @example
192
192
  * class: "table-class-name"
193
193
  */
194
- "class": undefined,
194
+ class: undefined,
195
195
  /**
196
196
  * Set to apply default style(`.bb-tableview`) to tableview element.
197
197
  * @name style
@@ -235,7 +235,7 @@ var Options$1 = Options;
235
235
  */
236
236
  var defaultStyle = {
237
237
  id: "__tableview-style__",
238
- "class": "bb-tableview",
238
+ class: "bb-tableview",
239
239
  rule: ".bb-tableview {\n\t\tborder-collapse:collapse;\n\t\tborder-spacing:0;\n\t\tbackground:#fff;\n\t\tmin-width:100%;\n\t\tmargin-top:10px;\n\t\tfont-family:sans-serif;\n\t\tfont-size:.9em;\n\t}\n\t.bb-tableview tr:hover {\n\t\tbackground:#eef7ff;\n\t}\n\t.bb-tableview thead tr {\n\t\tbackground:#f8f8f8;\n\t}\n\t.bb-tableview caption,.bb-tableview td,.bb-tableview th {\n\t\ttext-align: center;\n\t\tborder:1px solid silver;\n\t\tpadding:.5em;\n\t}\n\t.bb-tableview caption {\n\t\tfont-size:1.1em;\n\t\tfont-weight:700;\n\t\tmargin-bottom: -1px;\n\t}"
240
240
  };
241
241
  // template
@@ -256,11 +256,6 @@ var win = (function () {
256
256
  (typeof self === "object" && self !== null && self.Object === Object && self);
257
257
  return root || Function("return this")();
258
258
  })();
259
- /* eslint-enable no-new-func, no-undef */
260
- // fallback for non-supported environments
261
- win.requestIdleCallback = win.requestIdleCallback || (function (cb) { return setTimeout(cb, 1); });
262
- // win.cancelIdleCallback = win.cancelIdleCallback || (id => clearTimeout(id));
263
- win.requestAnimationFrame = win.requestAnimationFrame || (function (cb) { return setTimeout(cb, 1); });
264
259
  var doc = win === null || win === void 0 ? void 0 : win.document;
265
260
 
266
261
  var isNumber = function (v) { return typeof v === "number"; };
@@ -465,8 +460,8 @@ var TableView = /** @class */ (function (_super) {
465
460
  };
466
461
  TableView.prototype.$init = function () {
467
462
  var _a;
468
- var _b = this.config, className = _b["class"], selector = _b.selector, style = _b.style;
469
- var element = document.querySelector(selector || ".".concat(className || defaultStyle["class"]));
463
+ var _b = this.config, className = _b.class, selector = _b.selector, style = _b.style;
464
+ var element = document.querySelector(selector || ".".concat(className || defaultStyle.class));
470
465
  if (!element) {
471
466
  var chart = this.$$.$el.chart.node();
472
467
  element = document.createElement("table");
@@ -485,7 +480,7 @@ var TableView = /** @class */ (function (_super) {
485
480
  (document.head || document.getElementsByTagName("head")[0])
486
481
  .appendChild(s);
487
482
  }
488
- (_a = element.classList).add.apply(_a, [style && defaultStyle["class"], className].filter(Boolean));
483
+ (_a = element.classList).add.apply(_a, [style && defaultStyle.class, className].filter(Boolean));
489
484
  this.element = element;
490
485
  };
491
486
  /**
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.7.4
8
+ * @version 3.8.0-next.1
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
@@ -66,11 +66,6 @@ var win = (function () {
66
66
  (typeof self === "object" && self !== null && self.Object === Object && self);
67
67
  return root || Function("return this")();
68
68
  })();
69
- /* eslint-enable no-new-func, no-undef */
70
- // fallback for non-supported environments
71
- win.requestIdleCallback = win.requestIdleCallback || (function (cb) { return setTimeout(cb, 1); });
72
- // win.cancelIdleCallback = win.cancelIdleCallback || (id => clearTimeout(id));
73
- win.requestAnimationFrame = win.requestAnimationFrame || (function (cb) { return setTimeout(cb, 1); });
74
69
  var doc = win === null || win === void 0 ? void 0 : win.document;
75
70
 
76
71
  var isDefined = function (v) { return typeof v !== "undefined"; };
@@ -263,7 +258,7 @@ var Plugin = /** @class */ (function () {
263
258
  delete _this[key];
264
259
  });
265
260
  };
266
- Plugin.version = "3.7.4";
261
+ Plugin.version = "3.8.0-next.1";
267
262
  return Plugin;
268
263
  }());
269
264
  var Plugin$1 = Plugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "billboard.js",
3
- "version": "3.7.4",
3
+ "version": "3.8.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",
@@ -84,7 +84,7 @@
84
84
  "license": "MIT",
85
85
  "readmeFilename": "README.md",
86
86
  "dependencies": {
87
- "@types/d3-selection": "^3.0.4",
87
+ "@types/d3-selection": "^3.0.5",
88
88
  "@types/d3-transition": "^3.0.3",
89
89
  "d3-axis": "^3.0.0",
90
90
  "d3-brush": "^3.0.0",
@@ -101,32 +101,32 @@
101
101
  "d3-zoom": "^3.0.0"
102
102
  },
103
103
  "devDependencies": {
104
- "@babel/core": "^7.20.12",
105
- "@babel/eslint-parser": "^7.19.1",
104
+ "@babel/core": "^7.21.3",
105
+ "@babel/eslint-parser": "^7.21.3",
106
106
  "@babel/plugin-proposal-class-properties": "^7.18.6",
107
107
  "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
108
- "@babel/plugin-transform-runtime": "^7.19.1",
108
+ "@babel/plugin-transform-runtime": "^7.21.0",
109
109
  "@babel/preset-env": "^7.20.2",
110
- "@babel/preset-typescript": "^7.18.6",
111
- "@babel/runtime": "^7.20.13",
112
- "@commitlint/cli": "17.4.2",
113
- "@commitlint/config-conventional": "^17.4.2",
110
+ "@babel/preset-typescript": "^7.21.0",
111
+ "@babel/runtime": "^7.21.0",
112
+ "@commitlint/cli": "17.5.0",
113
+ "@commitlint/config-conventional": "^17.4.4",
114
114
  "@rollup/plugin-babel": "^6.0.3",
115
115
  "@rollup/plugin-node-resolve": "^15.0.0",
116
116
  "@rollup/plugin-replace": "^5.0.2",
117
117
  "@rollup/plugin-typescript": "^11.0.0",
118
- "@semantic-release/changelog": "^6.0.2",
118
+ "@semantic-release/changelog": "^6.0.3",
119
119
  "@semantic-release/commit-analyzer": "^9.0.2",
120
120
  "@semantic-release/exec": "^6.0.3",
121
121
  "@semantic-release/git": "^10.0.1",
122
- "@semantic-release/npm": "^9.0.2",
122
+ "@semantic-release/npm": "^10.0.2",
123
123
  "@semantic-release/release-notes-generator": "^10.0.3",
124
124
  "@types/chai": "^4.3.4",
125
125
  "@types/d3": "^7.4.0",
126
126
  "@types/mocha": "^10.0.1",
127
127
  "@types/sinon": "^10.0.13",
128
- "@typescript-eslint/eslint-plugin": "^5.49.0",
129
- "@typescript-eslint/parser": "^5.49.0",
128
+ "@typescript-eslint/eslint-plugin": "^5.57.0",
129
+ "@typescript-eslint/parser": "^5.57.0",
130
130
  "babel-helper-modules": "^6.0.0",
131
131
  "babel-loader": "^9.1.2",
132
132
  "babel-plugin-add-module-exports": "^1.0.4",
@@ -142,28 +142,28 @@
142
142
  "chai": "^4.3.7",
143
143
  "clean-webpack-plugin": "^4.0.0",
144
144
  "cloc": "^2.11.0",
145
- "core-js": "^3.27.2",
145
+ "core-js": "^3.29.1",
146
146
  "coveralls": "^3.1.1",
147
147
  "cross-env": "^7.0.3",
148
148
  "css-loader": "^6.7.3",
149
- "css-minimizer-webpack-plugin": "^4.2.2",
149
+ "css-minimizer-webpack-plugin": "^5.0.0",
150
150
  "d3-color": "^3.1.0",
151
- "d3-delaunay": "^6.0.2",
151
+ "d3-delaunay": "^6.0.3",
152
152
  "d3-format": "^3.1.0",
153
153
  "d3-polygon": "^3.0.1",
154
154
  "docdash": "^2.0.1",
155
155
  "dtslint": "^4.2.1",
156
- "eslint": "^8.33.0",
156
+ "eslint": "^8.36.0",
157
157
  "eslint-config-naver": "^2.1.0",
158
158
  "eslint-plugin-import": "^2.27.5",
159
- "eslint-plugin-jsdoc": "^39.7.4",
160
- "eslint-webpack-plugin": "^3.2.0",
159
+ "eslint-plugin-jsdoc": "^40.1.0",
160
+ "eslint-webpack-plugin": "^4.0.0",
161
161
  "exports-loader": "^4.0.0",
162
162
  "hammer-simulator": "0.0.1",
163
163
  "husky": "^8.0.3",
164
164
  "istanbul-instrumenter-loader": "^3.0.1",
165
165
  "istanbul-lib-instrument": "^5.2.1",
166
- "jsdoc": "^4.0.0",
166
+ "jsdoc": "^4.0.2",
167
167
  "karma": "^6.4.1",
168
168
  "karma-chai": "^0.1.0",
169
169
  "karma-chrome-launcher": "^3.1.1",
@@ -172,32 +172,32 @@
172
172
  "karma-mocha-reporter": "^2.2.3",
173
173
  "karma-scss-preprocessor": "^4.0.0",
174
174
  "karma-sinon": "^1.0.5",
175
- "karma-sourcemap-loader": "^0.3.8",
175
+ "karma-sourcemap-loader": "^0.4.0",
176
176
  "karma-webpack": "^5.0.0",
177
- "lint-staged": "^13.1.0",
177
+ "lint-staged": "^13.2.0",
178
178
  "lite-fixture": "^1.0.2",
179
- "mini-css-extract-plugin": "^2.7.2",
179
+ "mini-css-extract-plugin": "^2.7.5",
180
180
  "mocha": "^10.2.0",
181
181
  "node-sass": "^8.0.0",
182
182
  "regenerator-runtime": "^0.13.11",
183
- "rollup": "^3.12.0",
183
+ "rollup": "^3.20.2",
184
184
  "rollup-plugin-delete": "^2.0.0",
185
- "sass-loader": "^13.2.0",
186
- "semantic-release": "^20.1.0",
185
+ "sass-loader": "^13.2.2",
186
+ "semantic-release": "^21.0.0",
187
187
  "simulant": "^0.2.2",
188
- "sinon": "^15.0.1",
188
+ "sinon": "^15.0.3",
189
189
  "string-replace-loader": "^3.1.0",
190
- "style-loader": "^3.3.1",
190
+ "style-loader": "^3.3.2",
191
191
  "taffydb": "^2.7.3",
192
- "terser-webpack-plugin": "^5.3.6",
192
+ "terser-webpack-plugin": "^5.3.7",
193
193
  "tslib": "^2.5.0",
194
- "typescript": "4.9.5",
195
- "webpack": "^5.75.0",
196
- "webpack-bundle-analyzer": "^4.7.0",
194
+ "typescript": "5.0.2",
195
+ "webpack": "^5.76.3",
196
+ "webpack-bundle-analyzer": "^4.8.0",
197
197
  "webpack-clean": "^1.2.5",
198
198
  "webpack-cli": "^5.0.1",
199
199
  "webpack-common-shake": "^2.1.0",
200
- "webpack-dev-server": "^4.11.1",
200
+ "webpack-dev-server": "^4.13.1",
201
201
  "webpack-merge": "^5.8.0",
202
202
  "webpackbar": "^5.0.2",
203
203
  "write-file-webpack-plugin": "^4.5.1"
@@ -92,17 +92,17 @@ export default {
92
92
  },
93
93
 
94
94
  /**
95
- * This API reverts specified targets.<br><br>
96
- * You can specify multiple targets by giving an array that includes id as String. If no argument is given, all of targets will be reverted.
95
+ * Revert focused or defocused state to initial state.<br><br>
96
+ * You can specify multiple targets by giving an array that includes id as string. If no argument is given, all of targets will be reverted.
97
97
  * @function revert
98
98
  * @instance
99
99
  * @memberof Chart
100
100
  * @param {string|Array} targetIdsValue Target ids to be reverted
101
101
  * @example
102
- * // data1 will be reverted.
102
+ * // 'data1' will be reverted.
103
103
  * chart.revert("data1");
104
104
  *
105
- * // data1 and data2 will be reverted.
105
+ * // 'data1' and 'data2' will be reverted.
106
106
  * chart.revert(["data1", "data2"]);
107
107
  *
108
108
  * // all targets will be reverted.
@@ -0,0 +1,206 @@
1
+ /**
2
+ * Copyright (c) 2017 ~ present NAVER Corp.
3
+ * billboard.js project is licensed under the MIT license
4
+ */
5
+ import {extend, isTabVisible} from "../../module/util";
6
+
7
+ type GridsParam = {
8
+ value?: number,
9
+ class?: string,
10
+ text?: string
11
+ }[];
12
+
13
+ /**
14
+ * Update grid lines.
15
+ * @param {Array} grids grid lines to update
16
+ * @param {string} axisId axis' id: "x" or "y"
17
+ * @returns {Array}
18
+ * @private
19
+ */
20
+ function grid(grids: GridsParam, axisId: "x" | "y"): GridsParam {
21
+ const $$ = this.internal;
22
+ const {config} = $$;
23
+ const withTransition = config.transition_duration && isTabVisible();
24
+ const gridPropLines = `grid_${axisId}_lines`;
25
+
26
+ if (!grids) {
27
+ return config[gridPropLines];
28
+ }
29
+
30
+ config[gridPropLines] = grids;
31
+
32
+ $$.updateGrid();
33
+ $$.redrawGrid(withTransition);
34
+
35
+ return config[gridPropLines];
36
+ }
37
+
38
+ /**
39
+ * Add grid lines.
40
+ * @param {Array|object} grids grid lines to add
41
+ * @param {string} axisId axis' id: "x" or "y"
42
+ * @returns {Array}
43
+ * @private
44
+ */
45
+ function add(grids: GridsParam, axisId: "x" | "y"): GridsParam {
46
+ const gridPropLines = `grid_${axisId}_lines`;
47
+
48
+ return grid.bind(this)(
49
+ this.internal.config[gridPropLines].concat(grids || []),
50
+ axisId
51
+ );
52
+ }
53
+
54
+ /**
55
+ * Remove grid lines.
56
+ * @param {object} grids grid lines to remove
57
+ * @param {boolean} isXAxis weather is x axis or not
58
+ * @private
59
+ */
60
+ function remove(grids: GridsParam | undefined, isXAxis: boolean): void {
61
+ this.internal.removeGridLines(grids, isXAxis);
62
+ }
63
+
64
+ /**
65
+ * Update x grid lines.
66
+ * @function xgrids
67
+ * @instance
68
+ * @memberof Chart
69
+ * @param {Array} grids X grid lines will be replaced with this argument. The format of this argument is the same as grid.x.lines.
70
+ * @returns {Array}
71
+ * @example
72
+ * // Show 2 x grid lines
73
+ * chart.xgrids([
74
+ * {value: 1, text: "Label 1"},
75
+ * {value: 4, text: "Label 4"}
76
+ * ]);
77
+ * // --> Returns: [{value: 1, text: "Label 1"}, {value: 4, text: "Label 4"}]
78
+ */
79
+ const xgrids = function(grids: GridsParam): GridsParam {
80
+ return grid.bind(this)(grids, "x");
81
+ };
82
+
83
+ extend(xgrids, {
84
+ /**
85
+ * Add x grid lines.<br>
86
+ * This API adds new x grid lines instead of replacing like xgrids.
87
+ * @function xgrids․add
88
+ * @instance
89
+ * @memberof Chart
90
+ * @param {Array|object} grids New x grid lines will be added. The format of this argument is the same as grid.x.lines and it's possible to give an Object if only one line will be added.
91
+ * @returns {Array}
92
+ * @example
93
+ * // Add a new x grid line
94
+ * chart.xgrids.add(
95
+ * {value: 4, text: "Label 4"}
96
+ * );
97
+ *
98
+ * // Add new x grid lines
99
+ * chart.xgrids.add([
100
+ * {value: 2, text: "Label 2"},
101
+ * {value: 4, text: "Label 4"}
102
+ * ]);
103
+ */
104
+ add(grids: GridsParam): GridsParam {
105
+ return add.bind(this)(grids, "x");
106
+ },
107
+
108
+ /**
109
+ * Remove x grid lines.<br>
110
+ * This API removes x grid lines.
111
+ * @function xgrids․remove
112
+ * @instance
113
+ * @memberof Chart
114
+ * @param {object} grids This argument should include value or class. If value is given, the x grid lines that have specified x value will be removed. If class is given, the x grid lines that have specified class will be removed. If args is not given, all of x grid lines will be removed.
115
+ * @param {number} [grids.value] target value
116
+ * @param {string} [grids.class] target class
117
+ * @returns {void}
118
+ * @example
119
+ * // x grid line on x = 2 will be removed
120
+ * chart.xgrids.remove({value: 2});
121
+ *
122
+ * // x grid lines that have 'grid-A' will be removed
123
+ * chart.xgrids.remove({
124
+ * class: "grid-A"
125
+ * });
126
+ *
127
+ * // all of x grid lines will be removed
128
+ * chart.xgrids.remove();
129
+ */
130
+ remove(grids?: GridsParam): void { // TODO: multiple
131
+ return remove.bind(this)(grids, true);
132
+ }
133
+ });
134
+
135
+ /**
136
+ * Update y grid lines.
137
+ * @function ygrids
138
+ * @instance
139
+ * @memberof Chart
140
+ * @param {Array} grids Y grid lines will be replaced with this argument. The format of this argument is the same as grid.y.lines.
141
+ * @returns {object}
142
+ * @example
143
+ * // Show 2 y grid lines
144
+ * chart.ygrids([
145
+ * {value: 100, text: "Label 1"},
146
+ * {value: 400, text: "Label 4"}
147
+ * ]);
148
+ * // --> Returns: [{value: 100, text: "Label 1"}, {value: 400, text: "Label 4"}]
149
+ */
150
+ const ygrids = function(grids: GridsParam): GridsParam {
151
+ return grid.bind(this)(grids, "y");
152
+ };
153
+
154
+ extend(ygrids, {
155
+ /**
156
+ * Add y grid lines.<br>
157
+ * This API adds new y grid lines instead of replacing like ygrids.
158
+ * @function ygrids․add
159
+ * @instance
160
+ * @memberof Chart
161
+ * @param {Array|object} grids New y grid lines will be added. The format of this argument is the same as grid.y.lines and it's possible to give an Object if only one line will be added.
162
+ * @returns {object}
163
+ * @example
164
+ * // Add a new x grid line
165
+ * chart.ygrids.add(
166
+ * {value: 400, text: "Label 4"}
167
+ * );
168
+ *
169
+ * // Add new x grid lines
170
+ * chart.ygrids.add([
171
+ * {value: 200, text: "Label 2"},
172
+ * {value: 400, text: "Label 4"}
173
+ * ]);
174
+ */
175
+ add(grids: GridsParam): GridsParam {
176
+ return add.bind(this)(grids, "y");
177
+ },
178
+
179
+ /**
180
+ * Remove y grid lines.<br>
181
+ * This API removes x grid lines.
182
+ * @function ygrids․remove
183
+ * @instance
184
+ * @memberof Chart
185
+ * @param {object} grids This argument should include value or class. If value is given, the y grid lines that have specified y value will be removed. If class is given, the y grid lines that have specified class will be removed. If args is not given, all of y grid lines will be removed.
186
+ * @param {number} [grids.value] target value
187
+ * @param {string} [grids.class] target class
188
+ * @returns {void}
189
+ * @example
190
+ * // y grid line on y = 200 will be removed
191
+ * chart.ygrids.remove({value: 200});
192
+ *
193
+ * // y grid lines that have 'grid-A' will be removed
194
+ * chart.ygrids.remove({
195
+ * class: "grid-A"
196
+ * });
197
+ *
198
+ * // all of y grid lines will be removed
199
+ * chart.ygrids.remove();
200
+ */
201
+ remove(grids?: GridsParam): void { // TODO: multiple
202
+ return remove.bind(this)(grids, false);
203
+ }
204
+ });
205
+
206
+ export default {xgrids, ygrids};