billboard.js 3.11.1 → 3.11.3
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/README.md +1 -1
- package/dist/billboard.css +1 -1
- package/dist/billboard.js +209 -124
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +209 -124
- package/dist/billboard.pkgd.min.js +2 -2
- 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 +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +2 -2
- package/dist/theme/dark.css +1 -1
- package/dist/theme/dark.min.css +1 -1
- package/dist/theme/datalab.css +1 -1
- package/dist/theme/datalab.min.css +1 -1
- package/dist/theme/graph.css +1 -1
- package/dist/theme/graph.min.css +1 -1
- package/dist/theme/insight.css +1 -1
- package/dist/theme/insight.min.css +1 -1
- package/dist/theme/modern.css +1 -1
- package/dist/theme/modern.min.css +1 -1
- package/dist-esm/billboard.js +182 -132
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/package.json +17 -17
- package/src/ChartInternal/ChartInternal.ts +2 -2
- package/src/ChartInternal/data/IData.ts +2 -2
- package/src/ChartInternal/data/data.ts +1 -1
- package/src/ChartInternal/data/load.ts +7 -1
- package/src/ChartInternal/internals/clip.ts +1 -6
- package/src/ChartInternal/internals/legend.ts +6 -5
- package/src/ChartInternal/internals/redraw.ts +2 -1
- package/src/ChartInternal/internals/tooltip.ts +10 -6
- package/src/ChartInternal/shape/point.common.ts +134 -0
- package/src/ChartInternal/shape/point.ts +3 -95
- package/src/ChartInternal/shape/shape.ts +1 -1
- package/src/config/Options/common/legend.ts +1 -1
- package/src/config/Store/State.ts +1 -1
- package/src/config/resolver/axis.ts +4 -4
- package/src/config/resolver/shape.ts +22 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "billboard.js",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.3",
|
|
4
4
|
"description": "Re-usable easy interface JavaScript chart library, based on D3 v4+",
|
|
5
5
|
"homepage": "https://naver.github.io/billboard.js/",
|
|
6
6
|
"main": "dist/billboard.js",
|
|
@@ -101,16 +101,16 @@
|
|
|
101
101
|
"d3-zoom": "^3.0.0"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
|
-
"@babel/core": "^7.
|
|
104
|
+
"@babel/core": "^7.24.0",
|
|
105
105
|
"@babel/eslint-parser": "^7.23.10",
|
|
106
106
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
107
107
|
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
108
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
109
|
-
"@babel/preset-env": "^7.
|
|
108
|
+
"@babel/plugin-transform-runtime": "^7.24.0",
|
|
109
|
+
"@babel/preset-env": "^7.24.0",
|
|
110
110
|
"@babel/preset-typescript": "^7.23.3",
|
|
111
|
-
"@babel/runtime": "^7.
|
|
112
|
-
"@commitlint/cli": "
|
|
113
|
-
"@commitlint/config-conventional": "^
|
|
111
|
+
"@babel/runtime": "^7.24.0",
|
|
112
|
+
"@commitlint/cli": "19.0.3",
|
|
113
|
+
"@commitlint/config-conventional": "^19.0.3",
|
|
114
114
|
"@rollup/plugin-babel": "^6.0.4",
|
|
115
115
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
116
116
|
"@rollup/plugin-replace": "^5.0.5",
|
|
@@ -119,14 +119,14 @@
|
|
|
119
119
|
"@semantic-release/commit-analyzer": "^11.1.0",
|
|
120
120
|
"@semantic-release/exec": "^6.0.3",
|
|
121
121
|
"@semantic-release/git": "^10.0.1",
|
|
122
|
-
"@semantic-release/npm": "^11.0.
|
|
122
|
+
"@semantic-release/npm": "^11.0.3",
|
|
123
123
|
"@semantic-release/release-notes-generator": "^12.1.0",
|
|
124
|
-
"@types/chai": "^4.3.
|
|
124
|
+
"@types/chai": "^4.3.12",
|
|
125
125
|
"@types/d3": "^7.4.3",
|
|
126
126
|
"@types/mocha": "^10.0.6",
|
|
127
127
|
"@types/sinon": "^17.0.3",
|
|
128
|
-
"@typescript-eslint/eslint-plugin": "^7.0
|
|
129
|
-
"@typescript-eslint/parser": "^7.0
|
|
128
|
+
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
|
129
|
+
"@typescript-eslint/parser": "^7.2.0",
|
|
130
130
|
"babel-helper-modules": "^6.0.0",
|
|
131
131
|
"babel-loader": "^9.1.3",
|
|
132
132
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
@@ -152,10 +152,10 @@
|
|
|
152
152
|
"d3-format": "^3.1.0",
|
|
153
153
|
"d3-polygon": "^3.0.1",
|
|
154
154
|
"docdash": "^2.0.2",
|
|
155
|
-
"eslint": "^8.
|
|
155
|
+
"eslint": "^8.57.0",
|
|
156
156
|
"eslint-config-naver": "^2.1.0",
|
|
157
157
|
"eslint-plugin-import": "^2.29.1",
|
|
158
|
-
"eslint-plugin-jsdoc": "^48.1
|
|
158
|
+
"eslint-plugin-jsdoc": "^48.2.1",
|
|
159
159
|
"eslint-webpack-plugin": "^4.0.1",
|
|
160
160
|
"exports-loader": "^5.0.0",
|
|
161
161
|
"hammer-simulator": "0.0.1",
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
"istanbul-instrumenter-loader": "^3.0.1",
|
|
164
164
|
"istanbul-lib-instrument": "^6.0.2",
|
|
165
165
|
"jsdoc": "^4.0.2",
|
|
166
|
-
"karma": "^6.4.
|
|
166
|
+
"karma": "^6.4.3",
|
|
167
167
|
"karma-chai": "^0.1.0",
|
|
168
168
|
"karma-chrome-launcher": "^3.2.0",
|
|
169
169
|
"karma-coverage-istanbul-reporter": "^3.0.3",
|
|
@@ -175,11 +175,11 @@
|
|
|
175
175
|
"karma-webpack": "^5.0.1",
|
|
176
176
|
"lint-staged": "^15.2.2",
|
|
177
177
|
"lite-fixture": "^1.0.2",
|
|
178
|
-
"mini-css-extract-plugin": "^2.8.
|
|
178
|
+
"mini-css-extract-plugin": "^2.8.1",
|
|
179
179
|
"mocha": "^10.3.0",
|
|
180
180
|
"node-sass": "^9.0.0",
|
|
181
181
|
"regenerator-runtime": "^0.14.1",
|
|
182
|
-
"rollup": "^4.12.
|
|
182
|
+
"rollup": "^4.12.1",
|
|
183
183
|
"rollup-plugin-delete": "^2.0.0",
|
|
184
184
|
"sass-loader": "^14.1.1",
|
|
185
185
|
"semantic-release": "^23.0.2",
|
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
"taffydb": "^2.7.3",
|
|
191
191
|
"terser-webpack-plugin": "^5.3.10",
|
|
192
192
|
"tslib": "^2.6.2",
|
|
193
|
-
"typescript": "5.
|
|
193
|
+
"typescript": "5.4.2",
|
|
194
194
|
"webpack": "^5.90.3",
|
|
195
195
|
"webpack-bundle-analyzer": "^4.10.1",
|
|
196
196
|
"webpack-clean": "^1.2.5",
|
|
@@ -281,7 +281,7 @@ export default class ChartInternal {
|
|
|
281
281
|
config.subchart_show = false;
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
if ($$.hasPointType()) {
|
|
284
|
+
if ($$.hasPointType() || $$.hasLegendDefsPoint?.()) {
|
|
285
285
|
$$.point = $$.generatePoint();
|
|
286
286
|
}
|
|
287
287
|
|
|
@@ -416,7 +416,7 @@ export default class ChartInternal {
|
|
|
416
416
|
const hasColorPatterns = (isFunction(config.color_tiles) && $$.patterns);
|
|
417
417
|
|
|
418
418
|
if (hasAxis || hasColorPatterns || hasPolar || hasTreemap ||
|
|
419
|
-
config.data_labels_backgroundColors) {
|
|
419
|
+
config.data_labels_backgroundColors || $$.hasLegendDefsPoint?.()) {
|
|
420
420
|
$el.defs = $el.svg.append("defs");
|
|
421
421
|
|
|
422
422
|
if (hasAxis) {
|
|
@@ -451,7 +451,7 @@ export default {
|
|
|
451
451
|
return this.state.hiddenLegendIds.indexOf(targetId) < 0;
|
|
452
452
|
},
|
|
453
453
|
|
|
454
|
-
filterTargetsToShow(targets) {
|
|
454
|
+
filterTargetsToShow(targets?) {
|
|
455
455
|
const $$ = this;
|
|
456
456
|
|
|
457
457
|
return (targets || $$.data.targets).filter(t => $$.isTargetToShow(t.id));
|
|
@@ -131,6 +131,7 @@ export default {
|
|
|
131
131
|
unload(rawTargetIds, customDoneCb): void {
|
|
132
132
|
const $$ = this;
|
|
133
133
|
const {state, $el, $T} = $$;
|
|
134
|
+
const hasLegendDefsPoint = !!$$.hasLegendDefsPoint?.();
|
|
134
135
|
let done = customDoneCb;
|
|
135
136
|
let targetIds = rawTargetIds;
|
|
136
137
|
|
|
@@ -158,16 +159,21 @@ export default {
|
|
|
158
159
|
.call(endall, done);
|
|
159
160
|
|
|
160
161
|
targetIds.forEach(id => {
|
|
162
|
+
const suffixId = $$.getTargetSelectorSuffix(id);
|
|
163
|
+
|
|
161
164
|
// Reset fadein for future load
|
|
162
165
|
state.withoutFadeIn[id] = false;
|
|
163
166
|
|
|
164
167
|
// Remove target's elements
|
|
165
168
|
if ($el.legend) {
|
|
166
|
-
$el.legend.selectAll(`.${$LEGEND.legendItem}${
|
|
169
|
+
$el.legend.selectAll(`.${$LEGEND.legendItem}${suffixId}`).remove();
|
|
167
170
|
}
|
|
168
171
|
|
|
169
172
|
// Remove target
|
|
170
173
|
$$.data.targets = $$.data.targets.filter(t => t.id !== id);
|
|
174
|
+
|
|
175
|
+
// Remove custom point def element
|
|
176
|
+
hasLegendDefsPoint && $el.defs?.select(`#${$$.getDefsPointId(suffixId)}`).remove();
|
|
171
177
|
});
|
|
172
178
|
|
|
173
179
|
// since treemap uses different data types, it needs to be transformed
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import {document, window} from "../../module/browser";
|
|
6
5
|
|
|
7
6
|
export default {
|
|
8
7
|
initClip(): void {
|
|
@@ -33,11 +32,7 @@ export default {
|
|
|
33
32
|
return null;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
window.navigator.appVersion
|
|
38
|
-
.toLowerCase().indexOf("msie 9.") >= 0 : false;
|
|
39
|
-
|
|
40
|
-
return `url(${(isIE9 ? "" : document.URL.split("#")[0])}#${id})`;
|
|
35
|
+
return `url(#${id})`;
|
|
41
36
|
},
|
|
42
37
|
|
|
43
38
|
appendClip(parent, id: string): void {
|
|
@@ -30,13 +30,14 @@ function getLegendColor(id: string): string {
|
|
|
30
30
|
/**
|
|
31
31
|
* Get formatted text value
|
|
32
32
|
* @param {string} id Legend text id
|
|
33
|
+
* @param {boolean} formatted Whether or not to format the text
|
|
33
34
|
* @returns {string} Formatted legend text
|
|
34
35
|
*/
|
|
35
|
-
function getFormattedText<T = string>(id: T): T {
|
|
36
|
+
function getFormattedText<T = string>(id: T, formatted = true): T {
|
|
36
37
|
const {config} = this;
|
|
37
38
|
let text = config.data_names[id] ?? id;
|
|
38
39
|
|
|
39
|
-
if (isFunction(config.legend_format)) {
|
|
40
|
+
if (formatted && isFunction(config.legend_format)) {
|
|
40
41
|
text = config.legend_format(text);
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -589,12 +590,12 @@ export default {
|
|
|
589
590
|
if (config.legend_tooltip) {
|
|
590
591
|
legend.selectAll("title")
|
|
591
592
|
.data(targetIdz)
|
|
592
|
-
.text(id => id);
|
|
593
|
+
.text(id => getFormattedText.bind($$)(id, false));
|
|
593
594
|
}
|
|
594
595
|
|
|
595
596
|
const texts = legend.selectAll("text")
|
|
596
597
|
.data(targetIdz)
|
|
597
|
-
.text(getFormattedText.bind($$)) // MEMO: needed for update
|
|
598
|
+
.text(id => getFormattedText.bind($$)(id)) // MEMO: needed for update
|
|
598
599
|
.each(function(id, i) {
|
|
599
600
|
updatePositions(this, id, i);
|
|
600
601
|
});
|
|
@@ -749,7 +750,7 @@ export default {
|
|
|
749
750
|
}
|
|
750
751
|
|
|
751
752
|
l.append("text")
|
|
752
|
-
.text(getFormattedText.bind($$))
|
|
753
|
+
.text(id => getFormattedText.bind($$)(id))
|
|
753
754
|
.each(function(id, i) {
|
|
754
755
|
updatePositions(this, id, i);
|
|
755
756
|
})
|
|
@@ -86,9 +86,10 @@ export default {
|
|
|
86
86
|
treemap && $$.updateTreemap(durationForExit);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
// @TODO: Axis & Radar type
|
|
90
89
|
if (!state.resizing && !treemap && ($$.hasPointType() || state.hasRadar)) {
|
|
91
90
|
$$.updateCircle();
|
|
91
|
+
} else if ($$.hasLegendDefsPoint?.()) {
|
|
92
|
+
$$.data.targets.forEach($$.point("create", this));
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
// text
|
|
@@ -326,10 +326,8 @@ export default {
|
|
|
326
326
|
{top: number, left: number} {
|
|
327
327
|
const $$ = this;
|
|
328
328
|
const {config, scale, state} = $$;
|
|
329
|
-
const {width, height, current, isLegendRight, inputType} = state;
|
|
329
|
+
const {width, height, current, hasRadar, hasTreemap, isLegendRight, inputType} = state;
|
|
330
330
|
const hasGauge = $$.hasType("gauge") && !config.gauge_fullCircle;
|
|
331
|
-
const hasTreemap = state.hasTreemap;
|
|
332
|
-
const hasRadar = state.hasRadar;
|
|
333
331
|
const isRotated = config.axis_rotated;
|
|
334
332
|
const hasArcType = $$.hasArcType();
|
|
335
333
|
const svgLeft = $$.getSvgLeft(true);
|
|
@@ -342,11 +340,17 @@ export default {
|
|
|
342
340
|
x += x >= (width / 2) ? 15 : -(tWidth + 15);
|
|
343
341
|
y += 15;
|
|
344
342
|
} else if (hasArcType) {
|
|
345
|
-
const
|
|
343
|
+
const notTouch = inputType !== "touch";
|
|
344
|
+
|
|
345
|
+
if (notTouch) {
|
|
346
|
+
let titlePadding = $$.getTitlePadding?.() ?? 0;
|
|
347
|
+
|
|
348
|
+
if (titlePadding && hasGauge && config.arc_rangeText_values?.length) {
|
|
349
|
+
titlePadding += 10;
|
|
350
|
+
}
|
|
346
351
|
|
|
347
|
-
if (!raw) {
|
|
348
352
|
x += (width - (isLegendRight ? $$.getLegendWidth() : 0)) / 2;
|
|
349
|
-
y += (hasGauge ? height : (height / 2) + tHeight) +
|
|
353
|
+
y += (hasGauge ? height : (height / 2) + tHeight) + titlePadding;
|
|
350
354
|
}
|
|
351
355
|
} else if (hasTreemap) {
|
|
352
356
|
y += tHeight;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
|
+
* billboard.js project is licensed under the MIT license
|
|
4
|
+
*/
|
|
5
|
+
import {
|
|
6
|
+
namespaces as d3Namespaces,
|
|
7
|
+
select as d3Select
|
|
8
|
+
} from "d3-selection";
|
|
9
|
+
import {document} from "../../module/browser";
|
|
10
|
+
import {isFunction, isObjectType, notEmpty, toArray} from "../../module/util";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Check if point draw methods are valid
|
|
14
|
+
* @param {string} point point type
|
|
15
|
+
* @returns {boolean}
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
function hasValidPointDrawMethods(point: string): boolean {
|
|
19
|
+
return isObjectType(point) &&
|
|
20
|
+
isFunction(point.create) && isFunction(point.update);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Insert point info defs element
|
|
25
|
+
* @param {string} point Point element
|
|
26
|
+
* @param {string} id Point id
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
function insertPointInfoDefs(point: string, id: string): void {
|
|
30
|
+
const $$ = this;
|
|
31
|
+
const copyAttr = (from, target) => {
|
|
32
|
+
const attribs = from.attributes;
|
|
33
|
+
|
|
34
|
+
for (let i = 0, name; (name = attribs[i]); i++) {
|
|
35
|
+
name = name.name;
|
|
36
|
+
target.setAttribute(name, from.getAttribute(name));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const doc = new DOMParser().parseFromString(point, "image/svg+xml");
|
|
41
|
+
const node = doc.documentElement;
|
|
42
|
+
const clone = document.createElementNS(d3Namespaces.svg, node.nodeName.toLowerCase());
|
|
43
|
+
|
|
44
|
+
clone.id = id;
|
|
45
|
+
clone.style.fill = "inherit";
|
|
46
|
+
clone.style.stroke = "inherit";
|
|
47
|
+
|
|
48
|
+
copyAttr(node, clone);
|
|
49
|
+
|
|
50
|
+
if (node.childNodes?.length) {
|
|
51
|
+
const parent = d3Select(clone);
|
|
52
|
+
|
|
53
|
+
if ("innerHTML" in clone) {
|
|
54
|
+
parent.html(node.innerHTML);
|
|
55
|
+
} else {
|
|
56
|
+
toArray(node.childNodes).forEach(v => {
|
|
57
|
+
copyAttr(v, parent.append(v.tagName).node());
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
$$.$el.defs.node().appendChild(clone);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default {
|
|
66
|
+
/**
|
|
67
|
+
* Check if point type option is valid
|
|
68
|
+
* @param {string} type point type
|
|
69
|
+
* @returns {boolean}
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
hasValidPointType(type?: string): boolean {
|
|
73
|
+
return /^(circle|rect(angle)?|polygon|ellipse|use)$/i.test(type || this.config.point_type);
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Check if pattern point is set to be used on legend
|
|
78
|
+
* @returns {boolean}
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
hasLegendDefsPoint(): boolean {
|
|
82
|
+
const {config} = this;
|
|
83
|
+
|
|
84
|
+
return config.legend_show && config.point_pattern?.length && config.legend_usePoint;
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
getDefsPointId(id: string): string {
|
|
88
|
+
const {state: {datetimeId}} = this;
|
|
89
|
+
|
|
90
|
+
return `${datetimeId}-point${id}`;
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Get generate point function
|
|
95
|
+
* @returns {Function}
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
generatePoint(): Function {
|
|
99
|
+
const $$ = this;
|
|
100
|
+
const {$el, config} = $$;
|
|
101
|
+
const ids: string[] = [];
|
|
102
|
+
const pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
|
|
103
|
+
|
|
104
|
+
return function(method, context, ...args) {
|
|
105
|
+
return function(d) {
|
|
106
|
+
const id: string = $$.getTargetSelectorSuffix(d.id || d.data?.id || d);
|
|
107
|
+
const element = d3Select(this);
|
|
108
|
+
|
|
109
|
+
ids.indexOf(id) < 0 && ids.push(id);
|
|
110
|
+
|
|
111
|
+
let point = pattern[ids.indexOf(id) % pattern.length];
|
|
112
|
+
|
|
113
|
+
if ($$.hasValidPointType(point)) {
|
|
114
|
+
point = $$[point];
|
|
115
|
+
} else if (!hasValidPointDrawMethods(point || config.point_type)) {
|
|
116
|
+
const pointId = $$.getDefsPointId(id);
|
|
117
|
+
const defsPoint = $el.defs.select(`#${pointId}`);
|
|
118
|
+
|
|
119
|
+
if (defsPoint.size() < 1) {
|
|
120
|
+
insertPointInfoDefs.bind($$)(point, pointId);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (method === "create") {
|
|
124
|
+
return $$.custom?.create.bind(context)(element, pointId, ...args);
|
|
125
|
+
} else if (method === "update") {
|
|
126
|
+
return $$.custom?.update.bind(context)(element, ...args);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return point[method]?.bind(context)(element, ...args);
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
};
|
|
@@ -2,30 +2,15 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
namespaces as d3Namespaces,
|
|
7
|
-
select as d3Select
|
|
8
|
-
} from "d3-selection";
|
|
9
|
-
import type {d3Selection} from "../../../types/types";
|
|
5
|
+
import {select as d3Select} from "d3-selection";
|
|
10
6
|
import {$CIRCLE, $COMMON, $SELECT} from "../../config/classes";
|
|
11
|
-
import {
|
|
7
|
+
import {getBoundingRect, getPointer, getRandom, isFunction, isObject, isUndefined, isValue} from "../../module/util";
|
|
8
|
+
import type {d3Selection} from "../../../types/types";
|
|
12
9
|
import type {IDataPoint, IDataRow} from "../data/IData";
|
|
13
|
-
import {getBoundingRect, getPointer, getRandom, isFunction, isObject, isObjectType, isUndefined, isValue, toArray, notEmpty} from "../../module/util";
|
|
14
10
|
|
|
15
11
|
const getTransitionName = () => getRandom();
|
|
16
12
|
|
|
17
13
|
export default {
|
|
18
|
-
hasValidPointType(type?: string): boolean {
|
|
19
|
-
return /^(circle|rect(angle)?|polygon|ellipse|use)$/i.test(type || this.config.point_type);
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
hasValidPointDrawMethods(type?: string): boolean {
|
|
23
|
-
const pointType = type || this.config.point_type;
|
|
24
|
-
|
|
25
|
-
return isObjectType(pointType) &&
|
|
26
|
-
isFunction(pointType.create) && isFunction(pointType.update);
|
|
27
|
-
},
|
|
28
|
-
|
|
29
14
|
initialOpacityForCircle(d): string | number | null {
|
|
30
15
|
const {config, state: {withoutFadeIn}} = this;
|
|
31
16
|
let opacity = config.point_opacity;
|
|
@@ -410,46 +395,6 @@ export default {
|
|
|
410
395
|
return sensitivity;
|
|
411
396
|
},
|
|
412
397
|
|
|
413
|
-
insertPointInfoDefs(point, id: string): void {
|
|
414
|
-
const $$ = this;
|
|
415
|
-
const copyAttr = (from, target) => {
|
|
416
|
-
const attribs = from.attributes;
|
|
417
|
-
|
|
418
|
-
for (let i = 0, name; (name = attribs[i]); i++) {
|
|
419
|
-
name = name.name;
|
|
420
|
-
target.setAttribute(name, from.getAttribute(name));
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
|
|
424
|
-
const doc = new DOMParser().parseFromString(point, "image/svg+xml");
|
|
425
|
-
const node = doc.documentElement;
|
|
426
|
-
const clone = document.createElementNS(d3Namespaces.svg, node.nodeName.toLowerCase());
|
|
427
|
-
|
|
428
|
-
clone.id = id;
|
|
429
|
-
clone.style.fill = "inherit";
|
|
430
|
-
clone.style.stroke = "inherit";
|
|
431
|
-
|
|
432
|
-
copyAttr(node, clone);
|
|
433
|
-
|
|
434
|
-
if (node.childNodes?.length) {
|
|
435
|
-
const parent = d3Select(clone);
|
|
436
|
-
|
|
437
|
-
if ("innerHTML" in clone) {
|
|
438
|
-
parent.html(node.innerHTML);
|
|
439
|
-
} else {
|
|
440
|
-
toArray(node.childNodes).forEach(v => {
|
|
441
|
-
copyAttr(v, parent.append(v.tagName).node());
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
$$.$el.defs.node().appendChild(clone);
|
|
447
|
-
},
|
|
448
|
-
|
|
449
|
-
pointFromDefs(id: string) {
|
|
450
|
-
return this.$el.defs.select(`#${id}`);
|
|
451
|
-
},
|
|
452
|
-
|
|
453
398
|
updatePointClass(d) {
|
|
454
399
|
const $$ = this;
|
|
455
400
|
const {circle} = $$.$el;
|
|
@@ -504,43 +449,6 @@ export default {
|
|
|
504
449
|
};
|
|
505
450
|
},
|
|
506
451
|
|
|
507
|
-
generatePoint(): Function {
|
|
508
|
-
const $$ = this;
|
|
509
|
-
const {config, state: {datetimeId}} = $$;
|
|
510
|
-
const ids: string[] = [];
|
|
511
|
-
const pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
|
|
512
|
-
|
|
513
|
-
return function(method, context, ...args) {
|
|
514
|
-
return function(d) {
|
|
515
|
-
const id: string = $$.getTargetSelectorSuffix(d.id || d.data?.id || d);
|
|
516
|
-
const element = d3Select(this);
|
|
517
|
-
|
|
518
|
-
ids.indexOf(id) < 0 && ids.push(id);
|
|
519
|
-
|
|
520
|
-
let point = pattern[ids.indexOf(id) % pattern.length];
|
|
521
|
-
|
|
522
|
-
if ($$.hasValidPointType(point)) {
|
|
523
|
-
point = $$[point];
|
|
524
|
-
} else if (!$$.hasValidPointDrawMethods(point)) {
|
|
525
|
-
const pointId = `${datetimeId}-point${id}`;
|
|
526
|
-
const pointFromDefs = $$.pointFromDefs(pointId);
|
|
527
|
-
|
|
528
|
-
if (pointFromDefs.size() < 1) {
|
|
529
|
-
$$.insertPointInfoDefs(point, pointId);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
if (method === "create") {
|
|
533
|
-
return $$.custom.create.bind(context)(element, pointId, ...args);
|
|
534
|
-
} else if (method === "update") {
|
|
535
|
-
return $$.custom.update.bind(context)(element, ...args);
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
return point[method].bind(context)(element, ...args);
|
|
540
|
-
};
|
|
541
|
-
};
|
|
542
|
-
},
|
|
543
|
-
|
|
544
452
|
custom: {
|
|
545
453
|
create(element, id, fillStyleFn) {
|
|
546
454
|
return element.append("use")
|
|
@@ -425,7 +425,7 @@ export default {
|
|
|
425
425
|
const maxDataCount = $$.getMaxDataCount();
|
|
426
426
|
const isGrouped = type === "bar" && config.data_groups?.length;
|
|
427
427
|
const configName = `${type}_width`;
|
|
428
|
-
const {k} = $$.getZoomTransform();
|
|
428
|
+
const {k} = $$.getZoomTransform?.() ?? {k: 1};
|
|
429
429
|
const xMinMax = <[number, number]>[
|
|
430
430
|
config.axis_x_min ?? org.xDomain[0],
|
|
431
431
|
config.axis_x_max ?? org.xDomain[1]
|
|
@@ -68,7 +68,7 @@ export default {
|
|
|
68
68
|
* - rectangle
|
|
69
69
|
* @property {boolean} [legend.format] Set formatter function for legend text.
|
|
70
70
|
* The argument:<br>
|
|
71
|
-
* - `id`: legend text
|
|
71
|
+
* - `id`: legend text value. When `data.names` is specified, will pass from it, otherwise will pass data id.
|
|
72
72
|
* @property {boolean} [legend.tooltip=false] Show full legend text value using system tooltip(via `<title>` element).
|
|
73
73
|
* @property {boolean} [legend.usePoint=false] Whether to use custom points in legend.
|
|
74
74
|
* @see [Demo: format](https://naver.github.io/billboard.js/demo/#Legend.LegendFormat)
|
|
@@ -55,7 +55,7 @@ export default class State {
|
|
|
55
55
|
dataMax: 0,
|
|
56
56
|
|
|
57
57
|
maxTickSize: {
|
|
58
|
-
x: {width: 0, height: 0, ticks: <number[]> [], clipPath: 0, domain: ""},
|
|
58
|
+
x: {width: 0, height: 0, ticks: <(number|string)[]> [], clipPath: 0, domain: ""},
|
|
59
59
|
y: {width: 0, height: 0, domain: ""},
|
|
60
60
|
y2: {width: 0, height: 0, domain: ""}
|
|
61
61
|
},
|
|
@@ -39,7 +39,7 @@ export const api = [
|
|
|
39
39
|
apiX
|
|
40
40
|
];
|
|
41
41
|
|
|
42
|
-
export const internal =
|
|
42
|
+
export const internal = {
|
|
43
43
|
axis,
|
|
44
44
|
clip,
|
|
45
45
|
eventrect,
|
|
@@ -47,10 +47,10 @@ export const internal = [
|
|
|
47
47
|
grid,
|
|
48
48
|
region,
|
|
49
49
|
sizeAxis,
|
|
50
|
-
|
|
50
|
+
};
|
|
51
51
|
|
|
52
|
-
export const options =
|
|
52
|
+
export const options = {
|
|
53
53
|
optDataAxis,
|
|
54
54
|
optAxis,
|
|
55
55
|
optGrid,
|
|
56
|
-
|
|
56
|
+
};
|
|
@@ -23,6 +23,7 @@ import shapeCandlestick from "../../ChartInternal/shape/candlestick";
|
|
|
23
23
|
import shapeGauge from "../../ChartInternal/shape/gauge";
|
|
24
24
|
import shapeBubble from "../../ChartInternal/shape/bubble";
|
|
25
25
|
import shapeLine from "../../ChartInternal/shape/line";
|
|
26
|
+
import shapePointCommon from "../../ChartInternal/shape/point.common";
|
|
26
27
|
import shapePoint from "../../ChartInternal/shape/point";
|
|
27
28
|
import shapePolar from "../../ChartInternal/shape/polar";
|
|
28
29
|
import shapeRadar from "../../ChartInternal/shape/radar";
|
|
@@ -75,9 +76,9 @@ export {
|
|
|
75
76
|
* @private
|
|
76
77
|
*/
|
|
77
78
|
function extendAxis(module, option?): void {
|
|
78
|
-
extend(ChartInternal.prototype, axisInternal.concat(module));
|
|
79
|
+
extend(ChartInternal.prototype, Object.values(axisInternal).concat(module));
|
|
79
80
|
extend(Chart.prototype, axisAPI);
|
|
80
|
-
Options.setOptions(axisOptions.concat(option || []));
|
|
81
|
+
Options.setOptions(Object.values(axisOptions).concat(option || []));
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
/**
|
|
@@ -87,7 +88,7 @@ function extendAxis(module, option?): void {
|
|
|
87
88
|
* @private
|
|
88
89
|
*/
|
|
89
90
|
function extendLine(module?, option?): void {
|
|
90
|
-
extendAxis([shapePoint, shapeLine].concat(module || []));
|
|
91
|
+
extendAxis([shapePointCommon, shapePoint, shapeLine].concat(module || []));
|
|
91
92
|
Options.setOptions([optPoint, optLine].concat(option || []));
|
|
92
93
|
}
|
|
93
94
|
|
|
@@ -98,8 +99,8 @@ function extendLine(module?, option?): void {
|
|
|
98
99
|
* @private
|
|
99
100
|
*/
|
|
100
101
|
function extendArc(module?, option?): void {
|
|
101
|
-
extend(ChartInternal.prototype, [shapeArc].concat(module || []));
|
|
102
|
-
Options.setOptions(option);
|
|
102
|
+
extend(ChartInternal.prototype, [shapeArc, shapePointCommon].concat(module || []));
|
|
103
|
+
Options.setOptions([optPoint].concat(option || []));
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
// Area types
|
|
@@ -138,19 +139,30 @@ let polar = (): string => (
|
|
|
138
139
|
extendArc([shapePolar], [optArc, optPolar]), (polar = () => TYPE.POLAR)()
|
|
139
140
|
);
|
|
140
141
|
let radar = (): string => (
|
|
141
|
-
extendArc(
|
|
142
|
+
extendArc(
|
|
143
|
+
[axisInternal.eventrect, shapePoint, shapeRadar],
|
|
144
|
+
[optPoint, optRadar, {axis_x_categories: axisOptions.optAxis.axis_x_categories}]
|
|
145
|
+
), (radar = () => TYPE.RADAR)()
|
|
142
146
|
);
|
|
143
147
|
|
|
144
148
|
// Axis based types
|
|
145
|
-
let bar = (): string => (
|
|
149
|
+
let bar = (): string => (
|
|
150
|
+
extendAxis([shapeBar, shapePointCommon], [optBar, optPoint]), (bar = () => TYPE.BAR)()
|
|
151
|
+
);
|
|
146
152
|
let bubble = (): string => (
|
|
147
|
-
extendAxis(
|
|
153
|
+
extendAxis(
|
|
154
|
+
[shapePointCommon, shapePoint, shapeBubble], [optBubble, optPoint]
|
|
155
|
+
), (bubble = () => TYPE.BUBBLE)()
|
|
148
156
|
);
|
|
149
157
|
let candlestick = (): string => (
|
|
150
|
-
extendAxis(
|
|
158
|
+
extendAxis(
|
|
159
|
+
[shapeCandlestick, shapePointCommon], [optCandlestick, optPoint]
|
|
160
|
+
), (candlestick = () => TYPE.CANDLESTICK)()
|
|
151
161
|
);
|
|
152
162
|
let scatter = (): string => (
|
|
153
|
-
extendAxis(
|
|
163
|
+
extendAxis(
|
|
164
|
+
[shapePointCommon, shapePoint], [optPoint, optScatter]
|
|
165
|
+
), (scatter = () => TYPE.SCATTER)()
|
|
154
166
|
);
|
|
155
167
|
|
|
156
168
|
// Non Axis based types
|