Commit a2cca354 authored by ι™ˆεΈ…'s avatar ι™ˆεΈ…

feat: remove auto width

parent 29c23b1f
...@@ -7,7 +7,6 @@ import styles from '../index.less'; ...@@ -7,7 +7,6 @@ import styles from '../index.less';
class Bar extends Component { class Bar extends Component {
state = { state = {
width: 0,
height: 0, height: 0,
autoHideXLabels: false, autoHideXLabels: false,
}; };
...@@ -31,10 +30,9 @@ class Bar extends Component { ...@@ -31,10 +30,9 @@ class Bar extends Component {
resizeObserver() { resizeObserver() {
const ro = new ResizeObserver(entries => { const ro = new ResizeObserver(entries => {
const { width, height } = entries[0].contentRect; const { width, height } = entries[0].contentRect;
this.setState((preState, { hasLegend }) => { this.setState(preState => {
if (preState.width !== width || preState.height !== height) { if (preState.width !== width || preState.height !== height) {
return { return {
width: width - (hasLegend ? 240 : 0),
height, height,
}; };
} }
...@@ -101,7 +99,7 @@ class Bar extends Component { ...@@ -101,7 +99,7 @@ class Bar extends Component {
value: y, value: y,
}), }),
]; ];
const { height: stateHeight, width } = this.state; const { height: stateHeight } = this.state;
const height = propsHeight || stateHeight; const height = propsHeight || stateHeight;
return ( return (
<div className={styles.chart} style={{ height }} ref={this.handleRoot}> <div className={styles.chart} style={{ height }} ref={this.handleRoot}>
...@@ -109,7 +107,6 @@ class Bar extends Component { ...@@ -109,7 +107,6 @@ class Bar extends Component {
{title && <h4 style={{ marginBottom: 20 }}>{title}</h4>} {title && <h4 style={{ marginBottom: 20 }}>{title}</h4>}
<Chart <Chart
scale={scale} scale={scale}
width={width}
height={title ? height - 41 : height} height={title ? height - 41 : height}
forceFit={forceFit} forceFit={forceFit}
data={data} data={data}
......
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