billboard.js 3.11.3 → 3.12.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 (177) hide show
  1. package/README.md +1 -5
  2. package/dist/billboard.css +13 -1
  3. package/dist/billboard.js +19672 -24210
  4. package/dist/billboard.min.css +2 -2
  5. package/dist/billboard.min.js +26 -3
  6. package/dist/billboard.pkgd.js +24515 -30430
  7. package/dist/billboard.pkgd.min.js +33 -3
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.js +77 -175
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -3
  10. package/dist/plugin/billboardjs-plugin-sparkline.js +429 -1134
  11. package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -3
  12. package/dist/plugin/billboardjs-plugin-stanford.js +666 -1524
  13. package/dist/plugin/billboardjs-plugin-stanford.min.js +15 -3
  14. package/dist/plugin/billboardjs-plugin-tableview.js +503 -1175
  15. package/dist/plugin/billboardjs-plugin-tableview.min.js +30 -3
  16. package/dist/plugin/billboardjs-plugin-textoverlap.js +351 -1055
  17. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +4 -3
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +1387 -1854
  19. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +5 -3
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2760 -3959
  21. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +7 -3
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +3504 -5057
  23. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +18 -3
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2906 -4072
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +33 -3
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +3076 -4506
  27. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -3
  28. package/dist/theme/dark.css +12 -1
  29. package/dist/theme/dark.min.css +2 -2
  30. package/dist/theme/datalab.css +12 -1
  31. package/dist/theme/datalab.min.css +2 -2
  32. package/dist/theme/graph.css +12 -1
  33. package/dist/theme/graph.min.css +2 -2
  34. package/dist/theme/insight.css +12 -1
  35. package/dist/theme/insight.min.css +2 -2
  36. package/dist/theme/modern.css +12 -1
  37. package/dist/theme/modern.min.css +3 -4
  38. package/dist-esm/billboard.js +9297 -8527
  39. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +20 -27
  40. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +155 -149
  41. package/dist-esm/plugin/billboardjs-plugin-stanford.js +302 -289
  42. package/dist-esm/plugin/billboardjs-plugin-tableview.js +236 -236
  43. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +41 -43
  44. package/package.json +29 -49
  45. package/src/Chart/api/axis.ts +6 -13
  46. package/src/Chart/api/chart.ts +12 -11
  47. package/src/Chart/api/data.ts +8 -7
  48. package/src/Chart/api/export.ts +28 -21
  49. package/src/Chart/api/flow.ts +4 -2
  50. package/src/Chart/api/grid.ts +1 -5
  51. package/src/Chart/api/load.ts +2 -2
  52. package/src/Chart/api/regions.ts +29 -5
  53. package/src/Chart/api/selection.ts +2 -2
  54. package/src/Chart/api/show.ts +2 -3
  55. package/src/Chart/api/subchart.ts +2 -2
  56. package/src/Chart/api/tooltip.ts +8 -9
  57. package/src/Chart/api/x.ts +2 -2
  58. package/src/Chart/api/zoom.ts +2 -2
  59. package/src/ChartInternal/Axis/Axis.ts +119 -44
  60. package/src/ChartInternal/Axis/AxisRenderer.ts +53 -38
  61. package/src/ChartInternal/Axis/AxisRendererHelper.ts +2 -2
  62. package/src/ChartInternal/ChartInternal.ts +87 -55
  63. package/src/ChartInternal/data/IData.ts +31 -31
  64. package/src/ChartInternal/data/convert.helper.ts +66 -68
  65. package/src/ChartInternal/data/convert.ts +11 -11
  66. package/src/ChartInternal/data/data.ts +51 -27
  67. package/src/ChartInternal/data/load.ts +7 -6
  68. package/src/ChartInternal/interactions/drag.ts +2 -1
  69. package/src/ChartInternal/interactions/eventrect.ts +84 -32
  70. package/src/ChartInternal/interactions/flow.ts +14 -4
  71. package/src/ChartInternal/interactions/interaction.ts +51 -22
  72. package/src/ChartInternal/interactions/subchart.ts +27 -25
  73. package/src/ChartInternal/interactions/zoom.ts +29 -18
  74. package/src/ChartInternal/internals/category.ts +1 -1
  75. package/src/ChartInternal/internals/class.ts +6 -6
  76. package/src/ChartInternal/internals/clip.ts +8 -4
  77. package/src/ChartInternal/internals/color.ts +70 -42
  78. package/src/ChartInternal/internals/domain.ts +59 -28
  79. package/src/ChartInternal/internals/format.ts +5 -5
  80. package/src/ChartInternal/internals/grid.ts +131 -47
  81. package/src/ChartInternal/internals/legend.ts +93 -61
  82. package/src/ChartInternal/internals/redraw.ts +6 -2
  83. package/src/ChartInternal/internals/region.ts +5 -3
  84. package/src/ChartInternal/internals/scale.ts +28 -15
  85. package/src/ChartInternal/internals/selection.ts +14 -13
  86. package/src/ChartInternal/internals/size.axis.ts +18 -10
  87. package/src/ChartInternal/internals/size.ts +98 -67
  88. package/src/ChartInternal/internals/style.ts +21 -19
  89. package/src/ChartInternal/internals/text.ts +79 -43
  90. package/src/ChartInternal/internals/title.ts +2 -2
  91. package/src/ChartInternal/internals/tooltip.ts +78 -32
  92. package/src/ChartInternal/internals/transform.ts +4 -4
  93. package/src/ChartInternal/internals/type.ts +17 -12
  94. package/src/ChartInternal/shape/arc.ts +78 -44
  95. package/src/ChartInternal/shape/area.ts +19 -22
  96. package/src/ChartInternal/shape/bar.ts +41 -31
  97. package/src/ChartInternal/shape/bubble.ts +5 -5
  98. package/src/ChartInternal/shape/candlestick.ts +15 -13
  99. package/src/ChartInternal/shape/funnel.ts +317 -0
  100. package/src/ChartInternal/shape/gauge.ts +16 -9
  101. package/src/ChartInternal/shape/line.ts +62 -46
  102. package/src/ChartInternal/shape/point.common.ts +1 -4
  103. package/src/ChartInternal/shape/point.ts +54 -34
  104. package/src/ChartInternal/shape/polar.ts +4 -2
  105. package/src/ChartInternal/shape/radar.ts +40 -22
  106. package/src/ChartInternal/shape/shape.ts +84 -58
  107. package/src/ChartInternal/shape/treemap.ts +31 -20
  108. package/src/Plugin/bubblecompare/index.ts +1 -3
  109. package/src/Plugin/sparkline/index.ts +3 -4
  110. package/src/Plugin/stanford/ColorScale.ts +3 -2
  111. package/src/Plugin/stanford/Elements.ts +15 -6
  112. package/src/Plugin/stanford/Options.ts +5 -5
  113. package/src/Plugin/stanford/index.ts +13 -9
  114. package/src/Plugin/tableview/Options.ts +1 -1
  115. package/src/Plugin/tableview/const.ts +1 -4
  116. package/src/Plugin/tableview/index.ts +11 -9
  117. package/src/Plugin/textoverlap/index.ts +4 -6
  118. package/src/config/Options/Options.ts +3 -3
  119. package/src/config/Options/axis/axis.ts +36 -0
  120. package/src/config/Options/axis/x.ts +34 -14
  121. package/src/config/Options/axis/y.ts +13 -13
  122. package/src/config/Options/axis/y2.ts +23 -10
  123. package/src/config/Options/common/color.ts +4 -4
  124. package/src/config/Options/common/grid.ts +4 -4
  125. package/src/config/Options/common/legend.ts +12 -13
  126. package/src/config/Options/common/main.ts +23 -23
  127. package/src/config/Options/common/point.ts +17 -18
  128. package/src/config/Options/common/title.ts +2 -2
  129. package/src/config/Options/common/tooltip.ts +13 -11
  130. package/src/config/Options/data/axis.ts +2 -2
  131. package/src/config/Options/data/data.ts +48 -45
  132. package/src/config/Options/interaction/interaction.ts +1 -1
  133. package/src/config/Options/interaction/subchart.ts +2 -2
  134. package/src/config/Options/interaction/zoom.ts +9 -9
  135. package/src/config/Options/shape/arc.ts +10 -13
  136. package/src/config/Options/shape/area.ts +5 -7
  137. package/src/config/Options/shape/bar.ts +8 -10
  138. package/src/config/Options/shape/bubble.ts +1 -1
  139. package/src/config/Options/shape/candlestick.ts +2 -2
  140. package/src/config/Options/shape/donut.ts +4 -4
  141. package/src/config/Options/shape/funnel.ts +38 -0
  142. package/src/config/Options/shape/gauge.ts +6 -6
  143. package/src/config/Options/shape/line.ts +3 -3
  144. package/src/config/Options/shape/pie.ts +5 -5
  145. package/src/config/Options/shape/polar.ts +3 -3
  146. package/src/config/Options/shape/radar.ts +2 -2
  147. package/src/config/Options/shape/scatter.ts +1 -1
  148. package/src/config/Options/shape/treemap.ts +1 -1
  149. package/src/config/Store/Element.ts +8 -5
  150. package/src/config/Store/State.ts +20 -13
  151. package/src/config/classes.ts +14 -4
  152. package/src/config/config.ts +1 -1
  153. package/src/config/const.ts +2 -0
  154. package/src/config/resolver/axis.ts +4 -4
  155. package/src/config/resolver/interaction.ts +3 -7
  156. package/src/config/resolver/shape.ts +17 -12
  157. package/src/core.ts +2 -3
  158. package/src/index.esm.ts +3 -6
  159. package/src/index.ts +2 -2
  160. package/src/module/Cache.ts +2 -3
  161. package/src/module/browser.ts +15 -10
  162. package/src/module/error.ts +9 -8
  163. package/src/module/generator.ts +3 -5
  164. package/src/module/util.ts +62 -39
  165. package/src/module/worker.ts +14 -11
  166. package/src/scss/billboard.scss +18 -0
  167. package/src/scss/theme/dark.scss +17 -0
  168. package/src/scss/theme/datalab.scss +17 -0
  169. package/src/scss/theme/graph.scss +17 -0
  170. package/src/scss/theme/insight.scss +17 -0
  171. package/src/scss/theme/modern.scss +17 -0
  172. package/types/axis.d.ts +17 -0
  173. package/types/bb.d.ts +1 -0
  174. package/types/index.d.ts +1 -0
  175. package/types/options.d.ts +9 -0
  176. package/types/options.shape.d.ts +26 -1
  177. package/types/types.d.ts +1 -0
