1 | import { MIN_CHART_HEIGHT, MIN_CHART_WIDTH } from '../constant';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | function getElementSize(ele) {
|
8 | var style = getComputedStyle(ele);
|
9 | return {
|
10 | width: (ele.clientWidth || parseInt(style.width, 10)) -
|
11 | parseInt(style.paddingLeft, 10) -
|
12 | parseInt(style.paddingRight, 10),
|
13 | height: (ele.clientHeight || parseInt(style.height, 10)) -
|
14 | parseInt(style.paddingTop, 10) -
|
15 | parseInt(style.paddingBottom, 10),
|
16 | };
|
17 | }
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | function isNumber(v) {
|
24 | return typeof v === 'number' && !isNaN(v);
|
25 | }
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | export function getChartSize(ele, autoFit, width, height) {
|
36 | var w = width;
|
37 | var h = height;
|
38 | if (autoFit) {
|
39 | var size = getElementSize(ele);
|
40 | w = size.width ? size.width : w;
|
41 | h = size.height ? size.height : h;
|
42 | }
|
43 | return {
|
44 | width: Math.max(isNumber(w) ? w : MIN_CHART_WIDTH, MIN_CHART_WIDTH),
|
45 | height: Math.max(isNumber(h) ? h : MIN_CHART_HEIGHT, MIN_CHART_HEIGHT),
|
46 | };
|
47 | }
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 | export function removeDom(dom) {
|
54 | var parent = dom.parentNode;
|
55 | if (parent) {
|
56 | parent.removeChild(dom);
|
57 | }
|
58 | }
|
59 |
|
60 | export { createDom, modifyCSS } from '@antv/dom-util';
|
61 |
|
\ | No newline at end of file |