Commit a2a6456b authored by Jenny's avatar Jenny

feat: 横向柱状图根据数据动态 resize

parent 9dc543b0
......@@ -6,7 +6,7 @@
<script>
import uniEcCanvas from '@/uni-ec-canvas/uni-ec-canvas'
import echartElementData from '@/mixins/echartElementData.js'
import { DATAZOOM_DEFAULT } from '@/mixins/zoomConfig.js'
import { DATAZOOM_DEFAULT } from '@/mixins/zoomConfig.js'
let chart = null
let lastCount = 0 // 记录datazoom最后一次滑动的数值数量
......@@ -115,6 +115,11 @@
option.series = dealSeries
// 重新setOption,使得设置的formatter生效
chart.setOption(option)
if(Number(dealSeries[0].barWidth)) {
const height = categories.length * (Number(dealSeries[0].barWidth) + 5) + 25
uni.$emit('handleUpdateHeight', height)
chart.resize({ width: chart.getWidth(), height })
}
}
if(preview) {
this.cacheImages(images)
......
......@@ -12,7 +12,7 @@
]"
:style="{
width: `${parseInt(element.width * scale)}px`,
height: `${parseInt(element.height * scale)}px`,
height: `${element.type == 'HorizontalBar' && horizontalBarHeight ? horizontalBarHeight : parseInt(element.height * scale)}px`,
left: `${parseInt(element.left * scale)}px`,
top: `${parseInt(element.top * scale)}px`,
zIndex: `${element.type == 'NormalTabs' || element.type == 'DateTimePicker' ? 999999 : index + 1}`
......@@ -69,7 +69,8 @@
reportInfo: {},
timename: null,
pageScrollTop: 0,
stickyTables: [] // 设置了吸顶的table
stickyTables: [], // 设置了吸顶的table
horizontalBarHeight: 0
}
},
computed: {
......@@ -138,12 +139,16 @@
})
}
})
uni.$on('handleUpdateHeight', (height) => {
that.horizontalBarHeight = height
})
},
onHide() {
// 移除监听事件
uni.$off('handleLinkParams')
uni.$off('handleLinkComp')
uni.$off('handleDataZoomParams')
uni.$off('handleUpdateHeight')
clearInterval(this.timename)
},
methods: {
......
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