@@ -5,12 +5,12 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.11.3
8
+ * @version 3.12.0-next.2
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
12
- import { interpolateHslLong } from 'd3-interpolate';
13
12
  import { hsl } from 'd3-color';
13
+ import { interpolateHslLong } from 'd3-interpolate';
14
14
  import { scaleSequential, scaleSymlog, scaleSequentialLog } from 'd3-scale';
15
15
  import { axisRight } from 'd3-axis';
16
16
  import { format } from 'd3-format';
@@ -28,45 +28,43 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
28
28
  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
- ***************************************************************************** */
32
- /* global Reflect, Promise, SuppressedError, Symbol */
33
-
34
- var _extendStatics = function extendStatics(d, b) {
35
- _extendStatics = Object.setPrototypeOf || {
36
- __proto__: []
37
- } instanceof Array && function (d, b) {
38
- d.__proto__ = b;
39
- } || function (d, b) {
40
- for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
41
- };
42
- return _extendStatics(d, b);
43
- };
44
- function __extends(d, b) {
45
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + (b + "") + " is not a constructor or null");
46
- _extendStatics(d, b);
47
- function __() {
48
- this.constructor = d;
49
- }
50
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
51
- }
52
- var _assign = function __assign() {
53
- _assign = Object.assign || function (t) {
54
- for (var s, i = 1, n = arguments.length; i < n; i++) {
55
- s = arguments[i];
56
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
57
- }
58
- return t;
59
- };
60
- return _assign.apply(this, arguments);
61
- };
62
- function __spreadArray(to, from, pack) {
63
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
64
- if (ar || !(i in from)) {
65
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
66
- ar[i] = from[i];
67
- }
68
- }
69
- return to.concat(ar || Array.prototype.slice.call(from));
31
+ ***************************************************************************** */
32
+ /* global Reflect, Promise, SuppressedError, Symbol */
33
+
34
+ var extendStatics = function(d, b) {
35
+ extendStatics = Object.setPrototypeOf ||
36
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
37
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
38
+ return extendStatics(d, b);
39
+ };
40
+
41
+ function __extends(d, b) {
42
+ if (typeof b !== "function" && b !== null)
43
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
44
+ extendStatics(d, b);
45
+ function __() { this.constructor = d; }
46
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
47
+ }
48
+
49
+ var __assign = function() {
50
+ __assign = Object.assign || function __assign(t) {
51
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
52
+ s = arguments[i];
53
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
54
+ }
55
+ return t;
56
+ };
57
+ return __assign.apply(this, arguments);
58
+ };
59
+
60
+ function __spreadArray(to, from, pack) {
61
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
62
+ if (ar || !(i in from)) {
63
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
64
+ ar[i] = from[i];
65
+ }
66
+ }
67
+ return to.concat(ar || Array.prototype.slice.call(from));
70
68
  }
