瀏覽代碼

条形图高度设置

zhouy 4 年之前
父節點
當前提交
175d426194
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      uas-office-web/uas-mobile/src/components/common/bizgoblin/BarChart.jsx

+ 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'