billboard.js 3.6.2 → 3.7.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/billboard.css +1 -1
- package/dist/billboard.js +529 -167
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +1723 -1277
- package/dist/billboard.pkgd.min.js +4 -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 +35 -3
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.js +35 -3
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +35 -3
- package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.js +35 -3
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +933 -923
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +966 -924
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +966 -924
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +966 -924
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +966 -924
- 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-esm/billboard.js +375 -108
- 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 +40 -35
- package/src/Chart/api/chart.ts +13 -4
- package/src/Chart/api/export.ts +159 -14
- package/src/ChartInternal/Axis/Axis.ts +1 -1
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +4 -2
- package/src/ChartInternal/data/IData.ts +1 -0
- package/src/ChartInternal/data/data.ts +21 -2
- package/src/ChartInternal/interactions/interaction.ts +6 -7
- 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/shape/arc.ts +145 -68
- package/src/ChartInternal/shape/area.ts +3 -0
- package/src/ChartInternal/shape/bar.ts +3 -0
- package/src/ChartInternal/shape/line.ts +12 -15
- package/src/config/Options/common/tooltip.ts +11 -8
- package/src/config/Options/shape/arc.ts +47 -0
- package/src/config/Options/shape/gauge.ts +2 -2
- package/src/config/resolver/shape.ts +13 -4
- package/src/module/util.ts +1 -1
- package/types/chart.d.ts +7 -0
- package/types/options.d.ts +39 -624
- package/types/options.shape.d.ts +633 -0
- package/types/types.d.ts +2 -2
|
@@ -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.7.0-next.1
|
|
9
9
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
@@ -106,7 +106,7 @@ var Plugin = /** @class */ (function () {
|
|
|
106
106
|
delete _this[key];
|
|
107
107
|
});
|
|
108
108
|
};
|
|
109
|
-
Plugin.version = "3.
|
|
109
|
+
Plugin.version = "3.7.0-next.1";
|
|
110
110
|
return Plugin;
|
|
111
111
|
}());
|
|
112
112
|
var Plugin$1 = Plugin;
|
|
@@ -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.7.0-next.1
|
|
9
9
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
@@ -277,7 +277,7 @@ var Plugin = /** @class */ (function () {
|
|
|
277
277
|
delete _this[key];
|
|
278
278
|
});
|
|
279
279
|
};
|
|
280
|
-
Plugin.version = "3.
|
|
280
|
+
Plugin.version = "3.7.0-next.1";
|
|
281
281
|
return Plugin;
|
|
282
282
|
}());
|
|
283
283
|
var Plugin$1 = Plugin;
|
|
@@ -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.7.0-next.1
|
|
9
9
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
@@ -485,7 +485,7 @@ var Plugin = /** @class */ (function () {
|
|
|
485
485
|
delete _this[key];
|
|
486
486
|
});
|
|
487
487
|
};
|
|
488
|
-
Plugin.version = "3.
|
|
488
|
+
Plugin.version = "3.7.0-next.1";
|
|
489
489
|
return Plugin;
|
|
490
490
|
}());
|
|
491
491
|
var Plugin$1 = Plugin;
|
|
@@ -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.7.0-next.1
|
|
9
9
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
@@ -125,7 +125,7 @@ var Plugin = /** @class */ (function () {
|
|
|
125
125
|
delete _this[key];
|
|
126
126
|
});
|
|
127
127
|
};
|
|
128
|
-
Plugin.version = "3.
|
|
128
|
+
Plugin.version = "3.7.0-next.1";
|
|
129
129
|
return Plugin;
|
|
130
130
|
}());
|
|
131
131
|
var Plugin$1 = Plugin;
|
|
@@ -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.7.0-next.1
|
|
9
9
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
@@ -265,7 +265,7 @@ var Plugin = /** @class */ (function () {
|
|
|
265
265
|
delete _this[key];
|
|
266
266
|
});
|
|
267
267
|
};
|
|
268
|
-
Plugin.version = "3.
|
|
268
|
+
Plugin.version = "3.7.0-next.1";
|
|
269
269
|
return Plugin;
|
|
270
270
|
}());
|
|
271
271
|
var Plugin$1 = Plugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "billboard.js",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0-next.1",
|
|
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",
|
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
+
"types": "./types/index.d.ts",
|
|
12
13
|
"import": "./dist-esm/billboard.js",
|
|
13
14
|
"require": "./dist/billboard.pkgd.js"
|
|
14
15
|
},
|
|
15
16
|
"./dist/plugin/*": {
|
|
17
|
+
"types": "./types/plugin/*.d.ts",
|
|
16
18
|
"import": "./dist-esm/plugin/*.js",
|
|
17
19
|
"require": "./dist/plugin/pkgd/*.js"
|
|
18
20
|
},
|
|
@@ -82,6 +84,8 @@
|
|
|
82
84
|
"license": "MIT",
|
|
83
85
|
"readmeFilename": "README.md",
|
|
84
86
|
"dependencies": {
|
|
87
|
+
"@types/d3-selection": "^3.0.3",
|
|
88
|
+
"@types/d3-transition": "^3.0.2",
|
|
85
89
|
"d3-axis": "^3.0.0",
|
|
86
90
|
"d3-brush": "^3.0.0",
|
|
87
91
|
"d3-drag": "^3.0.0",
|
|
@@ -96,34 +100,34 @@
|
|
|
96
100
|
"d3-zoom": "^3.0.0"
|
|
97
101
|
},
|
|
98
102
|
"devDependencies": {
|
|
99
|
-
"@babel/core": "^7.
|
|
103
|
+
"@babel/core": "^7.20.5",
|
|
100
104
|
"@babel/eslint-parser": "^7.19.1",
|
|
101
105
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
102
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
|
106
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.20.2",
|
|
103
107
|
"@babel/plugin-transform-runtime": "^7.19.1",
|
|
104
|
-
"@babel/preset-env": "^7.
|
|
108
|
+
"@babel/preset-env": "^7.20.2",
|
|
105
109
|
"@babel/preset-typescript": "^7.18.6",
|
|
106
|
-
"@babel/runtime": "^7.
|
|
107
|
-
"@commitlint/cli": "17.
|
|
108
|
-
"@commitlint/config-conventional": "^17.
|
|
109
|
-
"@rollup/plugin-babel": "^6.0.
|
|
110
|
+
"@babel/runtime": "^7.20.6",
|
|
111
|
+
"@commitlint/cli": "17.3.0",
|
|
112
|
+
"@commitlint/config-conventional": "^17.3.0",
|
|
113
|
+
"@rollup/plugin-babel": "^6.0.3",
|
|
110
114
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
111
115
|
"@rollup/plugin-replace": "^5.0.0",
|
|
112
|
-
"@rollup/plugin-typescript": "^
|
|
113
|
-
"@semantic-release/changelog": "^6.0.
|
|
116
|
+
"@rollup/plugin-typescript": "^10.0.1",
|
|
117
|
+
"@semantic-release/changelog": "^6.0.2",
|
|
114
118
|
"@semantic-release/commit-analyzer": "^9.0.2",
|
|
115
119
|
"@semantic-release/exec": "^6.0.3",
|
|
116
120
|
"@semantic-release/git": "^10.0.1",
|
|
117
121
|
"@semantic-release/npm": "^9.0.1",
|
|
118
122
|
"@semantic-release/release-notes-generator": "^10.0.3",
|
|
119
|
-
"@types/chai": "^4.3.
|
|
123
|
+
"@types/chai": "^4.3.4",
|
|
120
124
|
"@types/d3": "^7.4.0",
|
|
121
|
-
"@types/mocha": "^10.0.
|
|
125
|
+
"@types/mocha": "^10.0.1",
|
|
122
126
|
"@types/sinon": "^10.0.13",
|
|
123
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
124
|
-
"@typescript-eslint/parser": "^5.
|
|
127
|
+
"@typescript-eslint/eslint-plugin": "^5.45.1",
|
|
128
|
+
"@typescript-eslint/parser": "^5.45.1",
|
|
125
129
|
"babel-helper-modules": "^6.0.0",
|
|
126
|
-
"babel-loader": "^
|
|
130
|
+
"babel-loader": "^9.1.0",
|
|
127
131
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
128
132
|
"babel-plugin-minify-constant-folding": "^0.5.0",
|
|
129
133
|
"babel-plugin-minify-dead-code-elimination": "^0.5.2",
|
|
@@ -134,31 +138,31 @@
|
|
|
134
138
|
"babel-plugin-transform-merge-sibling-variables": "^6.9.5",
|
|
135
139
|
"babel-plugin-transform-minify-booleans": "^6.9.4",
|
|
136
140
|
"better-docs": "^2.7.2",
|
|
137
|
-
"chai": "^4.3.
|
|
141
|
+
"chai": "^4.3.7",
|
|
138
142
|
"clean-webpack-plugin": "^4.0.0",
|
|
139
143
|
"cloc": "^2.10.0",
|
|
140
|
-
"core-js": "^3.
|
|
144
|
+
"core-js": "^3.26.1",
|
|
141
145
|
"coveralls": "^3.1.1",
|
|
142
146
|
"cross-env": "^7.0.3",
|
|
143
|
-
"css-loader": "^6.7.
|
|
147
|
+
"css-loader": "^6.7.2",
|
|
144
148
|
"css-minimizer-webpack-plugin": "^4.2.2",
|
|
145
149
|
"d3-color": "^3.1.0",
|
|
146
150
|
"d3-delaunay": "^6.0.2",
|
|
147
151
|
"d3-format": "^3.1.0",
|
|
148
152
|
"d3-polygon": "^3.0.1",
|
|
149
|
-
"docdash": "^
|
|
153
|
+
"docdash": "^2.0.0",
|
|
150
154
|
"dtslint": "^4.2.1",
|
|
151
|
-
"eslint": "^8.
|
|
155
|
+
"eslint": "^8.29.0",
|
|
152
156
|
"eslint-config-naver": "^2.1.0",
|
|
153
157
|
"eslint-plugin-import": "^2.26.0",
|
|
154
|
-
"eslint-plugin-jsdoc": "^39.
|
|
158
|
+
"eslint-plugin-jsdoc": "^39.6.4",
|
|
155
159
|
"eslint-webpack-plugin": "^3.2.0",
|
|
156
160
|
"exports-loader": "^4.0.0",
|
|
157
161
|
"hammer-simulator": "0.0.1",
|
|
158
|
-
"husky": "^8.0.
|
|
162
|
+
"husky": "^8.0.2",
|
|
159
163
|
"istanbul-instrumenter-loader": "^3.0.1",
|
|
160
164
|
"istanbul-lib-instrument": "^5.2.1",
|
|
161
|
-
"jsdoc": "^
|
|
165
|
+
"jsdoc": "^4.0.0",
|
|
162
166
|
"karma": "^6.4.1",
|
|
163
167
|
"karma-chai": "^0.1.0",
|
|
164
168
|
"karma-chrome-launcher": "^3.1.1",
|
|
@@ -169,27 +173,28 @@
|
|
|
169
173
|
"karma-sinon": "^1.0.5",
|
|
170
174
|
"karma-sourcemap-loader": "^0.3.8",
|
|
171
175
|
"karma-webpack": "^5.0.0",
|
|
172
|
-
"lint-staged": "^13.0
|
|
176
|
+
"lint-staged": "^13.1.0",
|
|
173
177
|
"lite-fixture": "^1.0.2",
|
|
174
|
-
"mini-css-extract-plugin": "^2.
|
|
178
|
+
"mini-css-extract-plugin": "^2.7.1",
|
|
175
179
|
"mocha": "^10.1.0",
|
|
176
|
-
"node-sass": "^
|
|
177
|
-
"regenerator-runtime": "^0.13.
|
|
178
|
-
"rollup": "^3.
|
|
180
|
+
"node-sass": "^8.0.0",
|
|
181
|
+
"regenerator-runtime": "^0.13.11",
|
|
182
|
+
"rollup": "^3.6.0",
|
|
179
183
|
"rollup-plugin-delete": "^2.0.0",
|
|
180
|
-
"sass-loader": "^13.
|
|
184
|
+
"sass-loader": "^13.2.0",
|
|
181
185
|
"semantic-release": "^19.0.5",
|
|
182
186
|
"simulant": "^0.2.2",
|
|
183
|
-
"sinon": "^
|
|
187
|
+
"sinon": "^15.0.0",
|
|
184
188
|
"string-replace-loader": "^3.1.0",
|
|
185
189
|
"style-loader": "^3.3.1",
|
|
190
|
+
"taffydb": "^2.7.3",
|
|
186
191
|
"terser-webpack-plugin": "^5.3.6",
|
|
187
|
-
"tslib": "^2.4.
|
|
188
|
-
"typescript": "4.
|
|
189
|
-
"webpack": "^5.
|
|
190
|
-
"webpack-bundle-analyzer": "^4.
|
|
192
|
+
"tslib": "^2.4.1",
|
|
193
|
+
"typescript": "4.9.3",
|
|
194
|
+
"webpack": "^5.75.0",
|
|
195
|
+
"webpack-bundle-analyzer": "^4.7.0",
|
|
191
196
|
"webpack-clean": "^1.2.5",
|
|
192
|
-
"webpack-cli": "^
|
|
197
|
+
"webpack-cli": "^5.0.1",
|
|
193
198
|
"webpack-common-shake": "^2.1.0",
|
|
194
199
|
"webpack-dev-server": "^4.11.1",
|
|
195
200
|
"webpack-merge": "^5.8.0",
|
package/src/Chart/api/chart.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import {window} from "../../module/browser";
|
|
6
|
-
import {
|
|
6
|
+
import {isDefined, isEmpty, notEmpty} from "../../module/util";
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
9
|
/**
|
|
@@ -143,8 +143,9 @@ export default {
|
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
145
|
* Get or set config option value.
|
|
146
|
-
* - **NOTE
|
|
147
|
-
*
|
|
146
|
+
* - **NOTE**
|
|
147
|
+
* - The option key name must be specified as the last level.
|
|
148
|
+
* - when no argument is given, will return all specified generation options object only. (will exclude any other options not specified at the initialization)
|
|
148
149
|
* @function config
|
|
149
150
|
* @instance
|
|
150
151
|
* @memberof Chart
|
|
@@ -158,12 +159,20 @@ export default {
|
|
|
158
159
|
* // Getter
|
|
159
160
|
* chart.config("gauge.max");
|
|
160
161
|
*
|
|
162
|
+
* // Getter specified with top level key name will not work.
|
|
163
|
+
* // The option key name must be specified as the last level.
|
|
164
|
+
* // chart.config("gauge"); // will not work
|
|
165
|
+
*
|
|
161
166
|
* // without any arguments, it returns generation config object
|
|
162
167
|
* chart.config(); // {data: { ... }, axis: { ... }, ...}
|
|
163
168
|
*
|
|
164
169
|
* // Setter
|
|
165
170
|
* chart.config("gauge.max", 100);
|
|
166
171
|
*
|
|
172
|
+
* // Setter specified with top level key name will not work.
|
|
173
|
+
* // The option key name must be specified as the last level.
|
|
174
|
+
* // chart.config("gauge", {min: 10, max: 20}); // will not work
|
|
175
|
+
*
|
|
167
176
|
* // Setter & redraw with the new option
|
|
168
177
|
* chart.config("gauge.max", 100, true);
|
|
169
178
|
*/
|
|
@@ -182,7 +191,7 @@ export default {
|
|
|
182
191
|
} else {
|
|
183
192
|
res = config[key];
|
|
184
193
|
}
|
|
185
|
-
} else {
|
|
194
|
+
} else if (arguments.length === 0 || isEmpty(name)) {
|
|
186
195
|
res = state.orgConfig;
|
|
187
196
|
}
|
|
188
197
|
|
package/src/Chart/api/export.ts
CHANGED
|
@@ -3,18 +3,31 @@
|
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import {namespaces as d3Namespaces} from "d3-selection";
|
|
6
|
-
import {document} from "../../module/browser";
|
|
6
|
+
import {document, window} from "../../module/browser";
|
|
7
7
|
import {isFunction, toArray, getCssRules, mergeObj} from "../../module/util";
|
|
8
8
|
|
|
9
|
-
type
|
|
9
|
+
type TExportOption = TSize & {
|
|
10
|
+
preserveAspectRatio: boolean;
|
|
11
|
+
preserveFontStyle: boolean;
|
|
12
|
+
mimeType: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type TSize = {
|
|
16
|
+
x?: number;
|
|
17
|
+
y?: number;
|
|
10
18
|
width: number;
|
|
11
19
|
height: number;
|
|
12
20
|
};
|
|
13
21
|
|
|
14
|
-
type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
22
|
+
type TTextGlyph = {
|
|
23
|
+
[key: string]: TSize & {
|
|
24
|
+
fill: string;
|
|
25
|
+
fontFamily: string;
|
|
26
|
+
fontSize: string;
|
|
27
|
+
textAnchor: string;
|
|
28
|
+
transform: string;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
18
31
|
|
|
19
32
|
/**
|
|
20
33
|
* Encode to base64
|
|
@@ -23,7 +36,7 @@ type ExportOption = Size & {
|
|
|
23
36
|
* @private
|
|
24
37
|
* @see https://developer.mozilla.org/ko/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
|
|
25
38
|
*/
|
|
26
|
-
const b64EncodeUnicode = (str: string): string => btoa(
|
|
39
|
+
const b64EncodeUnicode = (str: string): string => window.btoa?.(
|
|
27
40
|
encodeURIComponent(str)
|
|
28
41
|
.replace(/%([0-9A-F]{2})/g, (match, p: number | string): string => String.fromCharCode(Number(`0x${p}`)))
|
|
29
42
|
);
|
|
@@ -36,16 +49,27 @@ const b64EncodeUnicode = (str: string): string => btoa(
|
|
|
36
49
|
* @returns {string}
|
|
37
50
|
* @private
|
|
38
51
|
*/
|
|
39
|
-
function nodeToSvgDataUrl(node, option:
|
|
52
|
+
function nodeToSvgDataUrl(node, option: TExportOption, orgSize: TSize) {
|
|
40
53
|
const {width, height} = option || orgSize;
|
|
41
54
|
const serializer = new XMLSerializer();
|
|
42
55
|
const clone = node.cloneNode(true);
|
|
43
56
|
const cssText = getCssRules(toArray(document.styleSheets))
|
|
44
|
-
.filter((r:
|
|
45
|
-
.map((r:
|
|
57
|
+
.filter((r: CSSStyleRule) => r.cssText)
|
|
58
|
+
.map((r: CSSStyleRule) => r.cssText);
|
|
46
59
|
|
|
47
60
|
clone.setAttribute("xmlns", d3Namespaces.xhtml);
|
|
48
61
|
|
|
62
|
+
// remove padding & margin
|
|
63
|
+
clone.style.margin = "0";
|
|
64
|
+
clone.style.padding = "0";
|
|
65
|
+
|
|
66
|
+
// remove text nodes
|
|
67
|
+
if (option.preserveFontStyle) {
|
|
68
|
+
clone.querySelectorAll("text").forEach(t => {
|
|
69
|
+
t.innerHTML = "";
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
49
73
|
const nodeXml = serializer.serializeToString(clone);
|
|
50
74
|
|
|
51
75
|
// escape css for XML
|
|
@@ -69,12 +93,117 @@ function nodeToSvgDataUrl(node, option: ExportOption, orgSize: Size) {
|
|
|
69
93
|
return `data:image/svg+xml;base64,${b64EncodeUnicode(dataStr)}`;
|
|
70
94
|
}
|
|
71
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Get coordinate of the element
|
|
98
|
+
* @param {SVGElement} elem Target element
|
|
99
|
+
* @param {object} svgOffset SVG offset
|
|
100
|
+
* @returns {object}
|
|
101
|
+
* @private
|
|
102
|
+
*/
|
|
103
|
+
function getCoords(elem, svgOffset): TSize {
|
|
104
|
+
const {top, left} = svgOffset;
|
|
105
|
+
const {x, y} = elem.getBBox();
|
|
106
|
+
const {a, b, c, d, e, f} = elem.getScreenCTM();
|
|
107
|
+
const {width, height} = elem.getBoundingClientRect();
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
x: (a * x) + (c * y) + e - left,
|
|
111
|
+
y: (b * x) + (d * y) + f - top + (height - Math.round(height / 4)),
|
|
112
|
+
width,
|
|
113
|
+
height
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Get text glyph
|
|
119
|
+
* @param {SVGTextElement} svg Target svg node
|
|
120
|
+
* @returns {Array}
|
|
121
|
+
* @private
|
|
122
|
+
*/
|
|
123
|
+
function getGlyph(svg: SVGElement): TTextGlyph[] {
|
|
124
|
+
const {left, top} = svg.getBoundingClientRect();
|
|
125
|
+
const filterFn = t => t.textContent || t.childElementCount;
|
|
126
|
+
const glyph: TTextGlyph[] = [];
|
|
127
|
+
|
|
128
|
+
toArray(svg.querySelectorAll("text"))
|
|
129
|
+
.filter(filterFn)
|
|
130
|
+
.forEach((t: SVGTextElement) => { // eslint-disable-line
|
|
131
|
+
const getStyleFn = (ts: SVGTextElement): TTextGlyph => {
|
|
132
|
+
const {fill, fontFamily, fontSize, textAnchor, transform} = window.getComputedStyle(ts);
|
|
133
|
+
const {x, y, width, height} = getCoords(ts, {left, top});
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
[ts.textContent as string]: {
|
|
137
|
+
x, y, width, height, fill, fontFamily, fontSize, textAnchor, transform
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
if (t.childElementCount > 1) {
|
|
143
|
+
const text: TTextGlyph[] = [];
|
|
144
|
+
|
|
145
|
+
toArray(t.querySelectorAll("tspan"))
|
|
146
|
+
.filter(filterFn)
|
|
147
|
+
.forEach((ts: SVGTSpanElement) => {
|
|
148
|
+
glyph.push(getStyleFn(ts));
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
return text;
|
|
152
|
+
} else {
|
|
153
|
+
glyph.push(getStyleFn(t));
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
return glyph;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Render text glyph
|
|
162
|
+
* - NOTE: Called when the 'preserveFontStyle' option is true
|
|
163
|
+
* @param {CanvasRenderingContext2D} ctx Canvas context
|
|
164
|
+
* @param {Array} glyph Text glyph array
|
|
165
|
+
* @private
|
|
166
|
+
*/
|
|
167
|
+
function renderText(ctx, glyph): void {
|
|
168
|
+
glyph.forEach(g => {
|
|
169
|
+
Object.keys(g).forEach(key => {
|
|
170
|
+
const {x, y, width, height, fill, fontFamily, fontSize, transform} = g[key];
|
|
171
|
+
|
|
172
|
+
ctx.save();
|
|
173
|
+
|
|
174
|
+
ctx.font = `${fontSize} ${fontFamily}`;
|
|
175
|
+
ctx.fillStyle = fill;
|
|
176
|
+
|
|
177
|
+
if (transform === "none") {
|
|
178
|
+
ctx.fillText(key, x, y);
|
|
179
|
+
} else {
|
|
180
|
+
const args = transform
|
|
181
|
+
.replace(/(matrix|\(|\))/g, "")
|
|
182
|
+
.split(",");
|
|
183
|
+
|
|
184
|
+
if (args.splice(4).every(v => +v === 0)) {
|
|
185
|
+
args.push(x + width - (width / 4));
|
|
186
|
+
args.push(y - height + (height / 3));
|
|
187
|
+
} else {
|
|
188
|
+
args.push(x);
|
|
189
|
+
args.push(y);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
ctx.transform(...args);
|
|
193
|
+
ctx.fillText(key, 0, 0);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
ctx.restore();
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
72
201
|
export default {
|
|
73
202
|
/**
|
|
74
203
|
* Export chart as an image.
|
|
75
204
|
* - **NOTE:**
|
|
76
205
|
* - IE11 and below not work properly due to the lack of the feature(<a href="https://msdn.microsoft.com/en-us/library/hh834675(v=vs.85).aspx">foreignObject</a>) support
|
|
77
|
-
* -
|
|
206
|
+
* - Every style applied to the chart & the basic CSS file(ex. billboard.css) should be at same domain as API call context to get correct styled export image.
|
|
78
207
|
* @function export
|
|
79
208
|
* @instance
|
|
80
209
|
* @memberof Chart
|
|
@@ -83,6 +212,12 @@ export default {
|
|
|
83
212
|
* @param {number} [option.width={currentWidth}] width
|
|
84
213
|
* @param {number} [option.height={currentHeigth}] height
|
|
85
214
|
* @param {boolean} [option.preserveAspectRatio=true] Preserve aspect ratio on given size
|
|
215
|
+
* @param {boolean} [option.preserveFontStyle=false] Preserve font style(font-family).<br>
|
|
216
|
+
* **NOTE:**
|
|
217
|
+
* - This option is useful when outlink web font style's `font-family` are applied to chart's text element.
|
|
218
|
+
* - Text element's position(especially "transformed") can't be preserved correctly according the page's layout condition.
|
|
219
|
+
* - If need to preserve accurate text position, embed the web font data within to the page and set `preserveFontStyle=false`.
|
|
220
|
+
* - Checkout the embed example: <a href="https://stackblitz.com/edit/zfbya9-8nf9nn?file=index.html">https://stackblitz.com/edit/zfbya9-8nf9nn?file=index.html</a>
|
|
86
221
|
* @param {Function} [callback] The callback to be invoked when export is ready.
|
|
87
222
|
* @returns {string} dataURI
|
|
88
223
|
* @example
|
|
@@ -106,23 +241,26 @@ export default {
|
|
|
106
241
|
* width: 800,
|
|
107
242
|
* height: 600,
|
|
108
243
|
* preserveAspectRatio: false,
|
|
244
|
+
* preserveFontStyle: false,
|
|
109
245
|
* mimeType: "image/png"
|
|
110
246
|
* },
|
|
111
247
|
* dataUrl => { ... }
|
|
112
248
|
* );
|
|
113
249
|
*/
|
|
114
|
-
export(option?:
|
|
250
|
+
export(option?: TExportOption, callback?: (dataUrl: string) => void): string {
|
|
115
251
|
const $$ = this.internal;
|
|
116
|
-
const {state, $el: {chart}} = $$;
|
|
252
|
+
const {state, $el: {chart, svg}} = $$;
|
|
117
253
|
const {width, height} = state.current;
|
|
118
254
|
const opt = mergeObj({
|
|
119
255
|
width,
|
|
120
256
|
height,
|
|
121
257
|
preserveAspectRatio: true,
|
|
258
|
+
preserveFontStyle: false,
|
|
122
259
|
mimeType: "image/png"
|
|
123
|
-
}, option) as
|
|
260
|
+
}, option) as TExportOption;
|
|
124
261
|
|
|
125
262
|
const svgDataUrl = nodeToSvgDataUrl(chart.node(), opt, {width, height});
|
|
263
|
+
const glyph = opt.preserveFontStyle ? getGlyph(svg.node()) : [];
|
|
126
264
|
|
|
127
265
|
if (callback && isFunction(callback)) {
|
|
128
266
|
const img = new Image();
|
|
@@ -136,6 +274,13 @@ export default {
|
|
|
136
274
|
canvas.height = opt.height || height;
|
|
137
275
|
ctx.drawImage(img, 0, 0);
|
|
138
276
|
|
|
277
|
+
if (glyph.length) {
|
|
278
|
+
renderText(ctx, glyph);
|
|
279
|
+
|
|
280
|
+
// release glyph array
|
|
281
|
+
glyph.length = 0;
|
|
282
|
+
}
|
|
283
|
+
|
|
139
284
|
callback.bind(this)(canvas.toDataURL(opt.mimeType));
|
|
140
285
|
};
|
|
141
286
|
|
|
@@ -580,7 +580,7 @@ class Axis {
|
|
|
580
580
|
const currentTickMax = current.maxTickWidths[id];
|
|
581
581
|
let maxWidth = 0;
|
|
582
582
|
|
|
583
|
-
if (withoutRecompute || !config[`axis_${id}_show`] || $$.filterTargetsToShow().length === 0) {
|
|
583
|
+
if (withoutRecompute || !config[`axis_${id}_show`] || (currentTickMax.size > 0 && $$.filterTargetsToShow().length === 0)) {
|
|
584
584
|
return currentTickMax.size;
|
|
585
585
|
}
|
|
586
586
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @ignore
|
|
5
5
|
*/
|
|
6
6
|
import {getScale} from "../internals/scale";
|
|
7
|
-
import {isDefined, isNumber, isString} from "../../module/util";
|
|
7
|
+
import {isDefined, isNumber, isString, isValue} from "../../module/util";
|
|
8
8
|
import type {d3Selection} from "../../../types/types";
|
|
9
9
|
|
|
10
10
|
export default class AxisRendererHelper {
|
|
@@ -75,7 +75,9 @@ export default class AxisRendererHelper {
|
|
|
75
75
|
value => `translate(0,${value})`;
|
|
76
76
|
|
|
77
77
|
return (selection, scale) => {
|
|
78
|
-
selection.attr("transform", d =>
|
|
78
|
+
selection.attr("transform", d => (
|
|
79
|
+
isValue(d) ? fn(Math.ceil(scale(d))) : null
|
|
80
|
+
));
|
|
79
81
|
};
|
|
80
82
|
}
|
|
81
83
|
|
|
@@ -313,7 +313,7 @@ export default {
|
|
|
313
313
|
const cacheKey = KEY.dataTotalPerIndex;
|
|
314
314
|
let sum = $$.cache.get(cacheKey);
|
|
315
315
|
|
|
316
|
-
if ($$.isStackNormalized() && !sum) {
|
|
316
|
+
if (($$.config.data_groups.length || $$.isStackNormalized()) && !sum) {
|
|
317
317
|
sum = [];
|
|
318
318
|
|
|
319
319
|
$$.data.targets.forEach(row => {
|
|
@@ -883,6 +883,25 @@ export default {
|
|
|
883
883
|
return value;
|
|
884
884
|
},
|
|
885
885
|
|
|
886
|
+
/**
|
|
887
|
+
* Set ratio for grouped data
|
|
888
|
+
* @param {Array} data Data array
|
|
889
|
+
* @private
|
|
890
|
+
*/
|
|
891
|
+
setRatioForGroupedData(data: (IDataRow | IData)[]): void {
|
|
892
|
+
const $$ = this;
|
|
893
|
+
const {config} = $$;
|
|
894
|
+
|
|
895
|
+
// calculate ratio if grouped data exists
|
|
896
|
+
if (config.data_groups.length && data.some(d => $$.isGrouped(d.id))) {
|
|
897
|
+
const setter = (d: IDataRow) => $$.getRatio("index", d, true);
|
|
898
|
+
|
|
899
|
+
data.forEach(v => {
|
|
900
|
+
"values" in v ? v.values.forEach(setter) : setter(v);
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
},
|
|
904
|
+
|
|
886
905
|
/**
|
|
887
906
|
* Get ratio value
|
|
888
907
|
* @param {string} type Ratio for given type
|
|
@@ -927,7 +946,7 @@ export default {
|
|
|
927
946
|
}
|
|
928
947
|
}
|
|
929
948
|
|
|
930
|
-
d.ratio = isNumber(d.value) && total
|
|
949
|
+
d.ratio = isNumber(d.value) && total ?
|
|
931
950
|
d.value / total[d.index] : 0;
|
|
932
951
|
|
|
933
952
|
ratio = d.ratio;
|
|
@@ -28,14 +28,13 @@ export default {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
// remove possible previous focused state
|
|
32
|
+
main.selectAll(`.${$COMMON.EXPANDED}:not(.${$SHAPE.shape}-${index})`)
|
|
33
|
+
.classed($COMMON.EXPANDED, false);
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
})
|
|
35
|
+
const shapeAtIndex = main.selectAll(`.${$SHAPE.shape}-${index}`)
|
|
36
|
+
.classed($COMMON.EXPANDED, true)
|
|
37
|
+
.style("cursor", isSelectable ? "pointer" : null)
|
|
39
38
|
.filter(function(d) {
|
|
40
39
|
return $$.isWithinShape(this, d);
|
|
41
40
|
});
|