71
69
 
72
70
  /**
@@ -107,7 +105,10 @@ var $AXIS = {
107
105
  axisY: "bb-axis-y",
108
106
  axisY2: "bb-axis-y2",
109
107
  axisY2Label: "bb-axis-y2-label",
110
- axisYLabel: "bb-axis-y-label"
108
+ axisYLabel: "bb-axis-y-label",
109
+ axisXTooltip: "bb-axis-x-tooltip",
110
+ axisYTooltip: "bb-axis-y-tooltip",
111
+ axisY2Tooltip: "bb-axis-y2-tooltip"
111
112
  };
112
113
  var $BAR = {
113
114
  bar: "bb-bar",
@@ -136,6 +137,12 @@ var $DRAG = {
136
137
  dragarea: "bb-dragarea",
137
138
  INCLUDED: "_included_"
138
139
  };
140
+ var $FUNNEL = {
141
+ funnel: "bb-funnel",
142
+ chartFunnel: "bb-chart-funnel",
143
+ chartFunnels: "bb-chart-funnels",
144
+ funnelBackground: "bb-funnel-background"
145
+ };
139
146
  var $GAUGE = {
140
147
  chartArcsGaugeMax: "bb-chart-arcs-gauge-max",
141
148
  chartArcsGaugeMin: "bb-chart-arcs-gauge-min",
@@ -162,7 +169,7 @@ var $EVENT = {
162
169
  eventRect: "bb-event-rect",
163
170
  eventRects: "bb-event-rects",
164
171
  eventRectsMultiple: "bb-event-rects-multiple",
165
- eventRectsSingle: "bb-event-rects-single",
172
+ eventRectsSingle: "bb-event-rects-single"
166
173
  };
167
174
  var $FOCUS = {
168
175
  focused: "bb-focused",
@@ -198,7 +205,7 @@ var $SELECT = {
198
205
  };
199
206
  var $SHAPE = {
200
207
  shape: "bb-shape",
201
- shapes: "bb-shapes",
208
+ shapes: "bb-shapes"
202
209
  };
203
210
  var $SUBCHART = {
204
211
  brush: "bb-brush",
@@ -226,7 +233,7 @@ var $ZOOM = {
226
233
  buttonZoomReset: "bb-zoom-reset",
227
234
  zoomBrush: "bb-zoom-brush"
228
235
  };
229
- _assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign({}, $COMMON), $ARC), $AREA), $AXIS), $BAR), $CANDLESTICK), $CIRCLE), $COLOR), $DRAG), $GAUGE), $LEGEND), $LINE), $EVENT), $FOCUS), $GRID), $RADAR), $REGION), $SELECT), $SHAPE), $SUBCHART), $TEXT), $TOOLTIP), $TREEMAP), $ZOOM);
236
+ __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, $COMMON), $ARC), $AREA), $AXIS), $BAR), $CANDLESTICK), $CIRCLE), $COLOR), $DRAG), $GAUGE), $LEGEND), $LINE), $EVENT), $FOCUS), $FUNNEL), $GRID), $RADAR), $REGION), $SELECT), $SHAPE), $SUBCHART), $TEXT), $TOOLTIP), $TREEMAP), $ZOOM);
230
237
 
231
238
  /**
232
239
  * Copyright (c) 2017 ~ present NAVER Corp.
@@ -243,7 +250,8 @@ _assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(
243
250
  * @private
244
251
  */
