Browse Source

条形图高度设置

zhouy 3 years ago
parent
commit
175d426194

+ 7 - 1
uas-office-web/uas-mobile/src/components/common/bizgoblin/BarChart.jsx

@@ -35,7 +35,12 @@ export default class ColumnChart extends Component {
     if (!isObjEmpty(detailData)) {
       data = this.formatData(JSON.parse(detailData))
     }
-
+    let height = ''
+    if (isObjEmpty(detailData) || detailData.length == 0) {
+      height = '300'
+    } else {
+      height = detailData.length * 30
+    }
     return (
       <div className='bar-graph'
            style={{ width: '100%', backgroundColor: '#fff' }}>
@@ -49,6 +54,7 @@ export default class ColumnChart extends Component {
           padding={[25, 15, 40, 50]}
           autoFit
           forceFit
+          height={height}
           data={data}
         >
           <Axis name='xField'