Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

改变图表类型,会出现两个图表. #9

Closed
owenvip opened this issue Jul 26, 2019 · 0 comments
Closed

改变图表类型,会出现两个图表. #9

owenvip opened this issue Jul 26, 2019 · 0 comments

Comments

@owenvip
Copy link

owenvip commented Jul 26, 2019

文档示例地址
修改如下:

class Demo extends React.Component {
  state = {
    type: 'interval',
  };
  onClick = () => {
    let { type } = this.state;
    type === 'interval' ? type = 'line' : type = 'interval';
    this.setState({ type });
  };
  render() {
    return (
      <div>
        <Chart height={300} width="100%" data={data} defs={defs} animate={{ type: 'scaley' }} pixelRatio={pixelRatio}>
          <Axis dataKey="year" label={{ fontSize: 8 }}/>
          <Axis dataKey="sales"/>
          <Tooltip showItemMarker={false} onShow={onShowTooltip}/>
          <Geom geom={this.state.type} position="year*sales"/>
          <Legend/>
        </Chart>
        <button onClick={this.onClick}>改变</button>
      </div>
    );
  }
}
@owenvip owenvip closed this as completed Jul 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant