billboard.js 3.15.1 → 3.16.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 +2 -1
- package/dist/billboard.js +333 -102
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +9 -9
- package/dist/billboard.pkgd.js +3023 -1556
- package/dist/billboard.pkgd.min.js +19 -19
- 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 +25 -10
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +3 -3
- package/dist/plugin/billboardjs-plugin-stanford.js +25 -10
- package/dist/plugin/billboardjs-plugin-stanford.min.js +5 -5
- package/dist/plugin/billboardjs-plugin-tableview.js +18 -7
- package/dist/plugin/billboardjs-plugin-tableview.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-textoverlap.js +18 -7
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +4 -4
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2692 -1456
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +4 -4
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2716 -1465
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +7 -7
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2717 -1466
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +14 -14
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2711 -1464
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +7 -7
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2712 -1465
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -7
- package/dist/theme/dark.css +2 -1
- package/dist/theme/dark.min.css +2 -2
- package/dist/theme/datalab.css +2 -1
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +2 -1
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +2 -1
- package/dist/theme/insight.min.css +2 -2
- package/dist/theme/modern.css +2 -1
- package/dist/theme/modern.min.css +2 -2
- package/dist-esm/billboard.js +376 -129
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +9 -5
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +9 -5
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/package.json +23 -23
- package/src/Chart/api/category.ts +1 -1
- package/src/Chart/api/chart.ts +12 -0
- package/src/Chart/api/export.ts +11 -4
- package/src/ChartInternal/Axis/Axis.ts +20 -6
- package/src/ChartInternal/Axis/AxisRenderer.ts +17 -4
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +2 -2
- package/src/ChartInternal/ChartInternal.ts +1 -1
- package/src/ChartInternal/data/convert.ts +17 -4
- package/src/ChartInternal/data/data.ts +27 -38
- package/src/ChartInternal/interactions/eventrect.ts +8 -3
- package/src/ChartInternal/interactions/interaction.ts +3 -2
- package/src/ChartInternal/internals/color.ts +2 -2
- package/src/ChartInternal/internals/domain.ts +6 -2
- package/src/ChartInternal/internals/grid.ts +1 -1
- package/src/ChartInternal/internals/size.ts +16 -5
- package/src/ChartInternal/internals/style.ts +1 -1
- package/src/ChartInternal/internals/text.ts +31 -18
- package/src/ChartInternal/internals/tooltip.ts +2 -1
- package/src/ChartInternal/shape/arc.ts +2 -4
- package/src/ChartInternal/shape/bar.ts +113 -14
- package/src/ChartInternal/shape/candlestick.ts +1 -1
- package/src/ChartInternal/shape/funnel.ts +1 -1
- package/src/ChartInternal/shape/line.ts +6 -2
- package/src/ChartInternal/shape/point.ts +13 -9
- package/src/ChartInternal/shape/radar.ts +3 -2
- package/src/ChartInternal/shape/shape.ts +3 -2
- package/src/ChartInternal/shape/treemap.ts +1 -1
- package/src/config/Options/axis/axis.ts +19 -5
- package/src/config/Options/axis/x.ts +22 -1
- package/src/config/Options/axis/y.ts +20 -0
- package/src/config/Options/axis/y2.ts +33 -0
- package/src/config/Options/shape/bar.ts +1 -0
- package/src/config/Store/State.ts +2 -1
- package/src/config/classes.ts +7 -3
- package/src/module/util.ts +45 -20
- package/src/scss/billboard.scss +1 -0
- package/src/scss/theme/dark.scss +1 -0
- package/src/scss/theme/datalab.scss +1 -0
- package/src/scss/theme/graph.scss +1 -0
- package/src/scss/theme/insight.scss +1 -0
- package/src/scss/theme/modern.scss +1 -0
- package/types/axis.d.ts +12 -0
- package/types/chart.d.ts +10 -0
- package/types/options.shape.d.ts +6 -0
package/dist/billboard.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 3.
|
|
8
|
+
* @version 3.16.0-next.2
|
|
9
9
|
*/
|
|
10
10
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
11
11
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -235,7 +235,8 @@ const $COMMON = {
|
|
|
235
235
|
empty: "bb-empty",
|
|
236
236
|
main: "bb-main",
|
|
237
237
|
target: "bb-target",
|
|
238
|
-
EXPANDED: "_expanded_"
|
|
238
|
+
EXPANDED: "_expanded_",
|
|
239
|
+
dummy: "_dummy_"
|
|
239
240
|
};
|
|
240
241
|
const $ARC = {
|
|
241
242
|
arc: "bb-arc",
|
|
@@ -262,13 +263,16 @@ const $AXIS = {
|
|
|
262
263
|
axisYLabel: "bb-axis-y-label",
|
|
263
264
|
axisXTooltip: "bb-axis-x-tooltip",
|
|
264
265
|
axisYTooltip: "bb-axis-y-tooltip",
|
|
265
|
-
axisY2Tooltip: "bb-axis-y2-tooltip"
|
|
266
|
+
axisY2Tooltip: "bb-axis-y2-tooltip",
|
|
267
|
+
axisTooltipX: "bb-axis-tooltip-x",
|
|
268
|
+
axisTooltipY: "bb-axis-tooltip-y"
|
|
266
269
|
};
|
|
267
270
|
const $BAR = {
|
|
268
271
|
bar: "bb-bar",
|
|
269
272
|
bars: "bb-bars",
|
|
270
273
|
chartBar: "bb-chart-bar",
|
|
271
|
-
chartBars: "bb-chart-bars"
|
|
274
|
+
chartBars: "bb-chart-bars",
|
|
275
|
+
barConnectLine: "bb-bar-connectLine"
|
|
272
276
|
};
|
|
273
277
|
const $CANDLESTICK = {
|
|
274
278
|
candlestick: "bb-candlestick",
|
|
@@ -2415,7 +2419,7 @@ function getRectSegList(path) {
|
|
|
2415
2419
|
];
|
|
2416
2420
|
}
|
|
2417
2421
|
function getPathBox(path) {
|
|
2418
|
-
const { width, height } = path
|
|
2422
|
+
const { width, height } = getBoundingRect(path);
|
|
2419
2423
|
const items = getRectSegList(path);
|
|
2420
2424
|
const x = items[0].x;
|
|
2421
2425
|
const y = Math.min(items[0].y, items[1].y);
|
|
@@ -2447,9 +2451,20 @@ function getBrushSelection(ctx) {
|
|
|
2447
2451
|
}
|
|
2448
2452
|
return selection;
|
|
2449
2453
|
}
|
|
2450
|
-
function
|
|
2451
|
-
const
|
|
2452
|
-
|
|
2454
|
+
function getRect(relativeViewport, node, forceEval = false) {
|
|
2455
|
+
const _ = (n) => n[relativeViewport ? "getBoundingClientRect" : "getBBox"]();
|
|
2456
|
+
if (forceEval) {
|
|
2457
|
+
return _(node);
|
|
2458
|
+
} else {
|
|
2459
|
+
const needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +(node.getAttribute("width") || 0);
|
|
2460
|
+
return needEvaluate ? node.rect = _(node) : node.rect;
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
function getBoundingRect(node, forceEval = false) {
|
|
2464
|
+
return getRect(true, node, forceEval);
|
|
2465
|
+
}
|
|
2466
|
+
function getBBox(node, forceEval = false) {
|
|
2467
|
+
return getRect(false, node, forceEval);
|
|
2453
2468
|
}
|
|
2454
2469
|
function getRandom(asStr = true, min = 0, max = 1e4) {
|
|
2455
2470
|
const crpt = win.crypto || win.msCrypto;
|
|
@@ -2545,7 +2560,7 @@ function getTransformCTM(node, x = 0, y = 0, inverse = true) {
|
|
|
2545
2560
|
inverse ? screen == null ? void 0 : screen.inverse() : screen
|
|
2546
2561
|
);
|
|
2547
2562
|
if (inverse === false) {
|
|
2548
|
-
const rect = node
|
|
2563
|
+
const rect = getBoundingRect(node);
|
|
2549
2564
|
res.x -= rect.x;
|
|
2550
2565
|
res.y -= rect.y;
|
|
2551
2566
|
}
|
|
@@ -2929,8 +2944,10 @@ class State {
|
|
|
2929
2944
|
},
|
|
2930
2945
|
// current used chart type list
|
|
2931
2946
|
types: [],
|
|
2932
|
-
needle: void 0
|
|
2947
|
+
needle: void 0,
|
|
2933
2948
|
// arc needle current value
|
|
2949
|
+
zoomDomain: null
|
|
2950
|
+
// zoomed domain value
|
|
2934
2951
|
},
|
|
2935
2952
|
// legend
|
|
2936
2953
|
isLegendRight: false,
|
|
@@ -3574,8 +3591,14 @@ function getDataKeyForJson(keysParam, config) {
|
|
|
3574
3591
|
isCustomX = axis.isCustomX();
|
|
3575
3592
|
}
|
|
3576
3593
|
const dataKeys = Object.keys(data[0] || {});
|
|
3577
|
-
const ids = dataKeys.length ? dataKeys.
|
|
3578
|
-
|
|
3594
|
+
const { ids, xs } = dataKeys.length ? dataKeys.reduce((acc, key) => {
|
|
3595
|
+
if ($$.isX.call($$, key)) {
|
|
3596
|
+
acc.xs.push(key);
|
|
3597
|
+
} else if ($$.isNotX.call($$, key)) {
|
|
3598
|
+
acc.ids.push(key);
|
|
3599
|
+
}
|
|
3600
|
+
return acc;
|
|
3601
|
+
}, { ids: [], xs: [] }) : { ids: [], xs: [] };
|
|
3579
3602
|
let xsData;
|
|
3580
3603
|
ids.forEach((id) => {
|
|
3581
3604
|
const xKey = this.getXKey(id);
|
|
@@ -3603,7 +3626,10 @@ function getDataKeyForJson(keysParam, config) {
|
|
|
3603
3626
|
const convertedId = config.data_idConverter.bind($$.api)(id);
|
|
3604
3627
|
const xKey = $$.getXKey(id);
|
|
3605
3628
|
const isCategory = isCustomX && isCategorized;
|
|
3606
|
-
const hasCategory = isCategory &&
|
|
3629
|
+
const hasCategory = isCategory && (() => {
|
|
3630
|
+
const categorySet = new Set(config.axis_x_categories);
|
|
3631
|
+
return data.every((v) => categorySet.has(v.x));
|
|
3632
|
+
})();
|
|
3607
3633
|
const isDataAppend = data.__append__;
|
|
3608
3634
|
const xIndex = xKey === null && isDataAppend ? $$.api.data.values(id).length : 0;
|
|
3609
3635
|
return {
|
|
@@ -3867,9 +3893,10 @@ function getDataKeyForJson(keysParam, config) {
|
|
|
3867
3893
|
const minMax = $$.getMinMaxValue(data);
|
|
3868
3894
|
let min = [];
|
|
3869
3895
|
let max = [];
|
|
3896
|
+
const { min: minVal, max: maxVal } = minMax;
|
|
3870
3897
|
data.forEach((v) => {
|
|
3871
|
-
const minData = $$.getFilteredDataByValue(v,
|
|
3872
|
-
const maxData = $$.getFilteredDataByValue(v,
|
|
3898
|
+
const minData = $$.getFilteredDataByValue(v, minVal);
|
|
3899
|
+
const maxData = $$.getFilteredDataByValue(v, maxVal);
|
|
3873
3900
|
if (minData.length) {
|
|
3874
3901
|
min = min.concat(minData);
|
|
3875
3902
|
}
|
|
@@ -3897,7 +3924,7 @@ function getDataKeyForJson(keysParam, config) {
|
|
|
3897
3924
|
if (!sum[i]) {
|
|
3898
3925
|
sum[i] = 0;
|
|
3899
3926
|
}
|
|
3900
|
-
sum[i] +=
|
|
3927
|
+
sum[i] += ~~v.value;
|
|
3901
3928
|
});
|
|
3902
3929
|
});
|
|
3903
3930
|
}
|
|
@@ -3914,8 +3941,9 @@ function getDataKeyForJson(keysParam, config) {
|
|
|
3914
3941
|
const cacheKey = KEY.dataTotalSum;
|
|
3915
3942
|
let total = $$.cache.get(cacheKey);
|
|
3916
3943
|
if (!isNumber(total)) {
|
|
3917
|
-
|
|
3918
|
-
|
|
3944
|
+
total = $$.data.targets.reduce((acc, t) => {
|
|
3945
|
+
return acc + t.values.reduce((sum, v) => sum + ~~v.value, 0);
|
|
3946
|
+
}, 0);
|
|
3919
3947
|
$$.cache.add(cacheKey, total);
|
|
3920
3948
|
}
|
|
3921
3949
|
if (subtractHidden) {
|
|
@@ -4079,17 +4107,7 @@ function getDataKeyForJson(keysParam, config) {
|
|
|
4079
4107
|
return ys;
|
|
4080
4108
|
},
|
|
4081
4109
|
checkValueInTargets(targets, checker) {
|
|
4082
|
-
|
|
4083
|
-
let values;
|
|
4084
|
-
for (let i = 0; i < ids.length; i++) {
|
|
4085
|
-
values = targets[ids[i]].values;
|
|
4086
|
-
for (let j = 0; j < values.length; j++) {
|
|
4087
|
-
if (checker(values[j].value)) {
|
|
4088
|
-
return true;
|
|
4089
|
-
}
|
|
4090
|
-
}
|
|
4091
|
-
}
|
|
4092
|
-
return false;
|
|
4110
|
+
return Object.keys(targets).some((id) => targets[id].values.some((v) => checker(v.value)));
|
|
4093
4111
|
},
|
|
4094
4112
|
hasMultiTargets() {
|
|
4095
4113
|
return this.filterTargetsToShow().length > 1;
|
|
@@ -4143,6 +4161,12 @@ function getDataKeyForJson(keysParam, config) {
|
|
|
4143
4161
|
filterByX(targets, x) {
|
|
4144
4162
|
return mergeArray(targets.map((t) => t.values)).filter((v) => v.x - x === 0);
|
|
4145
4163
|
},
|
|
4164
|
+
filterNullish(data) {
|
|
4165
|
+
const filter = (v) => isValue(v.value);
|
|
4166
|
+
return data ? data.filter(
|
|
4167
|
+
(v) => "value" in v ? filter(v) : v.values.some(filter)
|
|
4168
|
+
) : data;
|
|
4169
|
+
},
|
|
4146
4170
|
filterRemoveNull(data) {
|
|
4147
4171
|
return data.filter((d) => isValue(this.getBaseValue(d)));
|
|
4148
4172
|
},
|
|
@@ -4210,13 +4234,12 @@ function getDataKeyForJson(keysParam, config) {
|
|
|
4210
4234
|
return index;
|
|
4211
4235
|
},
|
|
4212
4236
|
getDataLabelLength(min, max, key) {
|
|
4237
|
+
var _a;
|
|
4213
4238
|
const $$ = this;
|
|
4214
|
-
const lengths = [0, 0];
|
|
4215
4239
|
const paddingCoef = 1.3;
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
return lengths;
|
|
4240
|
+
return ((_a = $$.getTextRect(
|
|
4241
|
+
[min, max].map((v) => $$.dataLabelFormat()(v))
|
|
4242
|
+
)) == null ? void 0 : _a.map((rect) => rect[key] * paddingCoef)) || [0, 0];
|
|
4220
4243
|
},
|
|
4221
4244
|
isNoneArc(d) {
|
|
4222
4245
|
return this.hasTarget(this.data.targets, d.id);
|
|
@@ -4398,9 +4421,7 @@ function getDataKeyForJson(keysParam, config) {
|
|
|
4398
4421
|
if (state.hiddenTargetIds.length) {
|
|
4399
4422
|
let hiddenSum = dataValues(state.hiddenTargetIds, false);
|
|
4400
4423
|
if (hiddenSum.length) {
|
|
4401
|
-
hiddenSum = hiddenSum.reduce(
|
|
4402
|
-
(acc, curr) => acc.map((v, i) => (isNumber(v) ? v : 0) + curr[i])
|
|
4403
|
-
);
|
|
4424
|
+
hiddenSum = hiddenSum.reduce((acc, curr) => acc.map((v, i) => ~~v + curr[i]));
|
|
4404
4425
|
total = total.map((v, i) => v - hiddenSum[i]);
|
|
4405
4426
|
}
|
|
4406
4427
|
}
|
|
@@ -4461,7 +4482,7 @@ function getDataKeyForJson(keysParam, config) {
|
|
|
4461
4482
|
isBarRangeType(d) {
|
|
4462
4483
|
const $$ = this;
|
|
4463
4484
|
const { value } = d;
|
|
4464
|
-
return $$.isBarType(d) && isArray(value) && value.length >= 2 && value.every(
|
|
4485
|
+
return $$.isBarType(d) && isArray(value) && value.length >= 2 && value.every(isNumber);
|
|
4465
4486
|
},
|
|
4466
4487
|
/**
|
|
4467
4488
|
* Get data object by id
|
|
@@ -4647,7 +4668,7 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
|
|
|
4647
4668
|
if (isArcishData || d !== -1) {
|
|
4648
4669
|
const callback = config[isOver ? "data_onover" : "data_onout"].bind($$.api);
|
|
4649
4670
|
config.color_onover && $$.setOverColor(isOver, d, isArcishData);
|
|
4650
|
-
if (isArcishData
|
|
4671
|
+
if (isArcishData) {
|
|
4651
4672
|
const suffix = $$.getTargetSelectorSuffix(d.id);
|
|
4652
4673
|
const selector = hasFunnel || hasTreemap ? `${$COMMON.target + suffix} .${$SHAPE.shape}` : $ARC.arc + suffix;
|
|
4653
4674
|
callback(d, main.select(`.${selector}`).node());
|
|
@@ -4741,7 +4762,7 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
|
|
|
4741
4762
|
if (element) {
|
|
4742
4763
|
const isMultipleX = $$.isMultipleX();
|
|
4743
4764
|
const isRotated = config.axis_rotated;
|
|
4744
|
-
let { width, left, top } = element
|
|
4765
|
+
let { width, left, top } = getBoundingRect(element);
|
|
4745
4766
|
if (hasAxis && !hasRadar && !isMultipleX) {
|
|
4746
4767
|
const coords = eventReceiver.coords[index];
|
|
4747
4768
|
if (coords) {
|
|
@@ -4979,8 +5000,6 @@ const schemeCategory10 = [
|
|
|
4979
5000
|
generateColor() {
|
|
4980
5001
|
const $$ = this;
|
|
4981
5002
|
const { $el, config } = $$;
|
|
4982
|
-
const colors = config.data_colors;
|
|
4983
|
-
const callback = config.data_color;
|
|
4984
5003
|
const ids = [];
|
|
4985
5004
|
let pattern = notEmpty(config.color_pattern) ? config.color_pattern : (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleOrdinal)(getColorFromCss($el.chart) || schemeCategory10).range();
|
|
4986
5005
|
const originalColorPattern = pattern;
|
|
@@ -4996,6 +5015,8 @@ const schemeCategory10 = [
|
|
|
4996
5015
|
}
|
|
4997
5016
|
return function(d) {
|
|
4998
5017
|
var _a;
|
|
5018
|
+
const colors = config.data_colors;
|
|
5019
|
+
const callback = config.data_color;
|
|
4999
5020
|
const id = d.id || ((_a = d.data) == null ? void 0 : _a.id) || d;
|
|
5000
5021
|
const isLine = $$.isTypeOf(id, ["line", "spline", "step"]) || !config.data_types[id];
|
|
5001
5022
|
let color;
|
|
@@ -5256,7 +5277,10 @@ const schemeCategory10 = [
|
|
|
5256
5277
|
}
|
|
5257
5278
|
if (showHorizontalDataLabel) {
|
|
5258
5279
|
const diff = diffDomain(scale.y.range());
|
|
5259
|
-
const ratio = $$.getDataLabelLength(yDomainMin, yDomainMax, "width").map((v) =>
|
|
5280
|
+
const ratio = $$.getDataLabelLength(yDomainMin, yDomainMax, "width").map((v) => {
|
|
5281
|
+
const result = v / diff;
|
|
5282
|
+
return isFinite(result) ? result : 0;
|
|
5283
|
+
});
|
|
5260
5284
|
["bottom", "top"].forEach((v, i) => {
|
|
5261
5285
|
padding[v] += domainLength * (ratio[i] / (1 - ratio[0] - ratio[1]));
|
|
5262
5286
|
});
|
|
@@ -6633,7 +6657,7 @@ function getScale(type = "linear", min, max) {
|
|
|
6633
6657
|
let v = 0;
|
|
6634
6658
|
while (v < 30 && parent && parent.tagName !== "BODY") {
|
|
6635
6659
|
try {
|
|
6636
|
-
v = parent
|
|
6660
|
+
v = getBoundingRect(parent, true)[key];
|
|
6637
6661
|
} catch (e) {
|
|
6638
6662
|
if (offsetName in parent) {
|
|
6639
6663
|
v = parent[offsetName];
|
|
@@ -6668,11 +6692,11 @@ function getScale(type = "linear", min, max) {
|
|
|
6668
6692
|
if (hasAxis && (isString(leftLabel) || isString(leftLabel.text) || /^inner-/.test(leftLabel == null ? void 0 : leftLabel.position))) {
|
|
6669
6693
|
const label = $el.main.select(`.${leftAxisClass}-label`);
|
|
6670
6694
|
if (!label.empty()) {
|
|
6671
|
-
labelWidth = label.node()
|
|
6695
|
+
labelWidth = getBoundingRect(label.node()).left;
|
|
6672
6696
|
}
|
|
6673
6697
|
}
|
|
6674
|
-
const svgRect = leftAxis && hasLeftAxisRect ? leftAxis
|
|
6675
|
-
const chartRectLeft = $el.chart.node()
|
|
6698
|
+
const svgRect = leftAxis && hasLeftAxisRect ? getBoundingRect(leftAxis, !withoutRecompute) : { right: 0 };
|
|
6699
|
+
const chartRectLeft = getBoundingRect($el.chart.node(), !withoutRecompute).left + labelWidth;
|
|
6676
6700
|
const hasArc = $$.hasArcType();
|
|
6677
6701
|
const svgLeft = svgRect.right - chartRectLeft - (hasArc ? 0 : $$.getCurrentPaddingByDirection("left", withoutRecompute));
|
|
6678
6702
|
return svgLeft > 0 ? svgLeft : 0;
|
|
@@ -7016,7 +7040,7 @@ function getTextPos(d, type) {
|
|
|
7016
7040
|
const classChartText = $$.getChartClass("Text");
|
|
7017
7041
|
const classTexts = $$.getClass("texts", "id");
|
|
7018
7042
|
const classFocus = $$.classFocus.bind($$);
|
|
7019
|
-
const mainTextUpdate = $$.$el.main.select(`.${$TEXT.chartTexts}`).selectAll(`.${$TEXT.chartText}`).data(targets).attr("class", (d) => `${classChartText(d)}${classFocus(d)}`.trim());
|
|
7043
|
+
const mainTextUpdate = $$.$el.main.select(`.${$TEXT.chartTexts}`).selectAll(`.${$TEXT.chartText}`).data($$.filterNullish(targets)).attr("class", (d) => `${classChartText(d)}${classFocus(d)}`.trim());
|
|
7020
7044
|
const mainTextEnter = mainTextUpdate.enter().append("g").style("opacity", "0").attr("class", classChartText).call(
|
|
7021
7045
|
$$.setCssRule(
|
|
7022
7046
|
true,
|
|
@@ -7155,27 +7179,35 @@ function getTextPos(d, type) {
|
|
|
7155
7179
|
},
|
|
7156
7180
|
/**
|
|
7157
7181
|
* Gets the getBoundingClientRect value of the element
|
|
7158
|
-
* @param {HTMLElement|d3.selection}
|
|
7182
|
+
* @param {HTMLElement|d3.selection|Array} source Target element
|
|
7159
7183
|
* @param {string} className Class name
|
|
7160
7184
|
* @returns {object} value of element.getBoundingClientRect()
|
|
7161
7185
|
* @private
|
|
7162
7186
|
*/
|
|
7163
|
-
getTextRect(
|
|
7187
|
+
getTextRect(source, className) {
|
|
7188
|
+
var _a, _b;
|
|
7164
7189
|
const $$ = this;
|
|
7165
|
-
let
|
|
7166
|
-
|
|
7167
|
-
|
|
7190
|
+
let cacheKey;
|
|
7191
|
+
let base;
|
|
7192
|
+
let text;
|
|
7193
|
+
if (Array.isArray(source)) {
|
|
7194
|
+
cacheKey = `${KEY.textRect}-${source.join("_")}`;
|
|
7195
|
+
} else {
|
|
7196
|
+
base = (_b = (_a = source.node) == null ? void 0 : _a.call(source)) != null ? _b : source;
|
|
7197
|
+
if (!/text/i.test(base.tagName)) {
|
|
7198
|
+
base = base.querySelector("text");
|
|
7199
|
+
}
|
|
7200
|
+
text = base.textContent;
|
|
7201
|
+
cacheKey = `${KEY.textRect}-${text.replace(/\W/g, "_")}`;
|
|
7168
7202
|
}
|
|
7169
|
-
const
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
$$.$el.svg.append("text").style("visibility", "hidden").style("font", (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(base).style("font")).classed(className, true).text(text).call((v) => {
|
|
7174
|
-
rect = getBoundingRect(v.node());
|
|
7203
|
+
const rect = $$.cache.get(cacheKey) || [];
|
|
7204
|
+
if (rect.length === 0) {
|
|
7205
|
+
($$.$el.svg || $$.$el.chart.select("svg")).selectAll(`.${$COMMON.dummy}`).data(text ? [text] : source).enter().append("text").style("visibility", "hidden").style("font", base ? (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(base).style("font") : null).classed(className || $COMMON.dummy, true).text((d) => d).each(function(v, i) {
|
|
7206
|
+
rect[i] = getBoundingRect(this);
|
|
7175
7207
|
}).remove();
|
|
7176
7208
|
$$.cache.add(cacheKey, rect);
|
|
7177
7209
|
}
|
|
7178
|
-
return rect;
|
|
7210
|
+
return rect.length > 1 ? rect : rect[0];
|
|
7179
7211
|
},
|
|
7180
7212
|
/**
|
|
7181
7213
|
* Gets the x or y coordinate of the text
|
|
@@ -7705,7 +7737,7 @@ function getTextXPos(pos = "left", width) {
|
|
|
7705
7737
|
y = isRotated ? currPos.xAxis : y;
|
|
7706
7738
|
}
|
|
7707
7739
|
const ctm = getTransformCTM(target, x, y, false);
|
|
7708
|
-
const rect = target
|
|
7740
|
+
const rect = getBoundingRect(target);
|
|
7709
7741
|
const size = getTransformCTM(target, 20, 0, false).x;
|
|
7710
7742
|
let top = ctm.y;
|
|
7711
7743
|
let left = ctm.x + tWidth / 2 + size;
|
|
@@ -8658,7 +8690,7 @@ function getGroupedDataPointsFn(d) {
|
|
|
8658
8690
|
const x = Math.min(seg0.x, seg1.x);
|
|
8659
8691
|
const y = Math.min(seg0.y, seg1.y);
|
|
8660
8692
|
const offset = this.config.bar_sensitivity;
|
|
8661
|
-
const { width, height } =
|
|
8693
|
+
const { width, height } = getBBox(that, true);
|
|
8662
8694
|
const sx = x - offset;
|
|
8663
8695
|
const ex = x + width + offset;
|
|
8664
8696
|
const sy = y + height + offset;
|
|
@@ -8958,7 +8990,7 @@ class ChartInternal {
|
|
|
8958
8990
|
if (hasAxis || hasColorPatterns || hasPolar || hasTreemap || labelsBGColor || ((_a = $$.hasLegendDefsPoint) == null ? void 0 : _a.call($$))) {
|
|
8959
8991
|
$el.defs = $el.svg.append("defs");
|
|
8960
8992
|
if (hasAxis) {
|
|
8961
|
-
["id", "idXAxis", "idYAxis", "idGrid"].forEach((v) => {
|
|
8993
|
+
["id", "idXAxis", "idYAxis", "idY2Axis", "idGrid"].forEach((v) => {
|
|
8962
8994
|
$$.appendClip($el.defs, state.clip[v]);
|
|
8963
8995
|
});
|
|
8964
8996
|
}
|
|
@@ -9349,6 +9381,9 @@ function loadConfig(config) {
|
|
|
9349
9381
|
(_b = $$.axis) == null ? void 0 : _b.setOrient();
|
|
9350
9382
|
}
|
|
9351
9383
|
zoomResetBtn == null ? void 0 : zoomResetBtn.style("display", "none");
|
|
9384
|
+
if ($$.scale.zoom) {
|
|
9385
|
+
state.current.zoomDomain = $$.scale.zoom.domain();
|
|
9386
|
+
}
|
|
9352
9387
|
$$.scale.zoom = null;
|
|
9353
9388
|
soft ? $$.redraw({
|
|
9354
9389
|
withTransform: true,
|
|
@@ -9364,6 +9399,10 @@ function loadConfig(config) {
|
|
|
9364
9399
|
$$.brush.getSelection().call($$.brush.move);
|
|
9365
9400
|
$$.unselectRect();
|
|
9366
9401
|
}
|
|
9402
|
+
if (state.current.zoomDomain) {
|
|
9403
|
+
$$.api.zoom(state.current.zoomDomain);
|
|
9404
|
+
state.current.zoomDomain = null;
|
|
9405
|
+
}
|
|
9367
9406
|
} else {
|
|
9368
9407
|
$$.initToRender(true);
|
|
9369
9408
|
}
|
|
@@ -9674,9 +9713,9 @@ function nodeToSvgDataUrl(node, option, orgSize) {
|
|
|
9674
9713
|
}
|
|
9675
9714
|
function getCoords(elem, svgOffset) {
|
|
9676
9715
|
const { top, left } = svgOffset;
|
|
9677
|
-
const { x, y } =
|
|
9716
|
+
const { x, y } = getBBox(elem, true);
|
|
9678
9717
|
const { a, b, c, d, e, f } = elem.getScreenCTM();
|
|
9679
|
-
const { width, height } = elem
|
|
9718
|
+
const { width, height } = getBoundingRect(elem, true);
|
|
9680
9719
|
return {
|
|
9681
9720
|
x: a * x + c * y + e - left,
|
|
9682
9721
|
y: b * x + d * y + f - top + (height - Math.round(height / 4)),
|
|
@@ -9685,7 +9724,7 @@ function getCoords(elem, svgOffset) {
|
|
|
9685
9724
|
};
|
|
9686
9725
|
}
|
|
9687
9726
|
function getGlyph(svg) {
|
|
9688
|
-
const { left, top } = svg
|
|
9727
|
+
const { left, top } = getBoundingRect(svg);
|
|
9689
9728
|
const filterFn = (t) => t.textContent || t.childElementCount;
|
|
9690
9729
|
const glyph = [];
|
|
9691
9730
|
toArray(svg.querySelectorAll("text")).filter(filterFn).forEach((t) => {
|
|
@@ -12803,7 +12842,7 @@ class AxisRendererHelper {
|
|
|
12803
12842
|
};
|
|
12804
12843
|
!text.empty() && text.text("0").call((el) => {
|
|
12805
12844
|
try {
|
|
12806
|
-
const { width, height } = el.node()
|
|
12845
|
+
const { width, height } = getBBox(el.node(), true);
|
|
12807
12846
|
if (width && height) {
|
|
12808
12847
|
size.w = width;
|
|
12809
12848
|
size.h = height;
|
|
@@ -12904,6 +12943,7 @@ var AxisRenderer_publicField = (obj, key, value) => AxisRenderer_defNormalProp(o
|
|
|
12904
12943
|
|
|
12905
12944
|
|
|
12906
12945
|
|
|
12946
|
+
|
|
12907
12947
|
class AxisRenderer {
|
|
12908
12948
|
constructor(params = {}) {
|
|
12909
12949
|
AxisRenderer_publicField(this, "helper");
|
|
@@ -12974,7 +13014,7 @@ class AxisRenderer {
|
|
|
12974
13014
|
return isTopBottom ? `M${range[0]},${outerTickSized}V0H${range[1]}V${outerTickSized}` : `M${outerTickSized},${range[0]}H0V${range[1]}H${outerTickSized}`;
|
|
12975
13015
|
});
|
|
12976
13016
|
if (tickShow.tick || tickShow.text) {
|
|
12977
|
-
const ticks = config.tickValues || helper.generateTicks(scale1, isLeftRight);
|
|
13017
|
+
const ticks = config.tickValues || helper.generateTicks(scale1, isLeftRight || params.config.axis_rotated);
|
|
12978
13018
|
ctx.generatedTicks = ticks;
|
|
12979
13019
|
let tick = g2.selectAll(".tick").data(ticks, scale1);
|
|
12980
13020
|
const tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick");
|
|
@@ -12983,8 +13023,17 @@ class AxisRenderer {
|
|
|
12983
13023
|
tickShow.tick && tickEnter.append("line");
|
|
12984
13024
|
tickShow.text && tickEnter.append("text");
|
|
12985
13025
|
const tickText = tick.select("text");
|
|
12986
|
-
const sizeFor1Char = isFunction(evalTextSize) ? evalTextSize.bind(ctx.params.owner.api)(tickText.node()) : AxisRendererHelper.getSizeFor1Char(tickText, evalTextSize);
|
|
12987
13026
|
const counts = [];
|
|
13027
|
+
let sizeFor1Char;
|
|
13028
|
+
if (isFunction(evalTextSize)) {
|
|
13029
|
+
sizeFor1Char = evalTextSize.bind(ctx.params.owner.api)(tickText.node(), id);
|
|
13030
|
+
if (this.classList.contains($COMMON.dummy)) {
|
|
13031
|
+
this.sizeFor1Char = sizeFor1Char;
|
|
13032
|
+
}
|
|
13033
|
+
}
|
|
13034
|
+
if (!sizeFor1Char) {
|
|
13035
|
+
sizeFor1Char = AxisRendererHelper.getSizeFor1Char(tickText, !!evalTextSize);
|
|
13036
|
+
}
|
|
12988
13037
|
let tspan = tickText.selectAll("tspan").data((d, index) => {
|
|
12989
13038
|
const split = params.tickMultiline ? splitTickText(d, scale1, ticks, isLeftRight, sizeFor1Char.w) : isArray(helper.textFormatted(d)) ? helper.textFormatted(d).concat() : [helper.textFormatted(d)];
|
|
12990
13039
|
counts[index] = split.length;
|
|
@@ -13720,14 +13769,14 @@ class Axis_Axis {
|
|
|
13720
13769
|
*/
|
|
13721
13770
|
getMaxTickSize(id, withoutRecompute) {
|
|
13722
13771
|
const $$ = this.owner;
|
|
13723
|
-
const { config, state: { current }, $el: { svg, chart } } = $$;
|
|
13772
|
+
const { config, state: { current, resizing }, $el: { svg, chart } } = $$;
|
|
13724
13773
|
const currentTickMax = current.maxTickSize[id];
|
|
13725
13774
|
const configPrefix = `axis_${id}`;
|
|
13726
13775
|
const max = {
|
|
13727
13776
|
width: 0,
|
|
13728
13777
|
height: 0
|
|
13729
13778
|
};
|
|
13730
|
-
if (withoutRecompute || !config[`${configPrefix}_show`] || currentTickMax.width > 0 && $$.filterTargetsToShow().length === 0) {
|
|
13779
|
+
if (resizing || withoutRecompute || !config[`${configPrefix}_show`] || currentTickMax.width > 0 && $$.filterTargetsToShow().length === 0) {
|
|
13731
13780
|
return currentTickMax;
|
|
13732
13781
|
}
|
|
13733
13782
|
if (svg) {
|
|
@@ -13762,9 +13811,14 @@ class Axis_Axis {
|
|
|
13762
13811
|
}
|
|
13763
13812
|
!isYAxis && this.updateXAxisTickValues(targetsToShow, axis);
|
|
13764
13813
|
const dummy = chart.append("svg").style("visibility", "hidden").style("position", "fixed").style("top", "0").style("left", "0");
|
|
13765
|
-
axis.
|
|
13814
|
+
const g = dummy.append("g").attr("class", `${$AXIS[`axis${capitalize(id)}`]} ${$COMMON.dummy}`);
|
|
13815
|
+
axis.create(g);
|
|
13816
|
+
const { sizeFor1Char } = g.node();
|
|
13766
13817
|
dummy.selectAll("text").attr("transform", isNumber(tickRotate) ? `rotate(${tickRotate})` : null).each(function(d, i) {
|
|
13767
|
-
const { width, height } =
|
|
13818
|
+
const { width, height } = sizeFor1Char ? {
|
|
13819
|
+
width: this.textContent.length * sizeFor1Char.w,
|
|
13820
|
+
height: sizeFor1Char.h
|
|
13821
|
+
} : getBoundingRect(this, true);
|
|
13768
13822
|
max.width = Math.max(max.width, width);
|
|
13769
13823
|
max.height = Math.max(max.height, height);
|
|
13770
13824
|
if (!isYAxis) {
|
|
@@ -14012,7 +14066,10 @@ class Axis_Axis {
|
|
|
14012
14066
|
const toCull = config[cullingOptionPrefix];
|
|
14013
14067
|
if (axis && toCull) {
|
|
14014
14068
|
const tickNodes = axis.selectAll(".tick");
|
|
14015
|
-
const tickValues = sortValue(
|
|
14069
|
+
const tickValues = sortValue(
|
|
14070
|
+
tickNodes.data(),
|
|
14071
|
+
!config[`${cullingOptionPrefix}_reverse`]
|
|
14072
|
+
);
|
|
14016
14073
|
const tickSize = tickValues.length;
|
|
14017
14074
|
const cullingMax = config[`${cullingOptionPrefix}_max`];
|
|
14018
14075
|
const lines = config[`${cullingOptionPrefix}_lines`];
|
|
@@ -14206,7 +14263,7 @@ class Axis_Axis {
|
|
|
14206
14263
|
const updateClientRect = () => {
|
|
14207
14264
|
if (eventReceiver) {
|
|
14208
14265
|
const scrollPos = getScrollPosition($el.chart.node());
|
|
14209
|
-
eventReceiver.rect = rectElement.node()
|
|
14266
|
+
eventReceiver.rect = getBoundingRect(rectElement.node(), true).toJSON();
|
|
14210
14267
|
eventReceiver.rect.top += scrollPos.y;
|
|
14211
14268
|
eventReceiver.rect.left += scrollPos.x;
|
|
14212
14269
|
}
|
|
@@ -15036,7 +15093,7 @@ function smoothLines(el, type) {
|
|
|
15036
15093
|
hideAxisGridFocus() {
|
|
15037
15094
|
const $$ = this;
|
|
15038
15095
|
$$.$el.main.selectAll(
|
|
15039
|
-
`line.
|
|
15096
|
+
`line.${$AXIS.axisTooltipX}, line.${$AXIS.axisTooltipY}`
|
|
15040
15097
|
).style("visibility", "hidden");
|
|
15041
15098
|
Object.values($$.$el.axisTooltip).forEach((v) => v == null ? void 0 : v.style("display", "none"));
|
|
15042
15099
|
},
|
|
@@ -15583,7 +15640,7 @@ function smoothLines(el, type) {
|
|
|
15583
15640
|
* axis: {
|
|
15584
15641
|
* x: {
|
|
15585
15642
|
* tick: {
|
|
15586
|
-
* culling: false
|
|
15643
|
+
* culling: false,
|
|
15587
15644
|
* }
|
|
15588
15645
|
* }
|
|
15589
15646
|
* }
|
|
@@ -15625,6 +15682,26 @@ function smoothLines(el, type) {
|
|
|
15625
15682
|
* }
|
|
15626
15683
|
*/
|
|
15627
15684
|
axis_x_tick_culling_lines: true,
|
|
15685
|
+
/**
|
|
15686
|
+
* Control culling start point to be reversed. If set to true, the culling will be started from the end to start.
|
|
15687
|
+
* - **NOTE:** This option is only available when `axis.x.tick.culling` is set to truthy value.
|
|
15688
|
+
* @name axis․x․tick․culling․reverse
|
|
15689
|
+
* @memberof Options
|
|
15690
|
+
* @type {boolean}
|
|
15691
|
+
* @default false
|
|
15692
|
+
* @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.XAxisTickCulling)
|
|
15693
|
+
* @example
|
|
15694
|
+
* axis: {
|
|
15695
|
+
* x: {
|
|
15696
|
+
* tick: {
|
|
15697
|
+
* culling: {
|
|
15698
|
+
* reverse: true,
|
|
15699
|
+
* }
|
|
15700
|
+
* }
|
|
15701
|
+
* }
|
|
15702
|
+
* }
|
|
15703
|
+
*/
|
|
15704
|
+
axis_x_tick_culling_reverse: false,
|
|
15628
15705
|
/**
|
|
15629
15706
|
* The number of x axis ticks to show.<br><br>
|
|
15630
15707
|
* This option hides tick lines together with tick text. If this option is used on timeseries axis, the ticks position will be determined precisely and not nicely positioned (e.g. it will have rough second value).
|
|
@@ -16358,6 +16435,25 @@ function smoothLines(el, type) {
|
|
|
16358
16435
|
* }
|
|
16359
16436
|
*/
|
|
16360
16437
|
axis_y_tick_culling_lines: true,
|
|
16438
|
+
/**
|
|
16439
|
+
* Control culling start point to be reversed. If set to true, the culling will be started from the end to start.
|
|
16440
|
+
* - **NOTE:** This option is only available when `axis.y.tick.culling` is set to truthy value.
|
|
16441
|
+
* @name axis․y․tick․culling․reverse
|
|
16442
|
+
* @memberof Options
|
|
16443
|
+
* @type {boolean}
|
|
16444
|
+
* @default false
|
|
16445
|
+
* @example
|
|
16446
|
+
* axis: {
|
|
16447
|
+
* y: {
|
|
16448
|
+
* tick: {
|
|
16449
|
+
* culling: {
|
|
16450
|
+
* reverse: true,
|
|
16451
|
+
* }
|
|
16452
|
+
* }
|
|
16453
|
+
* }
|
|
16454
|
+
* }
|
|
16455
|
+
*/
|
|
16456
|
+
axis_y_tick_culling_reverse: false,
|
|
16361
16457
|
/**
|
|
16362
16458
|
* Show y axis outer tick.
|
|
16363
16459
|
* @name axis․y․tick․outer
|
|
@@ -16613,6 +16709,18 @@ function smoothLines(el, type) {
|
|
|
16613
16709
|
|
|
16614
16710
|
;// ./src/config/Options/axis/y2.ts
|
|
16615
16711
|
/* harmony default export */ var y2 = ({
|
|
16712
|
+
/**
|
|
16713
|
+
* Set clip-path attribute for y2 axis element
|
|
16714
|
+
* - **NOTE**: `clip-path` attribute for y2 Axis is set only when `axis.y2.inner` option is true.
|
|
16715
|
+
* @name axis․y2․clipPath
|
|
16716
|
+
* @memberof Options
|
|
16717
|
+
* @type {boolean}
|
|
16718
|
+
* @default true
|
|
16719
|
+
* @example
|
|
16720
|
+
* // don't set 'clip-path' attribute
|
|
16721
|
+
* clipPath: false
|
|
16722
|
+
*/
|
|
16723
|
+
axis_y2_clipPath: true,
|
|
16616
16724
|
/**
|
|
16617
16725
|
* Show or hide y2 axis.
|
|
16618
16726
|
* - **NOTE**:
|
|
@@ -16827,6 +16935,25 @@ function smoothLines(el, type) {
|
|
|
16827
16935
|
* }
|
|
16828
16936
|
*/
|
|
16829
16937
|
axis_y2_tick_culling_lines: true,
|
|
16938
|
+
/**
|
|
16939
|
+
* Control culling start point to be reversed. If set to true, the culling will be started from the end to start.
|
|
16940
|
+
* - **NOTE:** This option is only available when `axis.y2.tick.culling` is set to truthy value.
|
|
16941
|
+
* @name axis․y2․tick․culling․reverse
|
|
16942
|
+
* @memberof Options
|
|
16943
|
+
* @type {boolean}
|
|
16944
|
+
* @default false
|
|
16945
|
+
* @example
|
|
16946
|
+
* axis: {
|
|
16947
|
+
* y2: {
|
|
16948
|
+
* tick: {
|
|
16949
|
+
* culling: {
|
|
16950
|
+
* reverse: true,
|
|
16951
|
+
* }
|
|
16952
|
+
* }
|
|
16953
|
+
* }
|
|
16954
|
+
* }
|
|
16955
|
+
*/
|
|
16956
|
+
axis_y2_tick_culling_reverse: false,
|
|
16830
16957
|
/**
|
|
16831
16958
|
* Show or hide y2 axis outer tick.
|
|
16832
16959
|
* @name axis․y2․tick․outer
|
|
@@ -17084,23 +17211,34 @@ var axis_spreadValues = (a, b) => {
|
|
|
17084
17211
|
* @memberof Options
|
|
17085
17212
|
* @type {boolean|Function}
|
|
17086
17213
|
* @default true
|
|
17214
|
+
* @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.AxisEvalTextSize)
|
|
17087
17215
|
* @example
|
|
17088
17216
|
* axis: {
|
|
17089
17217
|
* // will evaluate getting text size every time.
|
|
17090
17218
|
* evalTextSize: false.
|
|
17091
17219
|
*
|
|
17092
17220
|
* // set a custom evaluator
|
|
17093
|
-
* evalTextSize: function(textElement) {
|
|
17221
|
+
* evalTextSize: function(textElement, axisId) {
|
|
17094
17222
|
* // set some character to be evaluated
|
|
17095
|
-
*
|
|
17223
|
+
* // NOTE: The dummy textElement is a descendant of given axisId('x', 'y' or 'y2').
|
|
17224
|
+
* textElement.textContent = "0";
|
|
17096
17225
|
*
|
|
17097
17226
|
* // get the size
|
|
17098
|
-
*
|
|
17227
|
+
* const box = textElement.getBBox();
|
|
17099
17228
|
*
|
|
17100
17229
|
* // clear text
|
|
17101
|
-
*
|
|
17230
|
+
* textElement.textContent = "";
|
|
17102
17231
|
*
|
|
17103
17232
|
* return { w: 7, h: 12};
|
|
17233
|
+
* },
|
|
17234
|
+
*
|
|
17235
|
+
* // set a custom evaluator by returning fixed value
|
|
17236
|
+
* evalTextSize: function(textElement, axisId) {
|
|
17237
|
+
* return {
|
|
17238
|
+
* x: {w: 7, h: 12},
|
|
17239
|
+
* y: {w: 15.75, h: 30},
|
|
17240
|
+
* y2: {w: 9.5, h: 18}
|
|
17241
|
+
* }[axisId];
|
|
17104
17242
|
* }
|
|
17105
17243
|
* }
|
|
17106
17244
|
*/
|
|
@@ -17960,7 +18098,7 @@ function getAttrTweenFn(fn) {
|
|
|
17960
18098
|
value = config.arc_needle_value;
|
|
17961
18099
|
}
|
|
17962
18100
|
return tplProcess(title, {
|
|
17963
|
-
NEEDLE_VALUE:
|
|
18101
|
+
NEEDLE_VALUE: ~~value
|
|
17964
18102
|
});
|
|
17965
18103
|
}
|
|
17966
18104
|
return false;
|
|
@@ -18394,6 +18532,12 @@ function getAttrTweenFn(fn) {
|
|
|
18394
18532
|
;// ./src/ChartInternal/shape/bar.ts
|
|
18395
18533
|
|
|
18396
18534
|
|
|
18535
|
+
|
|
18536
|
+
function getConnectLineType(id) {
|
|
18537
|
+
const connectLine = this.config.bar_connectLine;
|
|
18538
|
+
const type = (connectLine == null ? void 0 : connectLine[id]) || connectLine;
|
|
18539
|
+
return /^(start|end)\-(start|end)$/.test(type) ? type : null;
|
|
18540
|
+
}
|
|
18397
18541
|
/* harmony default export */ var bar = ({
|
|
18398
18542
|
initBar() {
|
|
18399
18543
|
const { $el, config, state: { clip } } = this;
|
|
@@ -18414,17 +18558,19 @@ function getAttrTweenFn(fn) {
|
|
|
18414
18558
|
if (!$el.bar) {
|
|
18415
18559
|
$$.initBar();
|
|
18416
18560
|
}
|
|
18417
|
-
const mainBarUpdate = $el.main.select(`.${$BAR.chartBars}`).selectAll(`.${$BAR.chartBar}`).data(
|
|
18418
|
-
// remove
|
|
18419
|
-
targets.filter(
|
|
18420
|
-
(v) => v.values.some((d) => isNumber(d.value) || $$.isBarRangeType(d))
|
|
18421
|
-
)
|
|
18422
|
-
).attr("class", (d) => classChartBar(d) + classFocus(d));
|
|
18561
|
+
const mainBarUpdate = $el.main.select(`.${$BAR.chartBars}`).selectAll(`.${$BAR.chartBar}`).data($$.filterNullish(targets)).attr("class", (d) => classChartBar(d) + classFocus(d));
|
|
18423
18562
|
const mainBarEnter = mainBarUpdate.enter().append("g").attr("class", classChartBar).style("opacity", "0").style("pointer-events", $$.getStylePropValue("none"));
|
|
18424
18563
|
mainBarEnter.append("g").attr("class", classBars).style("cursor", (d) => {
|
|
18425
18564
|
var _a;
|
|
18426
18565
|
return ((_a = isSelectable == null ? void 0 : isSelectable.bind) == null ? void 0 : _a.call(isSelectable, $$.api)(d)) ? "pointer" : null;
|
|
18427
|
-
}).call(
|
|
18566
|
+
}).call((selection) => {
|
|
18567
|
+
$$.setCssRule(true, ` .${$BAR.bar}`, ["fill"], $$.color)(selection);
|
|
18568
|
+
selection.each(function(d) {
|
|
18569
|
+
if (getConnectLineType.call($$, d.id)) {
|
|
18570
|
+
(0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).append("path").attr("class", $BAR.barConnectLine);
|
|
18571
|
+
}
|
|
18572
|
+
});
|
|
18573
|
+
});
|
|
18428
18574
|
},
|
|
18429
18575
|
/**
|
|
18430
18576
|
* Generate/Update elements
|
|
@@ -18466,8 +18612,25 @@ function getAttrTweenFn(fn) {
|
|
|
18466
18612
|
redrawBar(drawFn, withTransition, isSub = false) {
|
|
18467
18613
|
const $$ = this;
|
|
18468
18614
|
const { bar } = isSub ? $$.$el.subchart : $$.$el;
|
|
18615
|
+
const barPath = [];
|
|
18469
18616
|
return [
|
|
18470
|
-
$$.$T(bar, withTransition, getRandom()).attr("d", (d
|
|
18617
|
+
$$.$T(bar, withTransition, getRandom()).attr("d", function(d, i, arr) {
|
|
18618
|
+
const path = (isNumber(d.value) || $$.isBarRangeType(d)) && drawFn(d, i);
|
|
18619
|
+
const connectLineType = getConnectLineType.call($$, d.id);
|
|
18620
|
+
if (path.length > 1) {
|
|
18621
|
+
barPath.push(path[1]);
|
|
18622
|
+
if (i === arr.length - 1) {
|
|
18623
|
+
const barConnectLineNode = $$.$T(
|
|
18624
|
+
(0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this.parentNode.querySelector(`.${$BAR.barConnectLine}`)),
|
|
18625
|
+
withTransition,
|
|
18626
|
+
getRandom()
|
|
18627
|
+
);
|
|
18628
|
+
$$.updateConnectLine(barConnectLineNode, connectLineType, barPath);
|
|
18629
|
+
barPath.splice(0);
|
|
18630
|
+
}
|
|
18631
|
+
}
|
|
18632
|
+
return path[0];
|
|
18633
|
+
}).style("fill", $$.updateBarColor.bind($$)).style("clip-path", (d) => d.clipPath).style("opacity", null)
|
|
18471
18634
|
];
|
|
18472
18635
|
},
|
|
18473
18636
|
/**
|
|
@@ -18544,7 +18707,21 @@ function getAttrTweenFn(fn) {
|
|
|
18544
18707
|
}
|
|
18545
18708
|
}
|
|
18546
18709
|
const path = isRotated ? `H${pos} ${pathRadius[0]}V${points[2][indexY] - radius} ${pathRadius[1]}H${points[3][indexX]}` : `V${pos} ${pathRadius[0]}H${points[2][indexX] - radius} ${pathRadius[1]}V${points[3][indexY]}`;
|
|
18547
|
-
|
|
18710
|
+
const coords = [`M${points[0][indexX]},${points[0][indexY]}${path}z`];
|
|
18711
|
+
if (getConnectLineType.call($$, d.id)) {
|
|
18712
|
+
coords.push(isRotated ? {
|
|
18713
|
+
x: points[0][indexX],
|
|
18714
|
+
y: points[0][indexY],
|
|
18715
|
+
width: points[0][indexX] - pos,
|
|
18716
|
+
height: points[2][indexY] - points[0][indexY]
|
|
18717
|
+
} : {
|
|
18718
|
+
x: points[0][indexX],
|
|
18719
|
+
y: pos,
|
|
18720
|
+
width: points[2][indexX] - points[0][indexX],
|
|
18721
|
+
height: points[3][indexY] - pos
|
|
18722
|
+
});
|
|
18723
|
+
}
|
|
18724
|
+
return coords;
|
|
18548
18725
|
};
|
|
18549
18726
|
},
|
|
18550
18727
|
/**
|
|
@@ -18611,6 +18788,34 @@ function getAttrTweenFn(fn) {
|
|
|
18611
18788
|
[startPosX, offset]
|
|
18612
18789
|
];
|
|
18613
18790
|
};
|
|
18791
|
+
},
|
|
18792
|
+
/**
|
|
18793
|
+
* Update the bar connect line path
|
|
18794
|
+
* @param {d3Selection} node d3 selection of bar connect line
|
|
18795
|
+
* @param {string} type Type of connect line, one of "start-start", "start-end", "end-start", "end-end"
|
|
18796
|
+
* @param {Array} barPath d3 path data for the bar
|
|
18797
|
+
*/
|
|
18798
|
+
updateConnectLine(node, type, barPath) {
|
|
18799
|
+
const path = barPath.map((v, i, arr) => {
|
|
18800
|
+
const isRotated = this.config.axis_rotated;
|
|
18801
|
+
const isStart = /^start-(start|end)$/.test(type);
|
|
18802
|
+
const isEnd = /^end-(start|end)$/.test(type);
|
|
18803
|
+
const path2 = [];
|
|
18804
|
+
const x = isRotated ? isEnd ? v.x - v.width : v.x : v.x + v.width;
|
|
18805
|
+
const y = isRotated ? v.y + v.height : isStart ? v.y + v.height : v.y;
|
|
18806
|
+
if (i === 0) {
|
|
18807
|
+
path2.push(`${x},${y}`);
|
|
18808
|
+
} else {
|
|
18809
|
+
path2.push(
|
|
18810
|
+
isRotated ? `L${v.x - (/\w+-end$/.test(type) ? v.width : 0)},${v.y}` : `L${v.x},${v.y + (/\w+-start$/.test(type) ? v.height : 0)}`
|
|
18811
|
+
);
|
|
18812
|
+
if (i < arr.length - 1) {
|
|
18813
|
+
path2.push(`M${x},${y}`);
|
|
18814
|
+
}
|
|
18815
|
+
}
|
|
18816
|
+
return path2.join(" ");
|
|
18817
|
+
});
|
|
18818
|
+
node.attr("d", `M${path.join("")}z`);
|
|
18614
18819
|
}
|
|
18615
18820
|
});
|
|
18616
18821
|
|
|
@@ -18714,7 +18919,7 @@ var candlestick_spreadValues = (a, b) => {
|
|
|
18714
18919
|
if (!$el.candlestick) {
|
|
18715
18920
|
$$.initCandlestick();
|
|
18716
18921
|
}
|
|
18717
|
-
const mainUpdate = $$.$el.main.select(`.${$CANDLESTICK.chartCandlesticks}`).selectAll(`.${$CANDLESTICK.chartCandlestick}`).data(targets);
|
|
18922
|
+
const mainUpdate = $$.$el.main.select(`.${$CANDLESTICK.chartCandlesticks}`).selectAll(`.${$CANDLESTICK.chartCandlestick}`).data($$.filterNullish(targets));
|
|
18718
18923
|
mainUpdate.enter().append("g").attr("class", classChart).style("pointer-events", "none");
|
|
18719
18924
|
},
|
|
18720
18925
|
/**
|
|
@@ -19065,7 +19270,7 @@ function updateRatio(data) {
|
|
|
19065
19270
|
$$.initFunnel();
|
|
19066
19271
|
}
|
|
19067
19272
|
const targets = getFunnelData.call($$, t.filter($$.isFunnelType.bind($$)));
|
|
19068
|
-
const mainFunnelUpdate = funnel.selectAll(`.${$FUNNEL.chartFunnel}`).data(targets);
|
|
19273
|
+
const mainFunnelUpdate = funnel.selectAll(`.${$FUNNEL.chartFunnel}`).data($$.filterNullish(targets));
|
|
19069
19274
|
mainFunnelUpdate.exit().remove();
|
|
19070
19275
|
const mainFunnelEnter = mainFunnelUpdate.enter().insert("g", `.${$FUNNEL.funnelBackground}`);
|
|
19071
19276
|
mainFunnelEnter.append("path");
|
|
@@ -19199,6 +19404,25 @@ function updateRatio(data) {
|
|
|
19199
19404
|
});
|
|
19200
19405
|
|
|
19201
19406
|
;// ./src/ChartInternal/shape/line.ts
|
|
19407
|
+
var line_defProp = Object.defineProperty;
|
|
19408
|
+
var line_defProps = Object.defineProperties;
|
|
19409
|
+
var line_getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
19410
|
+
var line_getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
19411
|
+
var line_hasOwnProp = Object.prototype.hasOwnProperty;
|
|
19412
|
+
var line_propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
19413
|
+
var line_defNormalProp = (obj, key, value) => key in obj ? line_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
19414
|
+
var line_spreadValues = (a, b) => {
|
|
19415
|
+
for (var prop in b || (b = {}))
|
|
19416
|
+
if (line_hasOwnProp.call(b, prop))
|
|
19417
|
+
line_defNormalProp(a, prop, b[prop]);
|
|
19418
|
+
if (line_getOwnPropSymbols)
|
|
19419
|
+
for (var prop of line_getOwnPropSymbols(b)) {
|
|
19420
|
+
if (line_propIsEnum.call(b, prop))
|
|
19421
|
+
line_defNormalProp(a, prop, b[prop]);
|
|
19422
|
+
}
|
|
19423
|
+
return a;
|
|
19424
|
+
};
|
|
19425
|
+
var line_spreadProps = (a, b) => line_defProps(a, line_getOwnPropDescs(b));
|
|
19202
19426
|
|
|
19203
19427
|
|
|
19204
19428
|
|
|
@@ -19249,7 +19473,7 @@ function getRegions(d, _regions, isTimeSeries) {
|
|
|
19249
19473
|
$$.initLine();
|
|
19250
19474
|
}
|
|
19251
19475
|
const targets = t.filter((d) => !($$.isScatterType(d) || $$.isBubbleType(d)));
|
|
19252
|
-
const mainLineUpdate = main.select(`.${$LINE.chartLines}`).selectAll(`.${$LINE.chartLine}`).data(targets).attr("class", (d) => classChartLine(d) + classFocus(d));
|
|
19476
|
+
const mainLineUpdate = main.select(`.${$LINE.chartLines}`).selectAll(`.${$LINE.chartLine}`).data($$.filterNullish(targets)).attr("class", (d) => classChartLine(d) + classFocus(d));
|
|
19253
19477
|
const mainLineEnter = mainLineUpdate.enter().append("g").attr("class", classChartLine).style("opacity", "0").style("pointer-events", $$.getStylePropValue("none"));
|
|
19254
19478
|
mainLineEnter.append("g").attr("class", classLines);
|
|
19255
19479
|
if ($$.hasTypeOf("Area")) {
|
|
@@ -19338,6 +19562,9 @@ function getRegions(d, _regions, isTimeSeries) {
|
|
|
19338
19562
|
if ($$.isLineType(d)) {
|
|
19339
19563
|
const regions = config.data_regions[d.id];
|
|
19340
19564
|
if (regions) {
|
|
19565
|
+
if ($$.isAreaRangeType(d)) {
|
|
19566
|
+
values = values.map((dv) => line_spreadProps(line_spreadValues({}, dv), { value: $$.getRangedData(dv, "mid") }));
|
|
19567
|
+
}
|
|
19341
19568
|
path = $$.lineWithRegions(values, scale.zoom || x, y, regions);
|
|
19342
19569
|
} else {
|
|
19343
19570
|
if ($$.isStepType(d)) {
|
|
@@ -19546,7 +19773,7 @@ const getTransitionName = () => getRandom();
|
|
|
19546
19773
|
let targets = targetsValue;
|
|
19547
19774
|
let enterNode = enterNodeValue;
|
|
19548
19775
|
if (!targets) {
|
|
19549
|
-
targets = data.targets.filter((d) => this.isScatterType(d) || this.isBubbleType(d));
|
|
19776
|
+
targets = $$.filterNullish(data.targets).filter((d) => this.isScatterType(d) || this.isBubbleType(d));
|
|
19550
19777
|
const mainCircle = $el.main.select(`.${$CIRCLE.chartCircles}`).style("pointer-events", "none").selectAll(`.${$CIRCLE.circles}`).data(targets);
|
|
19551
19778
|
mainCircle.exit().remove();
|
|
19552
19779
|
enterNode = mainCircle.enter();
|
|
@@ -19574,7 +19801,10 @@ const getTransitionName = () => getRandom();
|
|
|
19574
19801
|
const $root = isSub ? $el.subchart : $el;
|
|
19575
19802
|
if (config.point_show && !state.toggling) {
|
|
19576
19803
|
config.point_radialGradient && $$.updateLinearGradient();
|
|
19577
|
-
const circles = $root.main.selectAll(`.${$CIRCLE.circles}`).selectAll(`.${$CIRCLE.circle}`).data((d) =>
|
|
19804
|
+
const circles = $root.main.selectAll(`.${$CIRCLE.circles}`).selectAll(`.${$CIRCLE.circle}`).data((d) => {
|
|
19805
|
+
const data = $$.isLineType(d) && $$.shouldDrawPointsForLine(d) || $$.isBubbleType(d) || $$.isRadarType(d) || $$.isScatterType(d) ? focusOnly ? [d.values[0]] : d.values : [];
|
|
19806
|
+
return $$.filterNullish(data);
|
|
19807
|
+
});
|
|
19578
19808
|
circles.exit().remove();
|
|
19579
19809
|
circles.enter().filter(Boolean).append(
|
|
19580
19810
|
$$.point("create", this, $$.pointR.bind($$), $$.updateCircleColor.bind($$))
|
|
@@ -19703,7 +19933,7 @@ const getTransitionName = () => getRandom();
|
|
|
19703
19933
|
if (this.tagName === "circle") {
|
|
19704
19934
|
point.attr("r", r);
|
|
19705
19935
|
} else {
|
|
19706
|
-
const { width, height } =
|
|
19936
|
+
const { width, height } = getBBox(this);
|
|
19707
19937
|
const x = ratio * (+point.attr("x") + width / 2);
|
|
19708
19938
|
const y = ratio * (+point.attr("y") + height / 2);
|
|
19709
19939
|
point.attr("transform", `translate(${x} ${y}) scale(${scale})`);
|
|
@@ -19836,7 +20066,7 @@ const getTransitionName = () => getRandom();
|
|
|
19836
20066
|
},
|
|
19837
20067
|
update(element, xPosFn, yPosFn, fillStyleFn, withTransition, flow, selectedCircles) {
|
|
19838
20068
|
const $$ = this;
|
|
19839
|
-
const { width, height } = element.node()
|
|
20069
|
+
const { width, height } = getBBox(element.node());
|
|
19840
20070
|
const xPosFn2 = (d) => isValue(d.value) ? xPosFn(d) - width / 2 : 0;
|
|
19841
20071
|
const yPosFn2 = (d) => isValue(d.value) ? yPosFn(d) - height / 2 : 0;
|
|
19842
20072
|
let mainCircles = element;
|
|
@@ -20244,7 +20474,7 @@ const cacheKeyTextWidth = KEY.radarTextWidth;
|
|
|
20244
20474
|
});
|
|
20245
20475
|
}).datum((d, i) => ({ index: i })).attr("transform", function(d) {
|
|
20246
20476
|
if (isUndefined(this.width)) {
|
|
20247
|
-
this.width = this
|
|
20477
|
+
this.width = getBoundingRect(this, true).width / 2;
|
|
20248
20478
|
}
|
|
20249
20479
|
let posX = $$.getRadarPosition("x", d.index, void 0, 1);
|
|
20250
20480
|
let posY = Math.round($$.getRadarPosition("y", d.index, void 0, 1));
|
|
@@ -20311,7 +20541,7 @@ const cacheKeyTextWidth = KEY.radarTextWidth;
|
|
|
20311
20541
|
const $$ = this;
|
|
20312
20542
|
const targets = $$.data.targets.filter((d) => $$.isRadarType(d));
|
|
20313
20543
|
const points = $$.cache.get(cacheKeyPoints);
|
|
20314
|
-
const areas = $$.$el.radar.shapes.selectAll("polygon").data(targets);
|
|
20544
|
+
const areas = $$.$el.radar.shapes.selectAll("polygon").data($$.filterNullish(targets));
|
|
20315
20545
|
const areasEnter = areas.enter().append("g").attr("class", $$.getChartClass("Radar"));
|
|
20316
20546
|
$$.$T(areas.exit()).remove();
|
|
20317
20547
|
areasEnter.append("polygon").merge(areas).style("fill", $$.color).style("stroke", $$.color).attr("points", (d) => points[d.id].join(" "));
|
|
@@ -20475,7 +20705,7 @@ function getHierachyData(data) {
|
|
|
20475
20705
|
const $$ = this;
|
|
20476
20706
|
const { $el: { treemap } } = $$;
|
|
20477
20707
|
const treemapData = getHierachyData.call($$, $$.getTreemapData(targets != null ? targets : $$.data.targets));
|
|
20478
|
-
treemap.data(treemapData);
|
|
20708
|
+
treemap.data($$.filterNullish(treemapData));
|
|
20479
20709
|
},
|
|
20480
20710
|
/**
|
|
20481
20711
|
* Render treemap
|
|
@@ -20899,6 +21129,7 @@ ${percentValue}%`;
|
|
|
20899
21129
|
* zerobased: false
|
|
20900
21130
|
* }
|
|
20901
21131
|
*/
|
|
21132
|
+
bar_connectLine: false,
|
|
20902
21133
|
bar_front: false,
|
|
20903
21134
|
bar_indices_removeNull: false,
|
|
20904
21135
|
bar_label_threshold: 0,
|
|
@@ -21906,7 +22137,7 @@ const bb = {
|
|
|
21906
22137
|
* bb.version; // "1.0.0"
|
|
21907
22138
|
* @memberof bb
|
|
21908
22139
|
*/
|
|
21909
|
-
version: "3.
|
|
22140
|
+
version: "3.16.0-next.2",
|
|
21910
22141
|
/**
|
|
21911
22142
|
* Generate chart
|
|
21912
22143
|
* - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
|