billboard.js 3.6.3 → 3.7.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 (91) hide show
  1. package/dist/billboard.css +6 -1
  2. package/dist/billboard.js +1704 -843
  3. package/dist/billboard.min.css +2 -2
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +3819 -2263
  6. package/dist/billboard.pkgd.min.js +6 -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 +62 -23
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +62 -23
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +48 -14
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +48 -14
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +1087 -1031
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +1171 -1112
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +1222 -1169
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +1159 -1105
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +1365 -1319
  22. package/dist/theme/datalab.css +6 -1
  23. package/dist/theme/datalab.min.css +2 -2
  24. package/dist/theme/graph.css +6 -1
  25. package/dist/theme/graph.min.css +2 -2
  26. package/dist/theme/insight.css +6 -1
  27. package/dist/theme/insight.min.css +2 -2
  28. package/dist-esm/billboard.js +942 -277
  29. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +3 -5
  30. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +10 -9
  31. package/dist-esm/plugin/billboardjs-plugin-stanford.js +10 -9
  32. package/dist-esm/plugin/billboardjs-plugin-tableview.js +4 -8
  33. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +3 -5
  34. package/package.json +44 -38
  35. package/src/Chart/api/chart.ts +13 -4
  36. package/src/Chart/api/export.ts +159 -14
  37. package/src/Chart/api/legend.ts +1 -0
  38. package/src/Chart/api/load.ts +1 -0
  39. package/src/Chart/api/tooltip.ts +11 -2
  40. package/src/ChartInternal/Axis/Axis.ts +1 -1
  41. package/src/ChartInternal/ChartInternal.ts +35 -25
  42. package/src/ChartInternal/data/IData.ts +9 -0
  43. package/src/ChartInternal/data/convert.helper.ts +35 -21
  44. package/src/ChartInternal/data/data.ts +26 -5
  45. package/src/ChartInternal/data/load.ts +3 -0
  46. package/src/ChartInternal/interactions/interaction.ts +42 -33
  47. package/src/ChartInternal/internals/class.ts +3 -4
  48. package/src/ChartInternal/internals/clip.ts +13 -10
  49. package/src/ChartInternal/internals/domain.ts +11 -4
  50. package/src/ChartInternal/internals/format.ts +1 -1
  51. package/src/ChartInternal/internals/grid.ts +1 -1
  52. package/src/ChartInternal/internals/legend.ts +3 -2
  53. package/src/ChartInternal/internals/redraw.ts +12 -5
  54. package/src/ChartInternal/internals/scale.ts +7 -2
  55. package/src/ChartInternal/internals/size.ts +41 -26
  56. package/src/ChartInternal/internals/text.ts +60 -32
  57. package/src/ChartInternal/internals/tooltip.ts +12 -8
  58. package/src/ChartInternal/internals/transform.ts +2 -2
  59. package/src/ChartInternal/internals/type.ts +6 -1
  60. package/src/ChartInternal/shape/arc.ts +145 -68
  61. package/src/ChartInternal/shape/area.ts +3 -0
  62. package/src/ChartInternal/shape/bar.ts +4 -1
  63. package/src/ChartInternal/shape/line.ts +12 -15
  64. package/src/ChartInternal/shape/radar.ts +2 -2
  65. package/src/ChartInternal/shape/shape.ts +10 -5
  66. package/src/ChartInternal/shape/treemap.ts +293 -0
  67. package/src/config/Options/common/tooltip.ts +11 -8
  68. package/src/config/Options/data/data.ts +6 -3
  69. package/src/config/Options/shape/arc.ts +47 -0
  70. package/src/config/Options/shape/gauge.ts +2 -2
  71. package/src/config/Options/shape/pie.ts +1 -1
  72. package/src/config/Options/shape/polar.ts +1 -1
  73. package/src/config/Options/shape/radar.ts +1 -1
  74. package/src/config/Options/shape/spline.ts +1 -1
  75. package/src/config/Options/shape/treemap.ts +53 -0
  76. package/src/config/Store/State.ts +1 -0
  77. package/src/config/classes.ts +7 -0
  78. package/src/config/const.ts +4 -2
  79. package/src/config/resolver/shape.ts +22 -5
  80. package/src/index.esm.ts +2 -1
  81. package/src/module/util.ts +1 -1
  82. package/src/scss/billboard.scss +6 -0
  83. package/src/scss/theme/datalab.scss +6 -0
  84. package/src/scss/theme/graph.scss +6 -0
  85. package/src/scss/theme/insight.scss +6 -0
  86. package/types/bb.d.ts +1 -0
  87. package/types/chart.d.ts +7 -0
  88. package/types/index.d.ts +1 -0
  89. package/types/options.d.ts +42 -624
  90. package/types/options.shape.d.ts +664 -0
  91. package/types/types.d.ts +4 -3