245
252
  function getGlobal() {
246
- return (typeof globalThis === "object" && globalThis !== null && globalThis.Object === Object && globalThis) ||
253
+ return (typeof globalThis === "object" && globalThis !== null && globalThis.Object === Object &&
254
+ globalThis) ||
247
255
  (typeof global === "object" && global !== null && global.Object === Object && global) ||
248
256
  (typeof self === "object" && self !== null && self.Object === Object && self) ||
249
257
  Function("return this")();
@@ -299,8 +307,7 @@ function mergeObj(target) {
299
307
  target[key] = mergeObj(target[key], value);
300
308
  }
301
309
  else {
302
- target[key] = isArray(value) ?
303
- value.concat() : value;
310
+ target[key] = isArray(value) ? value.concat() : value;
304
311
  }
305
312
  });
306
313
  }
@@ -315,7 +322,6 @@ function mergeObj(target) {
315
322
  * @private
316
323
  */
317
324
  var getRange = function (start, end, step) {
318
- if (step === void 0) { step = 1; }
319
325
  var res = [];
320
326
  var n = Math.max(0, Math.ceil((end - start) / step)) | 0;
321
327
  for (var i = start; i < n; i++) {
@@ -327,7 +333,12 @@ var getRange = function (start, end, step) {
327
333
  ({
328
334
  mouse: (function () {
329
335
  var getParams = function () { return ({
330
- bubbles: false, cancelable: false, screenX: 0, screenY: 0, clientX: 0, clientY: 0
336
+ bubbles: false,
337
+ cancelable: false,
338
+ screenX: 0,
339
+ screenY: 0,
340
+ clientX: 0,
341
+ clientY: 0
331
342
  }); };
332
343
  try {
333
344
  // eslint-disable-next-line no-new
@@ -397,10 +408,6 @@ function parseDate(date) {
397
408
  return parsedDate;
398
409
  }
399
410
 
400
- /**
401
- * Copyright (c) 2017 ~ present NAVER Corp.
402
- * billboard.js project is licensed under the MIT license
403
- */
404
411
  /**
405
412
  * Load configuration option
406
413
  * @param {object} config User's generation config value
@@ -494,156 +501,9 @@ var Plugin = /** @class */ (function () {
494
501
  delete _this[key];
495
502
  });
496
503
  };
497
- Plugin.version = "3.11.3";
504
+ Plugin.version = "3.12.0-next.2";
498
505
  return Plugin;
499
506
  }());
500
- var Plugin$1 = Plugin;
501
-
502
- /**
503
- * Copyright (c) 2017 ~ present NAVER Corp.
504
- * billboard.js project is licensed under the MIT license
505
- */
506
- /**
507
- * Stanford diagram plugin option class
508
- * @class StanfordOptions
509
- * @param {Options} options Stanford plugin options
510
- * @augments Plugin
511
- * @returns {StanfordOptions}
512
- * @private
513
- */
514
- var Options = /** @class */ (function () {
515
- function Options() {
516
- return {
517
- /**
518
- * Set the color of the color scale. This function receives a value between 0 and 1, and should return a color.
519
- * @name colors
520
- * @memberof plugin-stanford
521
- * @type {Function}
522
- * @default undefined
523
- * @example
524
- * colors: d3.interpolateHslLong(
525
- * d3.hsl(250, 1, 0.5), d3.hsl(0, 1, 0.5)
526
- * )
527
- */
528
- colors: undefined,
529
- /**
530
- * Specify the key of epochs values in the data.
531
- * @name epochs
532
- * @memberof plugin-stanford
533
- * @type {Array}
534
- * @default []
535
- * @example
536
- * epochs: [ 1, 1, 2, 2, ... ]
537
- */
538
- epochs: [],
539
- /**
540
- * Show additional lines anywhere on the chart.
541
- * - Each line object should consist with following options:
542
- *
543
- * | Key | Type | Description |
544
- * | --- | --- | --- |
545
- * | x1 | Number | Starting position on the x axis |
546
- * | y1 | Number | Starting position on the y axis |
547
- * | x2 | Number | Ending position on the x axis |
548
- * | y2 | Number | Ending position on the y axis |
549
- * | class | String | Optional value. Set a custom css class to this line. |
550
- * @type {Array}
551
- * @memberof plugin-stanford
552
- * @default []
553
- * @example
554
- * lines: [
555
- * { x1: 0, y1: 0, x2: 65, y2: 65, class: "line1" },
556
- * { x1: 0, x2: 65, y1: 40, y2: 40, class: "line2" }
557
- * ]
558
- */
559
- lines: [],
560
- /**
561
- * Set scale values
562
- * @name scale
563
- * @memberof plugin-stanford
564
- * @type {object}
565
- * @property {object} [scale] scale object
566
- * @property {number} [scale.min=undefined] Minimum value of the color scale. Default: lowest value in epochs
567
- * @property {number} [scale.max=undefined] Maximum value of the color scale. Default: highest value in epochs
568
- * @property {number} [scale.width=20] Width of the color scale
569
- * @property {string|Function} [scale.format=undefined] Format of the axis of the color scale. Use 'pow10' to format as powers of 10 or a custom function. Example: d3.format("d")
570
- * @example
571
- * scale: {
572
- * max: 10000,
573
- * min: 1,
574
- * width: 500,
575
- *
576
- * // specify 'pow10' to format as powers of 10
577
- * format: "pow10",
578
- *
579
- * // or specify a format function
580
- * format: function(x) {
581
- * return x +"%";
582
- * }
583
- * },
584
- */
585
- scale_min: undefined,
586
- scale_max: undefined,
587
- scale_width: 20,
588
- scale_format: undefined,
589
- /**
590
- * The padding for color scale element
591
- * @name padding
592
- * @memberof plugin-stanford
593
- * @type {object}
594
- * @property {object} [padding] padding object
595
- * @property {number} [padding.top=0] Top padding value.
596
- * @property {number} [padding.right=0] Right padding value.
597
- * @property {number} [padding.bottom=0] Bottom padding value.
598
- * @property {number} [padding.left=0] Left padding value.
599
- * @example
600
- * padding: {
601
- * top: 15,
602
- * right: 0,
603
- * bottom: 0,
604
- * left: 0
605
- * },
606
- */
607
- padding_top: 0,
608
- padding_right: 0,
609
- padding_bottom: 0,
610
- padding_left: 0,
611
- /**
612
- * Show additional regions anywhere on the chart.
613
- * - Each region object should consist with following options:
614
- *
615
- * | Key | Type | Default | Attributes | Description |
616
- * | --- | --- | --- | --- | --- |
617
- * | points | Array | | | Accepts a group of objects that has x and y.<br>These points should be added in a counter-clockwise fashion to make a closed polygon. |
618
- * | opacity | Number | `0.2` | &lt;optional> | Sets the opacity of the region as value between 0 and 1 |
619
- * | text | Function | | &lt;optional> | This function receives a value and percentage of the number of epochs in this region.<br>Return a string to place text in the middle of the region. |
620
- * | class | String | | &lt;optional> | Se a custom css class to this region, use the fill property in css to set a background color. |
621
- * @name regions
622
- * @memberof plugin-stanford
623
- * @type {Array}
624
- * @default []
625
- * @example
626
- * regions: [
627
- * {
628
- * points: [ // add points counter-clockwise
629
- * { x: 0, y: 0 },
630
- * { x: 40, y: 40 },
631
- * { x: 0, y: 40 },
632
- * ],
633
- * text: function (value, percentage) {
634
- * return `Normal Operations: ${value} (${percentage}%)`;
635
- * },
636
- * opacity: 0.2, // 0 to 1
637
- * class: "test-polygon1"
638
- * },
639
- * ...
640
- * ]
641
- */
642
- regions: []
643
- };
644
- }
645
- return Options;
646
- }());
647
507
 
648
508
  /**
649
509
  * Copyright (c) 2017 ~ present NAVER Corp.
@@ -752,6 +612,91 @@ function getCentroid(points) {
752
612
  };
753
613
  }
754
614
 
615
+ /**
616
+ * Copyright (c) 2017 ~ present NAVER Corp.
617
+ * billboard.js project is licensed under the MIT license
618
+ */
619
+ /**
620
+ * Stanford diagram plugin color scale class
621
+ * @class ColorScale
622
+ * @param {Stanford} owner Stanford instance
623
+ * @private
624
+ */
625
+ var ColorScale = /** @class */ (function () {
626
+ function ColorScale(owner) {
627
+ this.owner = owner;
628
+ }
629
+ ColorScale.prototype.drawColorScale = function () {
630
+ var _a = this.owner, $$ = _a.$$, config = _a.config;
631
+ var target = $$.data.targets[0];
632
+ var height = $$.state.height - config.padding_bottom - config.padding_top;
633
+ var barWidth = config.scale_width;
634
+ var barHeight = 5;
635
+ var points = getRange(config.padding_bottom, height, barHeight);
636
+ var inverseScale = scaleSequential(target.colors)
637
+ .domain([points[points.length - 1], points[0]]);
638
+ if (this.colorScale) {
639
+ this.colorScale.remove();
640
+ }
641
+ this.colorScale = $$.$el.svg.append("g")
642
+ .attr("width", 50)
643
+ .attr("height", height)
644
+ .attr("class", CLASS.colorScale);
645
+ this.colorScale.append("g")
646
+ .attr("transform", "translate(0, ".concat(config.padding_top, ")"))
647
+ .selectAll("bars")
648
+ .data(points)
649
+ .enter()
650
+ .append("rect")
651
+ .attr("y", function (d, i) { return i * barHeight; })
652
+ .attr("x", 0)
653
+ .attr("width", barWidth)
654
+ .attr("height", barHeight)
655
+ .attr("fill", function (d) { return inverseScale(d); });
656
+ // Legend Axis
657
+ var axisScale = scaleSymlog()
658
+ .domain([target.minEpochs, target.maxEpochs])
659
+ .range([
660
+ points[0] + config.padding_top + points[points.length - 1] + barHeight - 1,
661
+ points[0] + config.padding_top
662
+ ]);
663
+ var legendAxis = axisRight(axisScale);
664
+ var scaleFormat = config.scale_format;
665
+ if (scaleFormat === "pow10") {
666
+ legendAxis.tickValues([1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]);
667
+ }
668
+ else if (isFunction(scaleFormat)) {
669
+ legendAxis.tickFormat(scaleFormat);
670
+ }
671
+ else {
672
+ legendAxis.tickFormat(format("d"));
673
+ }
674
+ // Draw Axis
675
+ var axis = this.colorScale.append("g")
676
+ .attr("class", "legend axis")
677
+ .attr("transform", "translate(".concat(barWidth, ",0)"))
678
+ .call(legendAxis);
679
+ if (scaleFormat === "pow10") {
680
+ axis.selectAll(".tick text")
681
+ .text(null)
682
+ .filter(function (d) { return d / Math.pow(10, Math.ceil(Math.log(d) / Math.LN10 - 1e-12)) === 1; }) // Power of Ten
683
+ .text(10)
684
+ .append("tspan")
685
+ .attr("dy", "-.7em") // https://bl.ocks.org/mbostock/6738229
686
+ .text(function (d) { return Math.round(Math.log(d) / Math.LN10); });
687
+ }
688
+ this.colorScale.attr("transform", "translate(".concat($$.state.current.width - this.xForColorScale(), ", 0)"));
689
+ };
690
+ ColorScale.prototype.xForColorScale = function () {
691
+ return this.owner.config.padding_right +
692
+ this.colorScale.node().getBBox().width;
693
+ };
694
+ ColorScale.prototype.getColorScalePadding = function () {
695
+ return this.xForColorScale() + this.owner.config.padding_left + 20;
696
+ };
697
+ return ColorScale;
698
+ }());
699
+
755
700
  /**
756
701
  * Copyright (c) 2017 ~ present NAVER Corp.
757
702
  * billboard.js project is licensed under the MIT license
@@ -842,17 +787,25 @@ var Elements = /** @class */ (function () {
842
787
  .select("polygon")
843
788
  .transition()
844
789
  .duration(duration)
845
- .attr("points", function (d) { return d.points.map(function (value) { return [
846
- isRotated ? yvCustom(value, "y") : xvCustom(value, "x"),
847
- isRotated ? xvCustom(value, "x") : yvCustom(value, "y")
848
- ].join(","); }).join(" "); })
790
+ .attr("points", function (d) {
791
+ return d.points.map(function (value) {
792
+ return [
793
+ isRotated ? yvCustom(value, "y") : xvCustom(value, "x"),
794
+ isRotated ? xvCustom(value, "x") : yvCustom(value, "y")
795
+ ].join(",");
796
+ }).join(" ");
797
+ })
849
798
  .transition()
850
799
  .style("opacity", function (d) { return String(d.opacity ? d.opacity : 0.2); });
851
800
  stanfordRegion.select("text")
852
801
  .transition()
853
802
  .duration(duration)
854
- .attr("x", function (d) { return (isRotated ? yvCustom(getCentroid(d.points), "y") : xvCustom(getCentroid(d.points), "x")); })
855
- .attr("y", function (d) { return (isRotated ? xvCustom(getCentroid(d.points), "x") : yvCustom(getCentroid(d.points), "y")); })
803
+ .attr("x", function (d) { return (isRotated ?
804
+ yvCustom(getCentroid(d.points), "y") :
805
+ xvCustom(getCentroid(d.points), "x")); })
806
+ .attr("y", function (d) { return (isRotated ?
807
+ xvCustom(getCentroid(d.points), "x") :
808
+ yvCustom(getCentroid(d.points), "y")); })
856
809
  .text(function (d) {
857
810
  if (d.text) {
858
811
  var _a = countPointsInRegion(d.points), value = _a.value, percentage = _a.percentage;
@@ -896,84 +849,145 @@ var Elements = /** @class */ (function () {
896
849
  * billboard.js project is licensed under the MIT license
897
850
  */
898
851
  /**
899
- * Stanford diagram plugin color scale class
900
- * @class ColorScale
901
- * @param {Stanford} owner Stanford instance
852
+ * Stanford diagram plugin option class
853
+ * @class StanfordOptions
854
+ * @param {Options} options Stanford plugin options
855
+ * @augments Plugin
856
+ * @returns {StanfordOptions}
902
857
  * @private
903
858
  */
904
- var ColorScale = /** @class */ (function () {
905
- function ColorScale(owner) {
906
- this.owner = owner;
859
+ var Options = /** @class */ (function () {
860
+ function Options() {
861
+ return {
862
+ /**
863
+ * Set the color of the color scale. This function receives a value between 0 and 1, and should return a color.
864
+ * @name colors
865
+ * @memberof plugin-stanford
866
+ * @type {Function}
867
+ * @default undefined
868
+ * @example
869
+ * colors: d3.interpolateHslLong(
870
+ * d3.hsl(250, 1, 0.5), d3.hsl(0, 1, 0.5)
871
+ * )
872
+ */
873
+ colors: undefined,
874
+ /**
875
+ * Specify the key of epochs values in the data.
876
+ * @name epochs
877
+ * @memberof plugin-stanford
878
+ * @type {Array}
879
+ * @default []
880
+ * @example
881
+ * epochs: [ 1, 1, 2, 2, ... ]
882
+ */
883
+ epochs: [],
884
+ /**
885
+ * Show additional lines anywhere on the chart.
886
+ * - Each line object should consist with following options:
887
+ *
888
+ * | Key | Type | Description |
889
+ * | --- | --- | --- |
890
+ * | x1 | Number | Starting position on the x axis |
891
+ * | y1 | Number | Starting position on the y axis |
892
+ * | x2 | Number | Ending position on the x axis |
893
+ * | y2 | Number | Ending position on the y axis |
894
+ * | class | String | Optional value. Set a custom css class to this line. |
895
+ * @type {Array}
896
+ * @memberof plugin-stanford
897
+ * @default []
898
+ * @example
899
+ * lines: [
900
+ * { x1: 0, y1: 0, x2: 65, y2: 65, class: "line1" },
901
+ * { x1: 0, x2: 65, y1: 40, y2: 40, class: "line2" }
902
+ * ]
903
+ */
904
+ lines: [],
905
+ /**
906
+ * Set scale values
907
+ * @name scale
908
+ * @memberof plugin-stanford
909
+ * @type {object}
910
+ * @property {object} [scale] scale object
911
+ * @property {number} [scale.min=undefined] Minimum value of the color scale. Default: lowest value in epochs
912
+ * @property {number} [scale.max=undefined] Maximum value of the color scale. Default: highest value in epochs
913
+ * @property {number} [scale.width=20] Width of the color scale
914
+ * @property {string|Function} [scale.format=undefined] Format of the axis of the color scale. Use 'pow10' to format as powers of 10 or a custom function. Example: d3.format("d")
915
+ * @example
916
+ * scale: {
917
+ * max: 10000,
918
+ * min: 1,
919
+ * width: 500,
920
+ *
921
+ * // specify 'pow10' to format as powers of 10
922
+ * format: "pow10",
923
+ *
924
+ * // or specify a format function
925
+ * format: function(x) {
926
+ * return x +"%";
927
+ * }
928
+ * },
929
+ */
930
+ scale_min: undefined,
931
+ scale_max: undefined,
932
+ scale_width: 20,
933
+ scale_format: undefined,
934
+ /**
935
+ * The padding for color scale element
936
+ * @name padding
937
+ * @memberof plugin-stanford
938
+ * @type {object}
939
+ * @property {object} [padding] padding object
940
+ * @property {number} [padding.top=0] Top padding value.
941
+ * @property {number} [padding.right=0] Right padding value.
942
+ * @property {number} [padding.bottom=0] Bottom padding value.
943
+ * @property {number} [padding.left=0] Left padding value.
944
+ * @example
945
+ * padding: {
946
+ * top: 15,
947
+ * right: 0,
948
+ * bottom: 0,
949
+ * left: 0
950
+ * },
951
+ */
952
+ padding_top: 0,
953
+ padding_right: 0,
954
+ padding_bottom: 0,
955
+ padding_left: 0,
956
+ /**
957
+ * Show additional regions anywhere on the chart.
958
+ * - Each region object should consist with following options:
959
+ *
960
+ * | Key | Type | Default | Attributes | Description |
961
+ * | --- | --- | --- | --- | --- |
962
+ * | points | Array | | | Accepts a group of objects that has x and y.<br>These points should be added in a counter-clockwise fashion to make a closed polygon. |
963
+ * | opacity | Number | `0.2` | &lt;optional> | Sets the opacity of the region as value between 0 and 1 |
964
+ * | text | Function | | &lt;optional> | This function receives a value and percentage of the number of epochs in this region.<br>Return a string to place text in the middle of the region. |
965
+ * | class | String | | &lt;optional> | Se a custom css class to this region, use the fill property in css to set a background color. |
966
+ * @name regions
967
+ * @memberof plugin-stanford
968
+ * @type {Array}
969
+ * @default []
970
+ * @example
971
+ * regions: [
972
+ * {
973
+ * points: [ // add points counter-clockwise
974
+ * { x: 0, y: 0 },
975
+ * { x: 40, y: 40 },
976
+ * { x: 0, y: 40 },
977
+ * ],
978
+ * text: function (value, percentage) {
979
+ * return `Normal Operations: ${value} (${percentage}%)`;
980
+ * },
981
+ * opacity: 0.2, // 0 to 1
982
+ * class: "test-polygon1"
983
+ * },
984
+ * ...
985
+ * ]
986
+ */
987
+ regions: []
988
+ };
907
989
  }
908
- ColorScale.prototype.drawColorScale = function () {
909
- var _a = this.owner, $$ = _a.$$, config = _a.config;
910
- var target = $$.data.targets[0];
911
- var height = $$.state.height - config.padding_bottom - config.padding_top;
912
- var barWidth = config.scale_width;
913
- var barHeight = 5;
914
- var points = getRange(config.padding_bottom, height, barHeight);
915
- var inverseScale = scaleSequential(target.colors)
916
- .domain([points[points.length - 1], points[0]]);
917
- if (this.colorScale) {
918
- this.colorScale.remove();
919
- }
920
- this.colorScale = $$.$el.svg.append("g")
921
- .attr("width", 50)
922
- .attr("height", height)
923
- .attr("class", CLASS.colorScale);
924
- this.colorScale.append("g")
925
- .attr("transform", "translate(0, ".concat(config.padding_top, ")"))
926
- .selectAll("bars")
927
- .data(points)
928
- .enter()
929
- .append("rect")
930
- .attr("y", function (d, i) { return i * barHeight; })
931
- .attr("x", 0)
932
- .attr("width", barWidth)
933
- .attr("height", barHeight)
934
- .attr("fill", function (d) { return inverseScale(d); });
935
- // Legend Axis
936
- var axisScale = scaleSymlog()
937
- .domain([target.minEpochs, target.maxEpochs])
938
- .range([
939
- points[0] + config.padding_top + points[points.length - 1] + barHeight - 1,
940
- points[0] + config.padding_top
941
- ]);
942
- var legendAxis = axisRight(axisScale);
943
- var scaleFormat = config.scale_format;
944
- if (scaleFormat === "pow10") {
945
- legendAxis.tickValues([1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]);
946
- }
947
- else if (isFunction(scaleFormat)) {
948
- legendAxis.tickFormat(scaleFormat);
949
- }
950
- else {
951
- legendAxis.tickFormat(format("d"));
952
- }
953
- // Draw Axis
954
- var axis = this.colorScale.append("g")
955
- .attr("class", "legend axis")
956
- .attr("transform", "translate(".concat(barWidth, ",0)"))
957
- .call(legendAxis);
958
- if (scaleFormat === "pow10") {
959
- axis.selectAll(".tick text")
960
- .text(null)
961
- .filter(function (d) { return d / Math.pow(10, Math.ceil(Math.log(d) / Math.LN10 - 1e-12)) === 1; }) // Power of Ten
962
- .text(10)
963
- .append("tspan")
964
- .attr("dy", "-.7em") // https://bl.ocks.org/mbostock/6738229
965
- .text(function (d) { return Math.round(Math.log(d) / Math.LN10); });
966
- }
967
- this.colorScale.attr("transform", "translate(".concat($$.state.current.width - this.xForColorScale(), ", 0)"));
968
- };
969
- ColorScale.prototype.xForColorScale = function () {
970
- return this.owner.config.padding_right +
971
- this.colorScale.node().getBBox().width;
972
- };
973
- ColorScale.prototype.getColorScalePadding = function () {
974
- return this.xForColorScale() + this.owner.config.padding_left + 20;
975
- };
976
- return ColorScale;
990
+ return Options;
977
991
  }());
978
992
 
979
993
  /**
@@ -1052,7 +1066,7 @@ var ColorScale = /** @class */ (function () {
1052
1066
  * ]
1053
1067
  * });
1054
1068
  * @example
1055
- * import {bb} from "billboard.js";
1069
+ * import {bb} from "billboard.js";
1056
1070
  * import Stanford from "billboard.js/dist/billboardjs-plugin-stanford";
1057
1071
  *
1058
1072
  * bb.generate({
@@ -1129,7 +1143,8 @@ var Stanford = /** @class */ (function (_super) {
1129
1143
  target.minEpochs = !isNaN(config.scale_min) ? config.scale_min : Math.min.apply(Math, epochs);
1130
1144
  target.maxEpochs = !isNaN(config.scale_max) ? config.scale_max : Math.max.apply(Math, epochs);
1131
1145
  target.colors = isFunction(config.colors) ?
1132
- config.colors : interpolateHslLong(hsl(250, 1, 0.5), hsl(0, 1, 0.5));
1146
+ config.colors :
1147
+ interpolateHslLong(hsl(250, 1, 0.5), hsl(0, 1, 0.5));
1133
1148
  target.colorscale = scaleSequentialLog(target.colors)
1134
1149
  .domain([target.minEpochs, target.maxEpochs]);
1135
1150
  };
@@ -1154,9 +1169,7 @@ var Stanford = /** @class */ (function (_super) {
1154
1169
  Stanford.prototype.countEpochsInRegion = function (region) {
1155
1170
  var $$ = this;
1156
1171
  var target = $$.data.targets[0];
1157
- var total = target.values.reduce(function (accumulator, currentValue) {
1158
- return accumulator + Number(currentValue.epochs);
1159
- }, 0);
1172
+ var total = target.values.reduce(function (accumulator, currentValue) { return accumulator + Number(currentValue.epochs); }, 0);
1160
1173
  var value = target.values.reduce(function (accumulator, currentValue) {
1161
1174
  if (pointInRegion(currentValue, region)) {
1162
1175
  return accumulator + Number(currentValue.epochs);
@@ -1169,6 +1182,6 @@ var Stanford = /** @class */ (function (_super) {
1169
1182
  };
1170
1183
  };
1171
1184
  return Stanford;
1172
- }(Plugin$1));
1185
+ }(Plugin));
1173
1186
 
1174
1187
  export { Stanford as default };