billboard.js 3.11.2 → 3.12.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 (171) hide show
  1. package/README.md +2 -6
  2. package/dist/billboard.css +5 -1
  3. package/dist/billboard.js +19431 -24292
  4. package/dist/billboard.min.css +2 -2
  5. package/dist/billboard.min.js +26 -3
  6. package/dist/billboard.pkgd.js +22301 -29057
  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 +423 -1134
  11. package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -3
  12. package/dist/plugin/billboardjs-plugin-stanford.js +660 -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 +339 -1324
  19. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +5 -3
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +1701 -3424
  21. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +7 -3
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2385 -4462
  23. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +18 -3
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +1783 -3467
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +33 -3
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2031 -3979
  27. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -3
  28. package/dist/theme/dark.css +5 -1
  29. package/dist/theme/dark.min.css +2 -2
  30. package/dist/theme/datalab.css +5 -1
  31. package/dist/theme/datalab.min.css +2 -2
  32. package/dist/theme/graph.css +5 -1
  33. package/dist/theme/graph.min.css +2 -2
  34. package/dist/theme/insight.css +5 -1
  35. package/dist/theme/insight.min.css +2 -2
  36. package/dist/theme/modern.css +5 -1
  37. package/dist/theme/modern.min.css +3 -4
  38. package/dist-esm/billboard.js +9051 -8666
  39. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +19 -25
  40. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +149 -148
  41. package/dist-esm/plugin/billboardjs-plugin-stanford.js +295 -286
  42. package/dist-esm/plugin/billboardjs-plugin-tableview.js +235 -234
  43. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +40 -41
  44. package/package.json +26 -46
  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 +5 -7
  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 +79 -51
  63. package/src/ChartInternal/data/IData.ts +22 -29
  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 +40 -23
  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 +54 -25
  70. package/src/ChartInternal/interactions/flow.ts +14 -4
  71. package/src/ChartInternal/interactions/interaction.ts +34 -12
  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 +5 -5
  76. package/src/ChartInternal/internals/clip.ts +9 -10
  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 +130 -47
  81. package/src/ChartInternal/internals/legend.ts +99 -66
  82. package/src/ChartInternal/internals/redraw.ts +3 -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 +97 -66
  88. package/src/ChartInternal/internals/style.ts +21 -19
  89. package/src/ChartInternal/internals/text.ts +64 -39
  90. package/src/ChartInternal/internals/title.ts +2 -2
  91. package/src/ChartInternal/internals/tooltip.ts +83 -34
  92. package/src/ChartInternal/internals/transform.ts +2 -2
  93. package/src/ChartInternal/internals/type.ts +12 -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/gauge.ts +16 -9
  100. package/src/ChartInternal/shape/line.ts +62 -46
  101. package/src/ChartInternal/shape/point.common.ts +1 -4
  102. package/src/ChartInternal/shape/point.ts +52 -32
  103. package/src/ChartInternal/shape/polar.ts +4 -2
  104. package/src/ChartInternal/shape/radar.ts +40 -22
  105. package/src/ChartInternal/shape/shape.ts +84 -58
  106. package/src/ChartInternal/shape/treemap.ts +29 -20
  107. package/src/Plugin/bubblecompare/index.ts +1 -3
  108. package/src/Plugin/sparkline/index.ts +3 -4
  109. package/src/Plugin/stanford/ColorScale.ts +3 -2
  110. package/src/Plugin/stanford/Elements.ts +15 -6
  111. package/src/Plugin/stanford/Options.ts +5 -5
  112. package/src/Plugin/stanford/index.ts +13 -9
  113. package/src/Plugin/tableview/Options.ts +1 -1
  114. package/src/Plugin/tableview/const.ts +1 -4
  115. package/src/Plugin/tableview/index.ts +11 -9
  116. package/src/Plugin/textoverlap/index.ts +4 -6
  117. package/src/config/Options/Options.ts +3 -3
  118. package/src/config/Options/axis/axis.ts +36 -0
  119. package/src/config/Options/axis/x.ts +12 -13
  120. package/src/config/Options/axis/y.ts +13 -13
  121. package/src/config/Options/axis/y2.ts +23 -10
  122. package/src/config/Options/common/color.ts +4 -4
  123. package/src/config/Options/common/grid.ts +4 -4
  124. package/src/config/Options/common/legend.ts +13 -14
  125. package/src/config/Options/common/main.ts +23 -23
  126. package/src/config/Options/common/point.ts +17 -18
  127. package/src/config/Options/common/title.ts +2 -2
  128. package/src/config/Options/common/tooltip.ts +13 -11
  129. package/src/config/Options/data/axis.ts +2 -2
  130. package/src/config/Options/data/data.ts +45 -45
  131. package/src/config/Options/interaction/interaction.ts +1 -1
  132. package/src/config/Options/interaction/subchart.ts +2 -2
  133. package/src/config/Options/interaction/zoom.ts +9 -9
  134. package/src/config/Options/shape/arc.ts +10 -13
  135. package/src/config/Options/shape/area.ts +5 -7
  136. package/src/config/Options/shape/bar.ts +8 -10
  137. package/src/config/Options/shape/bubble.ts +1 -1
  138. package/src/config/Options/shape/candlestick.ts +2 -2
  139. package/src/config/Options/shape/donut.ts +4 -4
  140. package/src/config/Options/shape/gauge.ts +6 -6
  141. package/src/config/Options/shape/line.ts +3 -3
  142. package/src/config/Options/shape/pie.ts +5 -5
  143. package/src/config/Options/shape/polar.ts +3 -3
  144. package/src/config/Options/shape/radar.ts +2 -2
  145. package/src/config/Options/shape/scatter.ts +1 -1
  146. package/src/config/Options/shape/treemap.ts +1 -1
  147. package/src/config/Store/Element.ts +8 -5
  148. package/src/config/Store/State.ts +19 -13
  149. package/src/config/classes.ts +6 -4
  150. package/src/config/config.ts +1 -1
  151. package/src/config/resolver/axis.ts +4 -4
  152. package/src/config/resolver/interaction.ts +3 -7
  153. package/src/config/resolver/shape.ts +11 -12
  154. package/src/core.ts +2 -3
  155. package/src/index.esm.ts +2 -6
  156. package/src/index.ts +2 -2
  157. package/src/module/Cache.ts +2 -3
  158. package/src/module/browser.ts +15 -10
  159. package/src/module/error.ts +9 -8
  160. package/src/module/generator.ts +3 -5
  161. package/src/module/util.ts +60 -37
  162. package/src/module/worker.ts +14 -11
  163. package/src/scss/billboard.scss +6 -0
  164. package/src/scss/theme/dark.scss +6 -0
  165. package/src/scss/theme/datalab.scss +6 -0
  166. package/src/scss/theme/graph.scss +6 -0
  167. package/src/scss/theme/insight.scss +6 -0
  168. package/src/scss/theme/modern.scss +6 -0
  169. package/types/axis.d.ts +7 -0
  170. package/types/options.d.ts +7 -0
  171. package/types/options.shape.d.ts +7 -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.2
8
+ * @version 3.12.0-next.1
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",
@@ -162,7 +163,7 @@ var $EVENT = {
162
163
  eventRect: "bb-event-rect",
163
164
  eventRects: "bb-event-rects",
164
165
  eventRectsMultiple: "bb-event-rects-multiple",
165
- eventRectsSingle: "bb-event-rects-single",
166
+ eventRectsSingle: "bb-event-rects-single"
166
167
  };
167
168
  var $FOCUS = {
168
169
  focused: "bb-focused",
@@ -198,7 +199,7 @@ var $SELECT = {
198
199
  };
199
200
  var $SHAPE = {
200
201
  shape: "bb-shape",
201
- shapes: "bb-shapes",
202
+ shapes: "bb-shapes"
202
203
  };
203
204
  var $SUBCHART = {
204
205
  brush: "bb-brush",
@@ -226,7 +227,7 @@ var $ZOOM = {
226
227
  buttonZoomReset: "bb-zoom-reset",
227
228
  zoomBrush: "bb-zoom-brush"
228
229
  };
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);
230
+ __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);
230
231
 
231
232
  /**
232
233
  * Copyright (c) 2017 ~ present NAVER Corp.
@@ -243,7 +244,8 @@ _assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(_assign(
243
244
  * @private
244
245
  */
