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

remove auto width

parent a2cca354
......@@ -12,7 +12,6 @@ import styles from './index.less';
/* eslint react/no-danger:0 */
class Pie extends Component {
state = {
width: 0,
height: 0,
legendData: [],
legendBlock: false,
......@@ -96,19 +95,18 @@ class Pie extends Component {
resizeObserver() {
const ro = new ResizeObserver(entries => {
const { width, height } = entries[0].contentRect;
this.setState((preState, { hasLegend }) => {
if (preState.width !== width || preState.height !== height) {
const { height } = entries[0].contentRect;
this.setState(preState => {
if (preState.height !== height) {
return {
width: width - (hasLegend ? 240 : 0),
height,
};
}
return null;
});
});
if (this.root) {
ro.observe(this.root);
if (this.chartDom) {
ro.observe(this.chartDom);
}
}
......@@ -152,7 +150,7 @@ class Pie extends Component {
lineWidth = 1,
} = this.props;
const { legendData, height: StateHeight, width, legendBlock } = this.state;
const { legendData, height: stateHeight, legendBlock } = this.state;
const pieClassName = classNames(styles.pie, className, {
[styles.hasLegend]: !!hasLegend,
[styles.legendBlock]: legendBlock,
......@@ -225,13 +223,17 @@ class Pie extends Component {
return (
<div ref={this.handleRoot} className={pieClassName} style={style}>
<div
ref={ref => {
this.chartDom = ref;
}}
>
<ReactFitText maxFontSize={25}>
<div className={styles.chart}>
<Chart
scale={scale}
height={height || StateHeight}
height={height || stateHeight}
data={dv}
width={width}
padding={padding}
animate={animate}
onGetG2Instance={this.getG2Instance}
......@@ -259,6 +261,7 @@ class Pie extends Component {
)}
</div>
</ReactFitText>
</div>
{hasLegend && (
<ul className={styles.legend}>
{legendData.map((item, i) => (
......
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