You need to sign in or sign up before continuing.
Commit 5ade2230 authored by nikogu's avatar nikogu

1. fixed TagCloud unmount setState

2. fixed PageHeader key warning
3. fixed MiniArea key warning
parent cfced55c
......@@ -56,8 +56,24 @@ export default class MiniArea extends React.Component {
data={data}
padding={padding}
>
<Axis name="x" label={false} line={false} tickLine={false} grid={false} {...xAxis} />
<Axis name="y" label={false} line={false} tickLine={false} grid={false} {...yAxis} />
<Axis
key="axis-x"
name="x"
label={false}
line={false}
tickLine={false}
grid={false}
{...xAxis}
/>
<Axis
key="axis-y"
name="y"
label={false}
line={false}
tickLine={false}
grid={false}
{...yAxis}
/>
<Tooltip showTitle={false} crosshairs={false} />
<Geom
type="area"
......
......@@ -31,6 +31,7 @@ class TagCloud extends Component {
}
componentWillUnmount() {
this.isUnmount = true;
window.removeEventListener('resize', this.resize);
}
......@@ -87,18 +88,14 @@ class TagCloud extends Component {
const h = height * 4;
const w = this.root.offsetWidth * 4;
const imageMask = new Image();
imageMask.crossOrigin = '';
imageMask.src = imgUrl;
imageMask.onload = () => {
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() {
......
......@@ -6,7 +6,7 @@ import styles from './PageHeaderLayout.less';
export default ({ children, wrapperClassName, top, ...restProps }) => (
<div style={{ margin: '-24px -24px 0' }} className={wrapperClassName}>
{top}
<PageHeader {...restProps} linkElement={Link} />
<PageHeader key="pageheader" {...restProps} linkElement={Link} />
{children ? <div className={styles.content}>{children}</div> : null}
</div>
);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment