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 { ...@@ -56,8 +56,24 @@ export default class MiniArea extends React.Component {
data={data} data={data}
padding={padding} padding={padding}
> >
<Axis name="x" label={false} line={false} tickLine={false} grid={false} {...xAxis} /> <Axis
<Axis name="y" label={false} line={false} tickLine={false} grid={false} {...yAxis} /> 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} /> <Tooltip showTitle={false} crosshairs={false} />
<Geom <Geom
type="area" type="area"
......
...@@ -31,6 +31,7 @@ class TagCloud extends Component { ...@@ -31,6 +31,7 @@ class TagCloud extends Component {
} }
componentWillUnmount() { componentWillUnmount() {
this.isUnmount = true;
window.removeEventListener('resize', this.resize); window.removeEventListener('resize', this.resize);
} }
...@@ -87,18 +88,14 @@ class TagCloud extends Component { ...@@ -87,18 +88,14 @@ class TagCloud extends Component {
const h = height * 4; const h = height * 4;
const w = this.root.offsetWidth * 4; const w = this.root.offsetWidth * 4;
const imageMask = new Image(); const onload = () => {
imageMask.crossOrigin = '';
imageMask.src = imgUrl;
imageMask.onload = () => {
const dv = new DataSet.View().source(data); const dv = new DataSet.View().source(data);
const range = dv.range('value'); const range = dv.range('value');
const [min, max] = range; const [min, max] = range;
dv.transform({ dv.transform({
type: 'tag-cloud', type: 'tag-cloud',
fields: ['name', 'value'], fields: ['name', 'value'],
imageMask, imageMask: this.imageMask,
font: 'Verdana', font: 'Verdana',
size: [w, h], // 宽高设置最好根据 imageMask 做调整 size: [w, h], // 宽高设置最好根据 imageMask 做调整
padding: 5, padding: 5,
...@@ -112,12 +109,26 @@ class TagCloud extends Component { ...@@ -112,12 +109,26 @@ class TagCloud extends Component {
}, },
}); });
if (this.isUnmount) {
return;
}
this.setState({ this.setState({
dv, dv,
w, w,
h, h,
}); });
}; };
if (!this.imageMask) {
this.imageMask = new Image();
this.imageMask.crossOrigin = '';
this.imageMask.src = imgUrl;
this.imageMask.onload = onload;
} else {
onload();
}
}; };
render() { render() {
......
...@@ -6,7 +6,7 @@ import styles from './PageHeaderLayout.less'; ...@@ -6,7 +6,7 @@ import styles from './PageHeaderLayout.less';
export default ({ children, wrapperClassName, top, ...restProps }) => ( export default ({ children, wrapperClassName, top, ...restProps }) => (
<div style={{ margin: '-24px -24px 0' }} className={wrapperClassName}> <div style={{ margin: '-24px -24px 0' }} className={wrapperClassName}>
{top} {top}
<PageHeader {...restProps} linkElement={Link} /> <PageHeader key="pageheader" {...restProps} linkElement={Link} />
{children ? <div className={styles.content}>{children}</div> : null} {children ? <div className={styles.content}>{children}</div> : null}
</div> </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