245
246
  function getGlobal() {
246
- return (typeof globalThis === "object" && globalThis !== null && globalThis.Object === Object && globalThis) ||
247
+ return (typeof globalThis === "object" && globalThis !== null && globalThis.Object === Object &&
248
+ globalThis) ||
247
249
  (typeof global === "object" && global !== null && global.Object === Object && global) ||
248
250
  (typeof self === "object" && self !== null && self.Object === Object && self) ||
249
251
  Function("return this")();
@@ -299,8 +301,7 @@ function mergeObj(target) {
299
301
  target[key] = mergeObj(target[key], value);
300
302
  }
301
303
  else {
302
- target[key] = isArray(value) ?
303
- value.concat() : value;
304
+ target[key] = isArray(value) ? value.concat() : value;
304
305
  }
305
306
  });
306
307
  }
@@ -327,7 +328,12 @@ var getRange = function (start, end, step) {
327
328
  ({
328
329
  mouse: (function () {
329
330
  var getParams = function () { return ({
330
- bubbles: false, cancelable: false, screenX: 0, screenY: 0, clientX: 0, clientY: 0
331
+ bubbles: false,
332
+ cancelable: false,
333
+ screenX: 0,
334
+ screenY: 0,
335
+ clientX: 0,
336
+ clientY: 0
331
337
  }); };
332
338
  try {
333
339
  // eslint-disable-next-line no-new
@@ -397,10 +403,6 @@ function parseDate(date) {
397
403
  return parsedDate;
398
404
  }
399
405
 
400
- /**
401
- * Copyright (c) 2017 ~ present NAVER Corp.
402
- * billboard.js project is licensed under the MIT license
403
- */
404
406
  /**
405
407
  * Load configuration option
406
408
  * @param {object} config User's generation config value
@@ -494,157 +496,11 @@ var Plugin = /** @class */ (function () {
494
496
  delete _this[key];
495
497
  });
496
498
  };
497
- Plugin.version = "3.11.2";
499
+ Plugin.version = "3.12.0-next.1";
498
500
  return Plugin;
499
501
  }());
500
502
  var Plugin$1 = Plugin;
501
503
 
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
-
648
504
  /**
649
505
  * Copyright (c) 2017 ~ present NAVER Corp.
650
506
  * billboard.js project is licensed under the MIT license
@@ -752,6 +608,91 @@ function getCentroid(points) {
752
608
  };
753
609
  }
754
610
 
611
+ /**
612
+ * Copyright (c) 2017 ~ present NAVER Corp.
613
+ * billboard.js project is licensed under the MIT license
614
+ */
615
+ /**
616
+ * Stanford diagram plugin color scale class
617
+ * @class ColorScale
618
+ * @param {Stanford} owner Stanford instance
619
+ * @private
620
+ */
621
+ var ColorScale = /** @class */ (function () {
622
+ function ColorScale(owner) {
623
+ this.owner = owner;
624
+ }
625
+ ColorScale.prototype.drawColorScale = function () {
626
+ var _a = this.owner, $$ = _a.$$, config = _a.config;
627
+ var target = $$.data.targets[0];
628
+ var height = $$.state.height - config.padding_bottom - config.padding_top;
629
+ var barWidth = config.scale_width;
630
+ var barHeight = 5;
631
+ var points = getRange(config.padding_bottom, height, barHeight);
632
+ var inverseScale = scaleSequential(target.colors)
633
+ .domain([points[points.length - 1], points[0]]);
634
+ if (this.colorScale) {
635
+ this.colorScale.remove();
636
+ }
637
+ this.colorScale = $$.$el.svg.append("g")
638
+ .attr("width", 50)
639
+ .attr("height", height)
640
+ .attr("class", CLASS.colorScale);
641
+ this.colorScale.append("g")
642
+ .attr("transform", "translate(0, ".concat(config.padding_top, ")"))
643
+ .selectAll("bars")
644
+ .data(points)
645
+ .enter()
646
+ .append("rect")
647
+ .attr("y", function (d, i) { return i * barHeight; })
648
+ .attr("x", 0)
649
+ .attr("width", barWidth)
650
+ .attr("height", barHeight)
651
+ .attr("fill", function (d) { return inverseScale(d); });
652
+ // Legend Axis
653
+ var axisScale = scaleSymlog()
654
+ .domain([target.minEpochs, target.maxEpochs])
655
+ .range([
656
+ points[0] + config.padding_top + points[points.length - 1] + barHeight - 1,
657
+ points[0] + config.padding_top
658
+ ]);
659
+ var legendAxis = axisRight(axisScale);
660
+ var scaleFormat = config.scale_format;
661
+ if (scaleFormat === "pow10") {
662
+ legendAxis.tickValues([1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]);
663
+ }
664
+ else if (isFunction(scaleFormat)) {
665
+ legendAxis.tickFormat(scaleFormat);
666
+ }
667
+ else {
668
+ legendAxis.tickFormat(format("d"));
669
+ }
670
+ // Draw Axis
671
+ var axis = this.colorScale.append("g")
672
+ .attr("class", "legend axis")
673
+ .attr("transform", "translate(".concat(barWidth, ",0)"))
674
+ .call(legendAxis);
675
+ if (scaleFormat === "pow10") {
676
+ axis.selectAll(".tick text")
677
+ .text(null)
678
+ .filter(function (d) { return d / Math.pow(10, Math.ceil(Math.log(d) / Math.LN10 - 1e-12)) === 1; }) // Power of Ten
679
+ .text(10)
680
+ .append("tspan")
681
+ .attr("dy", "-.7em") // https://bl.ocks.org/mbostock/6738229
682
+ .text(function (d) { return Math.round(Math.log(d) / Math.LN10); });
683
+ }
684
+ this.colorScale.attr("transform", "translate(".concat($$.state.current.width - this.xForColorScale(), ", 0)"));
685
+ };
686
+ ColorScale.prototype.xForColorScale = function () {
687
+ return this.owner.config.padding_right +
688
+ this.colorScale.node().getBBox().width;
689
+ };
690
+ ColorScale.prototype.getColorScalePadding = function () {
691
+ return this.xForColorScale() + this.owner.config.padding_left + 20;
692
+ };
693
+ return ColorScale;
694
+ }());
695
+
755
696
  /**
756
697
  * Copyright (c) 2017 ~ present NAVER Corp.
757
698
  * billboard.js project is licensed under the MIT license
@@ -842,17 +783,25 @@ var Elements = /** @class */ (function () {
842
783
  .select("polygon")
843
784
  .transition()
844
785
  .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(" "); })
786
+ .attr("points", function (d) {
787
+ return d.points.map(function (value) {
788
+ return [
789
+ isRotated ? yvCustom(value, "y") : xvCustom(value, "x"),
790
+ isRotated ? xvCustom(value, "x") : yvCustom(value, "y")
791
+ ].join(",");
792
+ }).join(" ");
793
+ })
849
794
  .transition()
850
795
  .style("opacity", function (d) { return String(d.opacity ? d.opacity : 0.2); });
851
796
  stanfordRegion.select("text")
852
797
  .transition()
853
798
  .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")); })
799
+ .attr("x", function (d) { return (isRotated ?
800
+ yvCustom(getCentroid(d.points), "y") :
801
+ xvCustom(getCentroid(d.points), "x")); })
802
+ .attr("y", function (d) { return (isRotated ?
803
+ xvCustom(getCentroid(d.points), "x") :
804
+ yvCustom(getCentroid(d.points), "y")); })
856
805
  .text(function (d) {
857
806
  if (d.text) {
858
807
  var _a = countPointsInRegion(d.points), value = _a.value, percentage = _a.percentage;
@@ -896,84 +845,145 @@ var Elements = /** @class */ (function () {
896
845
  * billboard.js project is licensed under the MIT license
897
846
  */
898
847
  /**
899
- * Stanford diagram plugin color scale class
900
- * @class ColorScale
901
- * @param {Stanford} owner Stanford instance
848
+ * Stanford diagram plugin option class
849
+ * @class StanfordOptions
850
+ * @param {Options} options Stanford plugin options
851
+ * @augments Plugin
852
+ * @returns {StanfordOptions}
902
853
  * @private
903
854
  */
904
- var ColorScale = /** @class */ (function () {
905
- function ColorScale(owner) {
906
- this.owner = owner;
855
+ var Options = /** @class */ (function () {
856
+ function Options() {
857
+ return {
858
+ /**
859
+ * Set the color of the color scale. This function receives a value between 0 and 1, and should return a color.
860
+ * @name colors
861
+ * @memberof plugin-stanford
862
+ * @type {Function}
863
+ * @default undefined
864
+ * @example
865
+ * colors: d3.interpolateHslLong(
866
+ * d3.hsl(250, 1, 0.5), d3.hsl(0, 1, 0.5)
867
+ * )
868
+ */
869
+ colors: undefined,
870
+ /**
871
+ * Specify the key of epochs values in the data.
872
+ * @name epochs
873
+ * @memberof plugin-stanford
874
+ * @type {Array}
875
+ * @default []
876
+ * @example
877
+ * epochs: [ 1, 1, 2, 2, ... ]
878
+ */
879
+ epochs: [],
880
+ /**
881
+ * Show additional lines anywhere on the chart.
882
+ * - Each line object should consist with following options:
883
+ *
884
+ * | Key | Type | Description |
885
+ * | --- | --- | --- |
886
+ * | x1 | Number | Starting position on the x axis |
887
+ * | y1 | Number | Starting position on the y axis |
888
+ * | x2 | Number | Ending position on the x axis |
889
+ * | y2 | Number | Ending position on the y axis |
890
+ * | class | String | Optional value. Set a custom css class to this line. |
891
+ * @type {Array}
892
+ * @memberof plugin-stanford
893
+ * @default []
894
+ * @example
895
+ * lines: [
896
+ * { x1: 0, y1: 0, x2: 65, y2: 65, class: "line1" },
897
+ * { x1: 0, x2: 65, y1: 40, y2: 40, class: "line2" }
898
+ * ]
899
+ */
900
+ lines: [],
901
+ /**
902
+ * Set scale values
903
+ * @name scale
904
+ * @memberof plugin-stanford
905
+ * @type {object}
906
+ * @property {object} [scale] scale object
907
+ * @property {number} [scale.min=undefined] Minimum value of the color scale. Default: lowest value in epochs
908
+ * @property {number} [scale.max=undefined] Maximum value of the color scale. Default: highest value in epochs
909
+ * @property {number} [scale.width=20] Width of the color scale
910
+ * @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")
911
+ * @example
912
+ * scale: {
913
+ * max: 10000,
914
+ * min: 1,
915
+ * width: 500,
916
+ *
917
+ * // specify 'pow10' to format as powers of 10
918
+ * format: "pow10",
919
+ *
920
+ * // or specify a format function
921
+ * format: function(x) {
922
+ * return x +"%";
923
+ * }
924
+ * },
925
+ */
926
+ scale_min: undefined,
927
+ scale_max: undefined,
928
+ scale_width: 20,
929
+ scale_format: undefined,
930
+ /**
931
+ * The padding for color scale element
932
+ * @name padding
933
+ * @memberof plugin-stanford
934
+ * @type {object}
935
+ * @property {object} [padding] padding object
936
+ * @property {number} [padding.top=0] Top padding value.
937
+ * @property {number} [padding.right=0] Right padding value.
938
+ * @property {number} [padding.bottom=0] Bottom padding value.
939
+ * @property {number} [padding.left=0] Left padding value.
940
+ * @example
941
+ * padding: {
942
+ * top: 15,
943
+ * right: 0,
944
+ * bottom: 0,
945
+ * left: 0
946
+ * },
947
+ */
948
+ padding_top: 0,
949
+ padding_right: 0,
950
+ padding_bottom: 0,
951
+ padding_left: 0,
952
+ /**
953
+ * Show additional regions anywhere on the chart.
954
+ * - Each region object should consist with following options:
955
+ *
956
+ * | Key | Type | Default | Attributes | Description |
957
+ * | --- | --- | --- | --- | --- |
958
+ * | 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. |
959
+ * | opacity | Number | `0.2` | &lt;optional> | Sets the opacity of the region as value between 0 and 1 |
960
+ * | 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. |
961
+ * | class | String | | &lt;optional> | Se a custom css class to this region, use the fill property in css to set a background color. |
962
+ * @name regions
963
+ * @memberof plugin-stanford
964
+ * @type {Array}
965
+ * @default []
966
+ * @example
967
+ * regions: [
968
+ * {
969
+ * points: [ // add points counter-clockwise
970
+ * { x: 0, y: 0 },
971
+ * { x: 40, y: 40 },
972
+ * { x: 0, y: 40 },
973
+ * ],
974
+ * text: function (value, percentage) {
975
+ * return `Normal Operations: ${value} (${percentage}%)`;
976
+ * },
977
+ * opacity: 0.2, // 0 to 1
978
+ * class: "test-polygon1"
979
+ * },
980
+ * ...
981
+ * ]
982
+ */
983
+ regions: []
984
+ };
907
985
  }
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;
986
+ return Options;
977
987
  }());
978
988
 
979
989
  /**
@@ -1052,7 +1062,7 @@ var ColorScale = /** @class */ (function () {
1052
1062
  * ]
1053
1063
  * });
1054
1064
  * @example
1055
- * import {bb} from "billboard.js";
1065
+ * import {bb} from "billboard.js";
1056
1066
  * import Stanford from "billboard.js/dist/billboardjs-plugin-stanford";
1057
1067
  *
1058
1068
  * bb.generate({
@@ -1129,7 +1139,8 @@ var Stanford = /** @class */ (function (_super) {
1129
1139
  target.minEpochs = !isNaN(config.scale_min) ? config.scale_min : Math.min.apply(Math, epochs);
1130
1140
  target.maxEpochs = !isNaN(config.scale_max) ? config.scale_max : Math.max.apply(Math, epochs);
1131
1141
  target.colors = isFunction(config.colors) ?
1132
- config.colors : interpolateHslLong(hsl(250, 1, 0.5), hsl(0, 1, 0.5));
1142
+ config.colors :
1143
+ interpolateHslLong(hsl(250, 1, 0.5), hsl(0, 1, 0.5));
1133
1144
  target.colorscale = scaleSequentialLog(target.colors)
1134
1145
  .domain([target.minEpochs, target.maxEpochs]);
1135
1146
  };
@@ -1154,9 +1165,7 @@ var Stanford = /** @class */ (function (_super) {
1154
1165
  Stanford.prototype.countEpochsInRegion = function (region) {
1155
1166
  var $$ = this;
1156
1167
  var target = $$.data.targets[0];
1157
- var total = target.values.reduce(function (accumulator, currentValue) {
1158
- return accumulator + Number(currentValue.epochs);
1159
- }, 0);
1168
+ var total = target.values.reduce(function (accumulator, currentValue) { return accumulator + Number(currentValue.epochs); }, 0);
1160
1169
  var value = target.values.reduce(function (accumulator, currentValue) {
1161
1170
  if (pointInRegion(currentValue, region)) {
1162
1171
  return accumulator + Number(currentValue.epochs);