@@ -209,7 +209,6 @@ export default {
209
209
  const {config} = $$;
210
210
  const isRotated = config.axis_rotated;
211
211
  const isTimeSeries = $$.axis.isTimeSeries();
212
- const xOffset = $$.axis.isCategorized() ? 0.5 : 0;
213
212
  const regions: any[] = [];
214
213
  const dasharray = "2 2"; // default value
215
214
 
@@ -218,17 +217,6 @@ export default {
218
217
  let diff;
219
218
  let diffx2;
220
219
 
221
- // check weather data is within region
222
- const isWithinRegions = (withinX, withinRegions) => {
223
- for (let i = 0, reg; (reg = withinRegions[i]); i++) {
224
- if (reg.start < withinX && withinX <= reg.end) {
225
- return reg.style;
226
- }
227
- }
228
-
229
- return false;
230
- };
231
-
232
220
  // Check start/end of regions
233
221
  if (isDefined(_regions)) {
234
222
  const getValue = (v: Date | any, def: number): Date | any => (
@@ -250,7 +238,6 @@ export default {
250
238
 
251
239
  // Define svg generator function for region
252
240
  const generateM = points => `M${points[0][0]},${points[0][1]}L${points[1][0]},${points[1][1]}`;
253
-
254
241
  const sWithRegion = isTimeSeries ? (d0, d1, k, timeseriesDiff) => {
255
242
  const x0 = d0.x.getTime();
256
243
  const xDiff = d1.x - d0.x;
@@ -277,7 +264,7 @@ export default {
277
264
  for (let i = 0, data; (data = d[i]); i++) {
278
265
  const prevData = d[i - 1];
279
266
  const hasPrevData = prevData && isValue(prevData.value);
280
- let style = isWithinRegions(data.x, regions);
267
+ let style = $$.isWithinRegions(data.x, regions);
281
268
 
282
269
  // https://github.com/naver/billboard.js/issues/1172
283
270
  if (!isValue(data.value)) {
@@ -295,7 +282,7 @@ export default {
295
282
  }
296
283
 
297
284
  // Draw with region // TODO: Fix for horizotal charts
298
- xp = getScale(axisType.x, prevData.x + xOffset, data.x + xOffset);
285
+ xp = getScale(axisType.x, prevData.x, data.x);
299
286
  yp = getScale(axisType.y, prevData.value, data.value);
300
287
 
301
288
  const dx = x(data.x) - x(prevData.x);
@@ -319,6 +306,16 @@ export default {
319
306
  return path;
320
307
  },
321
308
 
309
+ isWithinRegions(withinX, withinRegions): boolean {
310
+ for (let i = 0, reg; (reg = withinRegions[i]); i++) {
311
+ if (reg.start < withinX && withinX <= reg.end) {
312
+ return reg.style;
313
+ }
314
+ }
315
+
316
+ return false;
317
+ },
318
+
322
319
  isWithinStep(that, y: number): boolean {
323
320
  return Math.abs(y - getPointer(this.state.event, that)[1]) < 30;
324
321
  },
@@ -290,10 +290,10 @@ export default {
290
290
  });
291
291
  }
292
292
 
293
- $$.bindEvent();
293
+ $$.bindRadarEvent();
294
294
  },
295
295
 
296
- bindEvent(): void {
296
+ bindRadarEvent(): void {
297
297
  const $$ = this;
298
298
  const {config, state, $el: {radar, svg}} = $$;
299
299
  const focusOnly = config.point_focus_only;
@@ -48,10 +48,10 @@ export default {
48
48
 
49
49
  const $$ = this;
50
50
  const isRotated = $$.config.axis_rotated;
51
- const {hasRadar} = $$.state;
51
+ const {hasRadar, hasTreemap} = $$.state;
52
52
  const shape = {type: <TShape>{}, indices: <TShape>{}, pos: {}};
53
53
 
54
- ["bar", "candlestick", "line", "area"].forEach(v => {
54
+ !hasTreemap && ["bar", "candlestick", "line", "area"].forEach(v => {
55
55
  const name = capitalize(/^(bubble|scatter)$/.test(v) ? "line" : v);
56
56
 
57
57
  if ($$.hasType(v) || $$.hasTypeOf(name) || (
@@ -65,10 +65,15 @@ export default {
65
65
  }
66
66
  });
67
67
 
68
- if (!$$.hasArcType() || hasRadar) {
68
+ if (!$$.hasArcType() || hasRadar || hasTreemap) {
69
+ let cx;
70
+ let cy;
71
+
69
72
  // generate circle x/y functions depending on updated params
70
- const cx = hasRadar ? $$.radarCircleX : (isRotated ? $$.circleY : $$.circleX);
71
- const cy = hasRadar ? $$.radarCircleY : (isRotated ? $$.circleX : $$.circleY);
73
+ if (!hasTreemap) {
74
+ cx = hasRadar ? $$.radarCircleX : (isRotated ? $$.circleY : $$.circleX);
75
+ cy = hasRadar ? $$.radarCircleY : (isRotated ? $$.circleX : $$.circleY);
76
+ }
72
77
 
73
78
  shape.pos = {
74
79
  xForText: $$.generateXYForText(shape.indices, true),
@@ -0,0 +1,293 @@
1
+ /**
2
+ * Copyright (c) 2017 ~ present NAVER Corp.
3
+ * billboard.js project is licensed under the MIT license
4
+ */
5
+ import {
6
+ hierarchy as d3Hierarchy,
7
+ treemap as d3Treemap,
8
+ treemapBinary as d3TreemapBinary,
9
+ treemapDice as d3TreemapDice,
10
+ treemapSlice as d3TreemapSlice,
11
+ treemapSliceDice as d3TreemapSliceDice,
12
+ treemapSquarify as d3TreemapSquarify,
13
+ treemapResquarify as d3TreemapResquarify
14
+ } from "d3-hierarchy";
15
+ import {select as d3Select} from "d3-selection";
16
+ import type {d3Selection} from "../../../types/types";
17
+ import {$COMMON, $TREEMAP} from "../../config/classes";
18
+ import {isFunction, getRandom} from "../../module/util";
19
+ import type {ITreemapData, IData, IDataRow} from "../data/IData";
20
+
21
+ /**
22
+ * Get treemap elements' position
23
+ * @param {d3Selection} group Root selection
24
+ * @param {object} root Root data
25
+ * @private
26
+ */
27
+ function position(group, root): void {
28
+ const $$ = this;
29
+ const {scale: {x, y}, state: {width}} = $$;
30
+
31
+ group.selectAll("g")
32
+ .attr("transform", d => (
33
+ `translate(${d === root ? "0,0" : `${x(d.x0)},${y(d.y0)}`})`
34
+ ))
35
+ .select("rect")
36
+ .attr("width", d => (
37
+ d === root ? width : x(d.x1) - x(d.x0))
38
+ )
39
+ .attr("height", d => (
40
+ d === root ? 0 : y(d.y1) - y(d.y0))
41
+ );
42
+ }
43
+
44
+ /**
45
+ * Convert data for treemap hierarchy
46
+ * @param {object} data Data object
47
+ * @returns {Array} Array of data for treemap hierarchy
48
+ * @private
49
+ */
50
+ function convertDataToTreemapData(data: IData[]): ITreemapData[] {
51
+ const $$ = this;
52
+
53
+ return data.map(d => {
54
+ const {id, values} = d;
55
+ const {value} = values[0];
56
+
57
+ return {
58
+ name: id,
59
+ id, // needed to keep compatibility on whole code logic
60
+ value,
61
+ ratio: $$.getRatio("treemap", values[0])
62
+ } as ITreemapData;
63
+ });
64
+ }
65
+
66
+ export default {
67
+ initTreemap(): void {
68
+ const $$ = this;
69
+ const {$el, state: {current: {width, height}, clip}} = $$;
70
+ const clipId = clip.id;
71
+
72
+ $$.treemap = d3Treemap()
73
+ .tile($$.getTreemapTile());
74
+
75
+ $$.treemapFn = data => {
76
+ const hierarchyData = d3Hierarchy(data).sum(d => d.value);
77
+ const sortFn = $$.getSortCompareFn(true);
78
+
79
+ return $$.treemap(
80
+ sortFn ? hierarchyData.sort(sortFn) : hierarchyData
81
+ );
82
+ };
83
+
84
+ $el.defs
85
+ .append("clipPath")
86
+ .attr("id", clipId)
87
+ .append("rect")
88
+ .attr("width", width)
89
+ .attr("height", height);
90
+
91
+ $el.treemap = $el.main.select(`.${$COMMON.chart}`)
92
+ .attr("clip-path", `url(#${clipId})`)
93
+ .append("g")
94
+ .classed($TREEMAP.chartTreemaps, true);
95
+
96
+ $$.bindTreemapEvent();
97
+ },
98
+
99
+ /**
100
+ * Bind events
101
+ * @private
102
+ */
103
+ bindTreemapEvent(): void {
104
+ const $$ = this;
105
+ const {$el, config, state} = $$;
106
+ const getTarget = event => {
107
+ const target = event.isTrusted ? event.target : state.eventReceiver.rect?.node();
108
+ let data;
109
+
110
+ if (/^rect$/i.test(target.tagName)) {
111
+ state.event = event;
112
+ data = d3Select(target).datum();
113
+ }
114
+
115
+ return data?.data;
116
+ };
117
+
118
+ if (config.interaction_enabled) {
119
+ const isTouch = state.inputType === "touch";
120
+
121
+ $el.treemap
122
+ .on(isTouch ? "touchstart" : "mousemove", event => {
123
+ const data = getTarget(event);
124
+
125
+ if (data) {
126
+ $$.showTooltip([data], event.currentTarget);
127
+ event.type === "mouseover" && $$.setOverOut(true, data);
128
+ }
129
+ })
130
+ .on(isTouch ? "touchend" : "mouseout", event => {
131
+ const data = getTarget(event);
132
+
133
+ $$.hideTooltip();
134
+ $$.setOverOut(false, data);
135
+ });
136
+ }
137
+ },
138
+
139
+ /**
140
+ * Get tiling function
141
+ * @returns {Function}
142
+ * @private
143
+ */
144
+ getTreemapTile() {
145
+ const $$ = this;
146
+ const {config, state: {current: {width, height}}} = $$;
147
+ const tile = {
148
+ "binary": d3TreemapBinary,
149
+ "dice": d3TreemapDice,
150
+ "slice": d3TreemapSlice,
151
+ "sliceDice": d3TreemapSliceDice,
152
+ "squarify": d3TreemapSquarify,
153
+ "resquarify": d3TreemapResquarify
154
+ }[config.treemap_tile ?? "binary"] ?? d3TreemapBinary;
155
+
156
+ return (node, x0, y0, x1, y1) => {
157
+ tile(node, 0, 0, width, height);
158
+
159
+ for (const child of node.children) {
160
+ child.x0 = x0 + child.x0 / width * (x1 - x0);
161
+ child.x1 = x0 + child.x1 / width * (x1 - x0);
162
+ child.y0 = y0 + child.y0 / height * (y1 - y0);
163
+ child.y1 = y0 + child.y1 / height * (y1 - y0);
164
+ }
165
+ };
166
+ },
167
+
168
+ /**
169
+ * Get treemap hierarchy data
170
+ * @param {Array} targets Data targets
171
+ * @returns {object}
172
+ * @private
173
+ */
174
+ getTreemapData(targets: IData[]): ITreemapData {
175
+ const $$ = this;
176
+
177
+ return {
178
+ name: "root",
179
+ children: convertDataToTreemapData.bind($$)(
180
+ $$.filterTargetsToShow(targets.filter($$.isTreemapType, $$))
181
+ )
182
+ };
183
+ },
184
+
185
+ /**
186
+ * Update treemap data
187
+ * @param {Array} targets Data targets
188
+ * @private
189
+ */
190
+ updateTargetsForTreemap(targets: IData): void {
191
+ const $$ = this;
192
+ const {$el: {treemap}} = $$;
193
+ const treemapData = $$.treemapFn($$.getTreemapData(targets ?? $$.data.targets));
194
+
195
+ // using $el.treemap reference can alter data, so select treemap <g> again
196
+ treemap.data(treemapData);
197
+ },
198
+
199
+ /**
200
+ * Render treemap
201
+ * @param {number} durationForExit Duration for exit transition
202
+ * @private
203
+ */
204
+ updateTreemap(durationForExit: number): void {
205
+ const $$ = this;
206
+ const {$el, $T} = $$;
207
+ const data = $el.treemap.datum();
208
+ const classChartTreemap = $$.getChartClass("Treemap");
209
+
210
+ const treemap = $el.treemap
211
+ .selectAll("g")
212
+ .data(data.children);
213
+
214
+ $T(treemap.exit(), durationForExit)
215
+ .style("opacity", "0")
216
+ .remove();
217
+
218
+ treemap.enter()
219
+ .append("g")
220
+ .append("rect");
221
+
222
+ $el.treemap.selectAll("g")
223
+ .attr("class", classChartTreemap)
224
+ .select("rect")
225
+ .attr("fill", d => $$.color(d.data.name));
226
+ },
227
+
228
+ /**
229
+ * Generate treemap coordinate points data
230
+ * @returns {Array} Array of coordinate points
231
+ * @private
232
+ */
233
+ generateGetTreemapPoints(): (d: IDataRow) => [number, number][] {
234
+ const $$ = this;
235
+ const {$el, scale: {x, y}} = $$;
236
+ const points = {};
237
+
238
+ $el.treemap.selectAll("g").each(d => {
239
+ points[d.data.name] = [
240
+ [x(d.x0), y(d.y0)],
241
+ [x(d.x1), y(d.y1)]
242
+ ];
243
+ });
244
+
245
+ return d => points[d.id];
246
+ },
247
+
248
+ /**
249
+ * Redraw treemap
250
+ * @param {boolean} withTransition With or without transition
251
+ * @returns {Array} Selections
252
+ * @private
253
+ */
254
+ redrawTreemap(withTransition?: boolean): d3Selection[] {
255
+ const $$ = this;
256
+ const {$el, state: {current: {width, height}}} = $$;
257
+
258
+ // update defs
259
+ $el.defs.select("rect")
260
+ .attr("width", width)
261
+ .attr("height", height);
262
+
263
+ return [
264
+ $$.$T($el.treemap, withTransition, getRandom())
265
+ .call(position.bind($$), $el.treemap.datum())
266
+ ];
267
+ },
268
+
269
+ /**
270
+ * Get treemap data label format function
271
+ * @param {object} d Data object
272
+ * @returns {Function}
273
+ * @private
274
+ */
275
+ treemapDataLabelFormat(d: IDataRow): Function {
276
+ const $$ = this;
277
+ const {config} = $$;
278
+ const {id, value} = d;
279
+ const format = config.treemap_label_format;
280
+ const ratio = $$.getRatio("treemap", d);
281
+ const percentValue = (ratio * 100).toFixed(2);
282
+ const meetLabelThreshold = config.treemap_label_show && $$.meetsLabelThreshold(
283
+ ratio, "treemap"
284
+ ) ? null : "0";
285
+
286
+ return function(node) {
287
+ node.style("opacity", meetLabelThreshold);
288
+
289
+ return isFunction(format) ? format.bind($$.api)(value, ratio, id) :
290
+ `${id}\n${percentValue}%`;
291
+ };
292
+ }
293
+ };
@@ -22,17 +22,20 @@ export default {
22
22
  * Specified function receives x of the data point to show.
23
23
  * @property {Function} [tooltip.format.name] Set format for the name of each data in tooltip.<br>
24
24
  * Specified function receives name, ratio, id and index of the data point to show. ratio will be undefined if the chart is not donut/pie/gauge.
25
- * @property {Function} [tooltip.format.value] Set format for the value of each data in tooltip.<br>
26
- * Specified function receives name, ratio, id and index of the data point to show. ratio will be undefined if the chart is not donut/pie/gauge.
27
- * If undefined returned, the row of that value will be skipped.
25
+ * @property {Function} [tooltip.format.value] Set format for the value of each data in tooltip. If undefined returned, the row of that value will be skipped to be called.
26
+ * - Will pass following arguments to the given function:
27
+ * - `value {string}`: Value of the data point
28
+ * - `ratio {number}`: Ratio of the data point in the `pie/donut/gauge` and `area/bar` when contains grouped data. Otherwise is `undefined`.
29
+ * - `id {string}`: id of the data point
30
+ * - `index {number}`: Index of the data point
28
31
  * @property {Function} [tooltip.position] Set custom position function for the tooltip.<br>
29
32
  * This option can be used to modify the tooltip position by returning object that has top and left.
30
33
  * - Will pass following arguments to the given function:
31
- * - `data {Array}`: Current selected data array object.
32
- * - `width {number}`: Width of tooltip.
33
- * - `height {number}`: Height of tooltip.
34
- * - `element {SVGElement}`: Tooltip event bound element
35
- * - `pos {object}`: Current position of the tooltip.
34
+ * - `data {Array}`: Current selected data array object.
35
+ * - `width {number}`: Width of tooltip.
36
+ * - `height {number}`: Height of tooltip.
37
+ * - `element {SVGElement}`: Tooltip event bound element
38
+ * - `pos {object}`: Current position of the tooltip.
36
39
  * @property {Function|object} [tooltip.contents] Set custom HTML for the tooltip.<br>
37
40
  * If tooltip.grouped is true, data includes multiple data points.<br><br>
38
41
  * Specified function receives `data` array and `defaultTitleFormat`, `defaultValueFormat` and `color` functions of the data point to show.
@@ -99,6 +99,7 @@ export default {
99
99
  * - scatter
100
100
  * - spline
101
101
  * - step
102
+ * - treemap
102
103
  * @name data․type
103
104
  * @memberof Options
104
105
  * @type {string}
@@ -127,7 +128,8 @@ export default {
127
128
  * radar,
128
129
  * scatter,
129
130
  * spline,
130
- * step
131
+ * step,
132
+ * treemap
131
133
  * }
132
134
  *
133
135
  * bb.generate({
@@ -142,7 +144,7 @@ export default {
142
144
  /**
143
145
  * Set chart type for each data.<br>
144
146
  * This setting overwrites data.type setting.
145
- * - **NOTE:** `radar` type can't be combined with other types.
147
+ * - **NOTE:** `radar` and `treemap` type can't be combined with other types.
146
148
  * @name data․types
147
149
  * @memberof Options
148
150
  * @type {object}
@@ -174,7 +176,8 @@ export default {
174
176
  * radar,
175
177
  * scatter,
176
178
  * spline,
177
- * step
179
+ * step,
180
+ * treemap
178
181
  * }
179
182
  *
180
183
  * bb.generate({
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Copyright (c) 2017 ~ present NAVER Corp.
3
+ * billboard.js project is licensed under the MIT license
4
+ */
5
+ /**
6
+ * arc config options
7
+ */
8
+ export default {
9
+ /**
10
+ * Set arc options
11
+ * @name arc
12
+ * @memberof Options
13
+ * @type {object}
14
+ * @property {object} arc Arc object
15
+ * @property {number|Function} [arc.cornerRadius=0] Set corner radius of Arc(donut/gauge/pie/polar) shape.
16
+ * - **NOTE:**
17
+ * - Corner radius can't surpass the `(outerRadius - innerRadius) /2` of indicated shape.
18
+ * @property {number} [arc.cornerRadius.ratio=0] Set ratio relative of outer radius.
19
+ * @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutCornerRadius)
20
+ * @see [Demo: Gauge corner radius](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeCornerRadius)
21
+ * @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#PieChartOptions.CornerRadius)
22
+ * @example
23
+ * arc: {
24
+ * cornerRadius: 12,
25
+ *
26
+ * // can customize corner radius for each data with function callback
27
+ * //
28
+ * // The function will receive:
29
+ * // - id {string}: Data id
30
+ * // - value {number}: Data value
31
+ * // - outerRadius {number}: Outer radius value
32
+ * cornerRadius: function(id, value, outerRadius) {
33
+ * return (id === "data1" && value > 10) ?
34
+ * 50 : outerRadius * 1.2;
35
+ * },
36
+ *
37
+ * // set ratio relative of outer radius
38
+ * cornerRadius: {
39
+ * ratio: 0.5
40
+ * }
41
+ * }
42
+ */
43
+ arc_cornerRadius: <
44
+ number|((id: string, value: number) => number)
45
+ > 0,
46
+ arc_cornerRadius_ratio: 0
47
+ };
@@ -39,7 +39,7 @@ export default {
39
39
  * - `startingAngle < -1 * Math.PI` defaults to `Math.PI`
40
40
  * - `startingAngle > Math.PI` defaults to `Math.PI`
41
41
  * @property {number} [gauge.arcLength=100] Set the length of the arc to be drawn in percent from -100 to 100.<br>
42
- * Negative value will draw the arc **counterclockwise**.
42
+ * Negative value will draw the arc **counterclockwise**. Need to be used in conjunction with `gauge.fullCircle=true`.
43
43
  *
44
44
  * **Limitations:**
45
45
  * - -100 <= arcLength (in percent) <= 100
@@ -52,7 +52,7 @@ export default {
52
52
  * **Available Values:**
53
53
  * - single
54
54
  * - multi
55
- * @property {string} [gauge.arcs.minWidth=5] Set minimal width of gauge arcs until the innerRadius disappears.
55
+ * @property {number} [gauge.arcs.minWidth=5] Set minimal width of gauge arcs until the innerRadius disappears.
56
56
  * @see [Demo: archLength](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeArcLength)
57
57
  * @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeStartingAngle)
58
58
  * @example
@@ -3,7 +3,7 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
5
  /**
6
- * x Axis config options
6
+ * pie config options
7
7
  */
8
8
  export default {
9
9
  /**
@@ -3,7 +3,7 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
5
  /**
6
- * x Axis config options
6
+ * polar config options
7
7
  */
8
8
  export default {
9
9
  /**
@@ -3,7 +3,7 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
5
  /**
6
- * x Axis config options
6
+ * radar config options
7
7
  */
8
8
  export default {
9
9
  /**
@@ -3,7 +3,7 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
5
  /**
6
- * x Axis config options
6
+ * spline config options
7
7
  */
8
8
  export default {
9
9
  /**
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Copyright (c) 2017 ~ present NAVER Corp.
3
+ * billboard.js project is licensed under the MIT license
4
+ */
5
+ /**
6
+ * treemap config options
7
+ */
8
+ export default {
9
+ /**
10
+ * Set treemap options
11
+ * @name treemap
12
+ * @memberof Options
13
+ * @type {object}
14
+ * @property {object} treemap Treemap object
15
+ * @property {string} [treemap.tile="binary"] Treemap tile type
16
+ * - **Available tile type values:**
17
+ * - binary ([d3.treemapBinary](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapBinary))
18
+ * - dice ([d3.treemapDice](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapDice))
19
+ * - slice ([d3.treemapSlice](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapSlice))
20
+ * - sliceDice ([d3.treemapSliceDice](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapSliceDice))
21
+ * - squrify ([d3.treemapSquarify](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapSquarify))
22
+ * - resquarify ([d3.treemapResquarify](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapResquarify))
23
+ * @property {Function} [treemap.label.format] Set formatter for the label text.
24
+ * @property {number} [treemap.label.threshold=0.05] Set threshold ratio to show/hide labels text.
25
+ * @property {number} [treemap.label.show=true] Show or hide label text.
26
+ * @see [Demo: treemap](https://naver.github.io/billboard.js/demo/#Chart.TreemapChart)
27
+ * @example
28
+ * treemap: {
29
+ * // "binary", "dice", "slice", "sliceDice", "squrify", "resquarify"
30
+ * tile: "dice",
31
+ *
32
+ * label: {
33
+ * // show or hide label text
34
+ * show: false,
35
+ *
36
+ * // set label text formatter
37
+ * format: function(value, ratio, id) {
38
+ * return d3.format("$")(value);
39
+ *
40
+ * // to multiline, return with '\n' character
41
+ * // return value +"%\nLine1\n2Line2";
42
+ * },
43
+ *
44
+ * // set ratio number
45
+ * ratio: 0.05
46
+ * }
47
+ * }
48
+ */
49
+ treemap_tile: "binary",
50
+ treemap_label_format: <(() => number|string)|undefined> undefined,
51
+ treemap_label_threshold: 0.05,
52
+ treemap_label_show: true
53
+ };
@@ -40,6 +40,7 @@ export default class State {
40
40
 
41
41
  hasAxis: false,
42
42
  hasRadar: false,
43
+ hasTreemap: false,
43
44
 
44
45
  // for data CSS rule index (used when boost.useCssRule is true)
45
46
  cssRule: {},
@@ -172,6 +172,12 @@ export const $TOOLTIP = {
172
172
  tooltipName: "bb-tooltip-name"
173
173
  };
174
174
 
175
+ export const $TREEMAP = {
176
+ treemap: "bb-treemap",
177
+ chartTreemap: "bb-chart-treemap",
178
+ chartTreemaps: "bb-chart-treemaps"
179
+ };
180
+
175
181
  export const $ZOOM = {
176
182
  buttonZoomReset: "bb-zoom-reset",
177
183
  zoomBrush: "bb-zoom-brush"
@@ -200,5 +206,6 @@ export default {
200
206
  ...$SUBCHART,
201
207
  ...$TEXT,
202
208
  ...$TOOLTIP,
209
+ ...$TREEMAP,
203
210
  ...$ZOOM
204
211
  };
@@ -23,7 +23,8 @@ export const TYPE = {
23
23
  RADAR: "radar",
24
24
  SCATTER: "scatter",
25
25
  SPLINE: "spline",
26
- STEP: "step"
26
+ STEP: "step",
27
+ TREEMAP: "treemap"
27
28
  };
28
29
 
29
30
  /**
@@ -47,7 +48,8 @@ export const TYPE_METHOD_NEEDED = {
47
48
  RADAR: "initCircle",
48
49
  SCATTER: "initCircle",
49
50
  SPLINE: "initLine",
50
- STEP: "initLine"
51
+ STEP: "initLine",
52
+ TREEMAP: "initTreemap"
51
53
  };
52
54
 
53
55
  /**