diff --git a/src/components/Charts/MiniArea/index.js b/src/components/Charts/MiniArea/index.js
index 2fc1fc82d6fb39e802187b53007e25ffc8c25120..a5526a958741b022ab708ad28f7258f057d38ecc 100644
--- a/src/components/Charts/MiniArea/index.js
+++ b/src/components/Charts/MiniArea/index.js
@@ -56,8 +56,24 @@ export default class MiniArea extends React.Component {
data={data}
padding={padding}
>
-
-
+
+
{
+ const onload = () => {
const dv = new DataSet.View().source(data);
const range = dv.range('value');
const [min, max] = range;
dv.transform({
type: 'tag-cloud',
fields: ['name', 'value'],
- imageMask,
+ imageMask: this.imageMask,
font: 'Verdana',
size: [w, h], // 宽高设置最好根据 imageMask 做调整
padding: 5,
@@ -112,12 +109,26 @@ class TagCloud extends Component {
},
});
+ if (this.isUnmount) {
+ return;
+ }
+
this.setState({
dv,
w,
h,
});
};
+
+ if (!this.imageMask) {
+ this.imageMask = new Image();
+ this.imageMask.crossOrigin = '';
+ this.imageMask.src = imgUrl;
+
+ this.imageMask.onload = onload;
+ } else {
+ onload();
+ }
};
render() {
diff --git a/src/layouts/PageHeaderLayout.js b/src/layouts/PageHeaderLayout.js
index 43ba3892dde0c71c16a3cbb5dfed2eecaf8c209a..2c615e897db6549d9af9f13a1a4ad0994a7ab70d 100644
--- a/src/layouts/PageHeaderLayout.js
+++ b/src/layouts/PageHeaderLayout.js
@@ -6,7 +6,7 @@ import styles from './PageHeaderLayout.less';
export default ({ children, wrapperClassName, top, ...restProps }) => (
{top}
-
+
{children ?
{children}
: null}
);