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.
- package/dist/billboard.css +6 -1
- package/dist/billboard.js +1704 -843
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +3819 -2263
- package/dist/billboard.pkgd.min.js +6 -3
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +62 -23
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.js +62 -23
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +48 -14
- package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.js +48 -14
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +1087 -1031
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +1171 -1112
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +1222 -1169
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +1159 -1105
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +1365 -1319
- package/dist/theme/datalab.css +6 -1
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +6 -1
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +6 -1
- package/dist/theme/insight.min.css +2 -2
- package/dist-esm/billboard.js +942 -277
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +3 -5
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +10 -9
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +10 -9
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +4 -8
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +3 -5
- package/package.json +44 -38
- package/src/Chart/api/chart.ts +13 -4
- package/src/Chart/api/export.ts +159 -14
- package/src/Chart/api/legend.ts +1 -0
- package/src/Chart/api/load.ts +1 -0
- package/src/Chart/api/tooltip.ts +11 -2
- package/src/ChartInternal/Axis/Axis.ts +1 -1
- package/src/ChartInternal/ChartInternal.ts +35 -25
- package/src/ChartInternal/data/IData.ts +9 -0
- package/src/ChartInternal/data/convert.helper.ts +35 -21
- package/src/ChartInternal/data/data.ts +26 -5
- package/src/ChartInternal/data/load.ts +3 -0
- package/src/ChartInternal/interactions/interaction.ts +42 -33
- package/src/ChartInternal/internals/class.ts +3 -4
- package/src/ChartInternal/internals/clip.ts +13 -10
- package/src/ChartInternal/internals/domain.ts +11 -4
- package/src/ChartInternal/internals/format.ts +1 -1
- package/src/ChartInternal/internals/grid.ts +1 -1
- package/src/ChartInternal/internals/legend.ts +3 -2
- package/src/ChartInternal/internals/redraw.ts +12 -5
- package/src/ChartInternal/internals/scale.ts +7 -2
- package/src/ChartInternal/internals/size.ts +41 -26
- package/src/ChartInternal/internals/text.ts +60 -32
- package/src/ChartInternal/internals/tooltip.ts +12 -8
- package/src/ChartInternal/internals/transform.ts +2 -2
- package/src/ChartInternal/internals/type.ts +6 -1
- package/src/ChartInternal/shape/arc.ts +145 -68
- package/src/ChartInternal/shape/area.ts +3 -0
- package/src/ChartInternal/shape/bar.ts +4 -1
- package/src/ChartInternal/shape/line.ts +12 -15
- package/src/ChartInternal/shape/radar.ts +2 -2
- package/src/ChartInternal/shape/shape.ts +10 -5
- package/src/ChartInternal/shape/treemap.ts +293 -0
- package/src/config/Options/common/tooltip.ts +11 -8
- package/src/config/Options/data/data.ts +6 -3
- package/src/config/Options/shape/arc.ts +47 -0
- package/src/config/Options/shape/gauge.ts +2 -2
- package/src/config/Options/shape/pie.ts +1 -1
- package/src/config/Options/shape/polar.ts +1 -1
- package/src/config/Options/shape/radar.ts +1 -1
- package/src/config/Options/shape/spline.ts +1 -1
- package/src/config/Options/shape/treemap.ts +53 -0
- package/src/config/Store/State.ts +1 -0
- package/src/config/classes.ts +7 -0
- package/src/config/const.ts +4 -2
- package/src/config/resolver/shape.ts +22 -5
- package/src/index.esm.ts +2 -1
- package/src/module/util.ts +1 -1
- package/src/scss/billboard.scss +6 -0
- package/src/scss/theme/datalab.scss +6 -0
- package/src/scss/theme/graph.scss +6 -0
- package/src/scss/theme/insight.scss +6 -0
- package/types/bb.d.ts +1 -0
- package/types/chart.d.ts +7 -0
- package/types/index.d.ts +1 -0
- package/types/options.d.ts +42 -624
- package/types/options.shape.d.ts +664 -0
- package/types/types.d.ts +4 -3
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import {select as d3Select} from "d3-selection";
|
|
6
6
|
import {drag as d3Drag} from "d3-drag";
|
|
7
|
-
import {$ARC, $AXIS, $COMMON, $SHAPE} from "../../config/classes";
|
|
7
|
+
import {$ARC, $AXIS, $COMMON, $SHAPE, $TREEMAP} from "../../config/classes";
|
|
8
8
|
import {KEY} from "../../module/Cache";
|
|
9
9
|
import {emulateEvent, getPointer, isNumber, isObject} from "../../module/util";
|
|
10
10
|
import type {IArcDataRow} from "../data/IData";
|
|
@@ -111,17 +111,19 @@ export default {
|
|
|
111
111
|
*/
|
|
112
112
|
setOverOut(isOver: boolean, d: number | IArcDataRow): void {
|
|
113
113
|
const $$ = this;
|
|
114
|
-
const {config, state: {hasRadar}, $el: {main}} = $$;
|
|
115
|
-
const
|
|
114
|
+
const {config, state: {hasRadar, hasTreemap}, $el: {main}} = $$;
|
|
115
|
+
const isArcTreemap = isObject(d);
|
|
116
116
|
|
|
117
117
|
// Call event handler
|
|
118
|
-
if (
|
|
118
|
+
if (isArcTreemap || d !== -1) {
|
|
119
119
|
const callback = config[isOver ? "data_onover" : "data_onout"].bind($$.api);
|
|
120
120
|
|
|
121
|
-
config.color_onover && $$.setOverColor(isOver, d,
|
|
121
|
+
config.color_onover && $$.setOverColor(isOver, d, isArcTreemap);
|
|
122
122
|
|
|
123
|
-
if (
|
|
124
|
-
|
|
123
|
+
if (isArcTreemap && "id") {
|
|
124
|
+
const selector = hasTreemap ? $TREEMAP.treemap : $ARC.arc;
|
|
125
|
+
|
|
126
|
+
callback(d, main.select(`.${selector}${$$.getTargetSelectorSuffix((d as IArcDataRow).id)}`).node());
|
|
125
127
|
} else if (!config.tooltip_grouped) {
|
|
126
128
|
const last = $$.cache.get(KEY.setOverOut) || [];
|
|
127
129
|
|
|
@@ -222,36 +224,43 @@ export default {
|
|
|
222
224
|
*/
|
|
223
225
|
dispatchEvent(type: string, index: number, mouse): void {
|
|
224
226
|
const $$ = this;
|
|
225
|
-
const {config, state: {
|
|
226
|
-
|
|
227
|
+
const {config, state: {
|
|
228
|
+
eventReceiver, hasAxis, hasRadar, hasTreemap
|
|
229
|
+
}, $el: {eventRect, arcs, radar, treemap}} = $$;
|
|
227
230
|
const element = (
|
|
228
|
-
|
|
229
|
-
|
|
231
|
+
(hasTreemap && eventReceiver.rect) ||
|
|
232
|
+
(hasRadar && radar.axes.select(`.${$AXIS.axis}-${index} text`)) || (
|
|
233
|
+
eventRect || arcs?.selectAll(`.${$COMMON.target} path`).filter((d, i) => i === index)
|
|
230
234
|
)
|
|
231
|
-
)
|
|
235
|
+
)?.node();
|
|
232
236
|
|
|
233
|
-
|
|
237
|
+
if (element) {
|
|
238
|
+
const isMultipleX = $$.isMultipleX();
|
|
239
|
+
let {width, left, top} = element.getBoundingClientRect();
|
|
234
240
|
|
|
235
|
-
|
|
236
|
-
|
|
241
|
+
if (hasAxis && !hasRadar && !isMultipleX) {
|
|
242
|
+
const coords = eventReceiver.coords[index];
|
|
237
243
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
244
|
+
width = coords.w;
|
|
245
|
+
left += coords.x;
|
|
246
|
+
top += coords.y;
|
|
247
|
+
}
|
|
242
248
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
249
|
+
const x = left + (mouse ? mouse[0] : 0) + (
|
|
250
|
+
isMultipleX || config.axis_rotated ? 0 : (width / 2)
|
|
251
|
+
);
|
|
252
|
+
const y = top + (mouse ? mouse[1] : 0);
|
|
253
|
+
const params = {
|
|
254
|
+
screenX: x,
|
|
255
|
+
screenY: y,
|
|
256
|
+
clientX: x,
|
|
257
|
+
clientY: y
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
emulateEvent[/^(mouse|click)/.test(type) ? "mouse" : "touch"](
|
|
261
|
+
hasTreemap ? treemap.node() : element,
|
|
262
|
+
type, params);
|
|
263
|
+
}
|
|
255
264
|
},
|
|
256
265
|
|
|
257
266
|
setDragStatus(isDragging: boolean): void {
|
|
@@ -278,7 +287,7 @@ export default {
|
|
|
278
287
|
*/
|
|
279
288
|
unbindAllEvents(): void {
|
|
280
289
|
const $$ = this;
|
|
281
|
-
const {$el: {arcs, eventRect, legend, region, svg}, brush} = $$;
|
|
290
|
+
const {$el: {arcs, eventRect, legend, region, svg, treemap}, brush} = $$;
|
|
282
291
|
const list = [
|
|
283
292
|
"wheel",
|
|
284
293
|
"click",
|
|
@@ -299,7 +308,7 @@ export default {
|
|
|
299
308
|
].join(" ");
|
|
300
309
|
|
|
301
310
|
// detach all possible event types
|
|
302
|
-
[svg, eventRect, region?.list, brush?.getSelection(), arcs?.selectAll("path"), legend?.selectAll("g")]
|
|
311
|
+
[svg, eventRect, region?.list, brush?.getSelection(), arcs?.selectAll("path"), legend?.selectAll("g"), treemap]
|
|
303
312
|
.forEach(v => v?.on(list, null));
|
|
304
313
|
|
|
305
314
|
$$.unbindZoomEvent?.();
|
|
@@ -18,7 +18,7 @@ export default {
|
|
|
18
18
|
*/
|
|
19
19
|
getClass(type: string, withShape: boolean): Function {
|
|
20
20
|
const isPlural = /s$/.test(type);
|
|
21
|
-
const useIdKey = /^(area|arc|line)s?$/.test(type);
|
|
21
|
+
const useIdKey = /^(area|arc|line|treemap)s?$/.test(type);
|
|
22
22
|
const key = isPlural ? "id" : "index";
|
|
23
23
|
|
|
24
24
|
return (d): string => {
|
|
@@ -90,12 +90,11 @@ export default {
|
|
|
90
90
|
return targetStr.replace(/([\s?!@#$%^&*()_=+,.<>'":;\[\]\/|~`{}\\])/g, "-");
|
|
91
91
|
},
|
|
92
92
|
|
|
93
|
-
selectorTarget(id: string, prefix
|
|
94
|
-
const pfx = prefix || "";
|
|
93
|
+
selectorTarget(id: string, prefix = "", postfix = ""): string {
|
|
95
94
|
const target = this.getTargetSelectorSuffix(id);
|
|
96
95
|
|
|
97
96
|
// select target & circle
|
|
98
|
-
return `${
|
|
97
|
+
return `${prefix}.${CLASS.target + target} ${postfix}, ${prefix}.${CLASS.circles + target} ${postfix}`;
|
|
99
98
|
},
|
|
100
99
|
|
|
101
100
|
selectorTargets(idsValue, prefix: string): string[] | null {
|
|
@@ -7,19 +7,22 @@ import {document, window} from "../../module/browser";
|
|
|
7
7
|
export default {
|
|
8
8
|
initClip(): void {
|
|
9
9
|
const $$ = this;
|
|
10
|
-
const {clip} = $$.state;
|
|
10
|
+
const {clip, hasAxis} = $$.state;
|
|
11
11
|
|
|
12
12
|
// MEMO: clipId needs to be unique because it conflicts when multiple charts exist
|
|
13
13
|
clip.id = `${$$.state.datetimeId}-clip`;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
|
|
15
|
+
if (hasAxis) {
|
|
16
|
+
clip.idXAxis = `${clip.id}-xaxis`;
|
|
17
|
+
clip.idYAxis = `${clip.id}-yaxis`;
|
|
18
|
+
clip.idGrid = `${clip.id}-grid`;
|
|
19
|
+
|
|
20
|
+
// Define 'clip-path' attribute values
|
|
21
|
+
clip.path = $$.getClipPath(clip.id);
|
|
22
|
+
clip.pathXAxis = $$.getClipPath(clip.idXAxis);
|
|
23
|
+
clip.pathYAxis = $$.getClipPath(clip.idYAxis);
|
|
24
|
+
clip.pathGrid = $$.getClipPath(clip.idGrid);
|
|
25
|
+
}
|
|
23
26
|
},
|
|
24
27
|
|
|
25
28
|
getClipPath(id: string): string | null {
|
|
@@ -113,10 +113,17 @@ export default {
|
|
|
113
113
|
});
|
|
114
114
|
|
|
115
115
|
// MEMO: avoid inverting domain unexpectedly
|
|
116
|
-
yDomainMin = isValue(yMin) ? yMin :
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
yDomainMin = isValue(yMin) ? yMin : (
|
|
117
|
+
isValue(yMax) ? (
|
|
118
|
+
yDomainMin <= yMax ? yDomainMin : yMax - 10
|
|
119
|
+
) : yDomainMin
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
yDomainMax = isValue(yMax) ? yMax : (
|
|
123
|
+
isValue(yMin) ? (
|
|
124
|
+
yMin <= yDomainMax ? yDomainMax : yMin + 10
|
|
125
|
+
) : yDomainMax
|
|
126
|
+
);
|
|
120
127
|
|
|
121
128
|
if (isNaN(yDomainMin)) { // set minimum to zero when not number
|
|
122
129
|
yDomainMin = 0;
|
|
@@ -64,6 +64,7 @@ export default {
|
|
|
64
64
|
updateLegend(targetIds, options, transitions): void {
|
|
65
65
|
const $$ = this;
|
|
66
66
|
const {config, state, scale, $el} = $$;
|
|
67
|
+
|
|
67
68
|
const optionz = options || {
|
|
68
69
|
withTransform: false,
|
|
69
70
|
withTransitionForTransform: false,
|
|
@@ -75,7 +76,7 @@ export default {
|
|
|
75
76
|
|
|
76
77
|
if (config.legend_contents_bindto && config.legend_contents_template) {
|
|
77
78
|
$$.updateLegendTemplate();
|
|
78
|
-
} else {
|
|
79
|
+
} else if (!state.hasTreemap) {
|
|
79
80
|
$$.updateLegendElement(
|
|
80
81
|
targetIds || $$.mapToIds($$.data.targets),
|
|
81
82
|
optionz,
|
|
@@ -84,7 +85,7 @@ export default {
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
// toggle legend state
|
|
87
|
-
$el.legend
|
|
88
|
+
$el.legend?.selectAll(`.${$LEGEND.legendItem}`)
|
|
88
89
|
.classed($LEGEND.legendItemHidden, function(id) {
|
|
89
90
|
const hide = !$$.isTargetToShow(id);
|
|
90
91
|
|
|
@@ -11,7 +11,7 @@ export default {
|
|
|
11
11
|
redraw(options: any = {}): void {
|
|
12
12
|
const $$ = this;
|
|
13
13
|
const {config, state, $el} = $$;
|
|
14
|
-
const {main} = $el;
|
|
14
|
+
const {main, treemap} = $el;
|
|
15
15
|
|
|
16
16
|
state.redrawing = true;
|
|
17
17
|
|
|
@@ -28,7 +28,7 @@ export default {
|
|
|
28
28
|
// update legend and transform each g
|
|
29
29
|
if (wth.Legend && config.legend_show) {
|
|
30
30
|
options.withTransition = !!duration;
|
|
31
|
-
$$.updateLegend($$.mapToIds($$.data.targets), options, transitions);
|
|
31
|
+
!treemap && $$.updateLegend($$.mapToIds($$.data.targets), options, transitions);
|
|
32
32
|
} else if (wth.Dimension) {
|
|
33
33
|
// need to update dimension (e.g. axis.y.tick.values) because y tick values should change
|
|
34
34
|
// no need to update axis in it because they will be updated in redraw()
|
|
@@ -36,7 +36,7 @@ export default {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
// update circleY based on updated parameters
|
|
39
|
-
if (!$$.hasArcType() || state.hasRadar) {
|
|
39
|
+
if (!treemap && (!$$.hasArcType() || state.hasRadar)) {
|
|
40
40
|
$$.updateCircleY && ($$.circleY = $$.updateCircleY());
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -87,10 +87,13 @@ export default {
|
|
|
87
87
|
|
|
88
88
|
// polar
|
|
89
89
|
$el.polar && $$.redrawPolar();
|
|
90
|
+
|
|
91
|
+
// treemap
|
|
92
|
+
treemap && $$.updateTreemap(durationForExit);
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
// @TODO: Axis & Radar type
|
|
93
|
-
if (!state.resizing && ($$.hasPointType() || state.hasRadar)) {
|
|
96
|
+
if (!state.resizing && !treemap && ($$.hasPointType() || state.hasRadar)) {
|
|
94
97
|
$$.updateCircle();
|
|
95
98
|
}
|
|
96
99
|
|
|
@@ -172,7 +175,7 @@ export default {
|
|
|
172
175
|
|
|
173
176
|
getRedrawList(shape, flow, flowFn, withTransition: boolean): Function[] {
|
|
174
177
|
const $$ = <any> this;
|
|
175
|
-
const {config, state: {hasAxis, hasRadar}, $el: {grid}} = $$;
|
|
178
|
+
const {config, state: {hasAxis, hasRadar, hasTreemap}, $el: {grid}} = $$;
|
|
176
179
|
const {cx, cy, xForText, yForText} = shape.pos;
|
|
177
180
|
const list: Function[] = [];
|
|
178
181
|
|
|
@@ -206,6 +209,10 @@ export default {
|
|
|
206
209
|
$$.redrawCircle && list.push($$.redrawCircle(cx, cy, withTransition, flowFn));
|
|
207
210
|
}
|
|
208
211
|
|
|
212
|
+
if (hasTreemap) {
|
|
213
|
+
list.push($$.redrawTreemap(withTransition));
|
|
214
|
+
}
|
|
215
|
+
|
|
209
216
|
return list;
|
|
210
217
|
},
|
|
211
218
|
|
|
@@ -82,7 +82,7 @@ export default {
|
|
|
82
82
|
* @private
|
|
83
83
|
*/
|
|
84
84
|
getYScaleById(id: string, isSub = false): Function {
|
|
85
|
-
const isY2 = this.axis
|
|
85
|
+
const isY2 = this.axis?.getId(id) === "y2";
|
|
86
86
|
const key = isSub ? (isY2 ? "subY2" : "subY") : (isY2 ? "y2" : "y");
|
|
87
87
|
|
|
88
88
|
return this.scale[key];
|
|
@@ -141,7 +141,7 @@ export default {
|
|
|
141
141
|
updateScales(isInit: boolean, updateXDomain = true): void {
|
|
142
142
|
const $$ = this;
|
|
143
143
|
const {axis, config, format, org, scale,
|
|
144
|
-
state: {width, height, width2, height2, hasAxis}
|
|
144
|
+
state: {current, width, height, width2, height2, hasAxis, hasTreemap}
|
|
145
145
|
} = $$;
|
|
146
146
|
|
|
147
147
|
if (hasAxis) {
|
|
@@ -197,6 +197,11 @@ export default {
|
|
|
197
197
|
|
|
198
198
|
axis.setAxis("y2", scale.y2, config.axis_y2_tick_outer, isInit);
|
|
199
199
|
}
|
|
200
|
+
} else if (hasTreemap) {
|
|
201
|
+
const padding = $$.getCurrentPadding();
|
|
202
|
+
|
|
203
|
+
scale.x = d3ScaleLinear().rangeRound([padding.left, current.width - padding.right]);
|
|
204
|
+
scale.y = d3ScaleLinear().rangeRound([padding.top, current.height - padding.bottom]);
|
|
200
205
|
} else {
|
|
201
206
|
// update for arc
|
|
202
207
|
$$.updateArc?.();
|
|
@@ -100,7 +100,7 @@ export default {
|
|
|
100
100
|
let padding;
|
|
101
101
|
|
|
102
102
|
if (isValue(config.padding_right)) {
|
|
103
|
-
padding = config.padding_right + 1; // 1 is needed not to hide tick line
|
|
103
|
+
padding = config.padding_right + (hasAxis ? 1 : 0); // 1 is needed not to hide tick line
|
|
104
104
|
} else if ($$.axis && config.axis_rotated) {
|
|
105
105
|
padding = defaultPadding + legendWidthOnRight;
|
|
106
106
|
} else if ($$.axis && (!config.axis_y2_show || config.axis_y2_inner)) { // && !config.axis_rotated
|
|
@@ -232,6 +232,17 @@ export default {
|
|
|
232
232
|
}
|
|
233
233
|
},
|
|
234
234
|
|
|
235
|
+
getCurrentPadding(): {top: number, bottom: number, left: number, right: number} {
|
|
236
|
+
const $$ = this;
|
|
237
|
+
|
|
238
|
+
return {
|
|
239
|
+
top: $$.getCurrentPaddingTop(),
|
|
240
|
+
bottom: $$.getCurrentPaddingBottom(),
|
|
241
|
+
left: $$.getCurrentPaddingLeft(),
|
|
242
|
+
right: $$.getCurrentPaddingRight()
|
|
243
|
+
};
|
|
244
|
+
},
|
|
245
|
+
|
|
235
246
|
/**
|
|
236
247
|
* Get resetted padding values when 'padding=false' option is set
|
|
237
248
|
* https://github.com/naver/billboard.js/issues/2367
|
|
@@ -239,14 +250,14 @@ export default {
|
|
|
239
250
|
* @returns {number|object} Padding value
|
|
240
251
|
* @private
|
|
241
252
|
*/
|
|
242
|
-
getResettedPadding<T = number | {[key: string]: string
|
|
253
|
+
getResettedPadding<T = number | {[key: string]: string}>(v: T): T {
|
|
243
254
|
const $$ = this;
|
|
244
255
|
const {config} = $$;
|
|
245
256
|
const isNum = isNumber(v);
|
|
246
|
-
let p = isNum ? 0 : {};
|
|
257
|
+
let p: any = isNum ? 0 : {};
|
|
247
258
|
|
|
248
259
|
if (config.padding === false) {
|
|
249
|
-
!isNum && Object.keys(v).forEach(key => {
|
|
260
|
+
!isNum && Object.keys(v as object).forEach(key => {
|
|
250
261
|
// when data.lables=true, do not reset top padding
|
|
251
262
|
p[key] = (
|
|
252
263
|
!isEmpty(config.data_labels) &&
|
|
@@ -270,7 +281,7 @@ export default {
|
|
|
270
281
|
const $$ = this;
|
|
271
282
|
const {config, state, $el: {legend}} = $$;
|
|
272
283
|
const isRotated = config.axis_rotated;
|
|
273
|
-
const
|
|
284
|
+
const isNonAxis = $$.hasArcType() || state.hasTreemap;
|
|
274
285
|
|
|
275
286
|
!isInit && $$.setContainerSize();
|
|
276
287
|
|
|
@@ -279,29 +290,31 @@ export default {
|
|
|
279
290
|
height: legend ? $$.getLegendHeight() : 0
|
|
280
291
|
};
|
|
281
292
|
|
|
282
|
-
if (!
|
|
293
|
+
if (!isNonAxis && config.axis_x_show && config.axis_x_tick_autorotate) {
|
|
283
294
|
$$.updateXAxisTickClip();
|
|
284
295
|
}
|
|
285
296
|
|
|
286
297
|
const legendHeightForBottom = state.isLegendRight || state.isLegendInset ? 0 : currLegend.height;
|
|
287
|
-
const xAxisHeight = isRotated ||
|
|
298
|
+
const xAxisHeight = isRotated || isNonAxis ? 0 : $$.getHorizontalAxisHeight("x");
|
|
288
299
|
|
|
289
300
|
const subchartXAxisHeight = config.subchart_axis_x_show && config.subchart_axis_x_tick_text_show ?
|
|
290
301
|
xAxisHeight : 30;
|
|
291
|
-
const subchartHeight = config.subchart_show && !
|
|
302
|
+
const subchartHeight = config.subchart_show && !isNonAxis ?
|
|
292
303
|
(config.subchart_size_height + subchartXAxisHeight) : 0;
|
|
293
304
|
|
|
305
|
+
const padding = $$.getCurrentPadding();
|
|
306
|
+
|
|
294
307
|
// for main
|
|
295
|
-
state.margin = !
|
|
296
|
-
top: $$.getHorizontalAxisHeight("y2") +
|
|
297
|
-
right:
|
|
298
|
-
bottom: $$.getHorizontalAxisHeight("y") + legendHeightForBottom +
|
|
299
|
-
left: subchartHeight + (
|
|
308
|
+
state.margin = !isNonAxis && isRotated ? {
|
|
309
|
+
top: $$.getHorizontalAxisHeight("y2") + padding.top,
|
|
310
|
+
right: isNonAxis ? 0 : $$.getCurrentPaddingRight(true),
|
|
311
|
+
bottom: $$.getHorizontalAxisHeight("y") + legendHeightForBottom + padding.bottom,
|
|
312
|
+
left: subchartHeight + (isNonAxis ? 0 : padding.left)
|
|
300
313
|
} : {
|
|
301
|
-
top: 4 +
|
|
302
|
-
right:
|
|
303
|
-
bottom: xAxisHeight + subchartHeight + legendHeightForBottom +
|
|
304
|
-
left:
|
|
314
|
+
top: 4 + padding.top, // for top tick text
|
|
315
|
+
right: isNonAxis ? 0 : $$.getCurrentPaddingRight(true),
|
|
316
|
+
bottom: xAxisHeight + subchartHeight + legendHeightForBottom + padding.bottom,
|
|
317
|
+
left: isNonAxis ? 0 : padding.left
|
|
305
318
|
};
|
|
306
319
|
|
|
307
320
|
state.margin = $$.getResettedPadding(state.margin);
|
|
@@ -355,19 +368,21 @@ export default {
|
|
|
355
368
|
}
|
|
356
369
|
|
|
357
370
|
// for arc
|
|
358
|
-
|
|
359
|
-
|
|
371
|
+
if ($$.hasArcType()) {
|
|
372
|
+
const hasGauge = $$.hasType("gauge");
|
|
373
|
+
const isLegendRight = config.legend_show && state.isLegendRight;
|
|
360
374
|
|
|
361
|
-
|
|
362
|
-
|
|
375
|
+
state.arcWidth = state.width - (isLegendRight ? currLegend.width + 10 : 0);
|
|
376
|
+
state.arcHeight = state.height - (isLegendRight && !hasGauge ? 0 : 10);
|
|
363
377
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
378
|
+
if (hasGauge && !config.gauge_fullCircle) {
|
|
379
|
+
state.arcHeight += state.height - $$.getPaddingBottomForGauge();
|
|
380
|
+
}
|
|
367
381
|
|
|
368
|
-
|
|
382
|
+
$$.updateRadius?.();
|
|
383
|
+
}
|
|
369
384
|
|
|
370
|
-
if (state.isLegendRight &&
|
|
385
|
+
if (state.isLegendRight && isNonAxis) {
|
|
371
386
|
state.margin3.left = state.arcWidth / 2 + state.radiusExpanded * 1.1;
|
|
372
387
|
}
|
|
373
388
|
}
|