Commit 3641660f authored by leon's avatar leon

feat: fix datazoom default bug

parent 832d71d0
...@@ -128,10 +128,6 @@ export default { ...@@ -128,10 +128,6 @@ export default {
this.$nextTick().then(() => { this.$nextTick().then(() => {
const { categories, series, preview, images } = this.elementData.dataList const { categories, series, preview, images } = this.elementData.dataList
var count = categories.length var count = categories.length
if(count < this.elementInfo.dataZoom.count) {
this.elementInfo.dataZoom.start = 0
this.elementInfo.dataZoom.end = 100
}
if (this.labelShow) { if (this.labelShow) {
// 处理初始状态时,数值显示的数量是否超过了配置的最大值 // 处理初始状态时,数值显示的数量是否超过了配置的最大值
if (this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) { if (this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) {
...@@ -165,6 +161,15 @@ export default { ...@@ -165,6 +161,15 @@ export default {
} }
] ]
) )
if(categories.length < this.elementInfo.dataZoom.count) {
this.$set(this.ec.option, 'dataZoom.start', 0)
this.$set(this.ec.option, 'dataZoom.end', 100)
} else {
this.$set(this.ec.option, 'dataZoom.start', this.elementInfo.dataZoom.start)
this.$set(this.ec.option, 'dataZoom.end', this.elementInfo.dataZoom.end)
}
if (chart && chart.getOption()) { if (chart && chart.getOption()) {
const option = chart.getOption() const option = chart.getOption()
option.series = dealSeries option.series = dealSeries
......
...@@ -106,10 +106,6 @@ ...@@ -106,10 +106,6 @@
this.$nextTick().then(() => { this.$nextTick().then(() => {
const { categories, series } = this.elementData.dataList const { categories, series } = this.elementData.dataList
var count = categories.length var count = categories.length
if(count < this.elementInfo.dataZoom.count) {
this.elementInfo.dataZoom.start = 0
this.elementInfo.dataZoom.end = 100
}
if(this.labelShow) { if(this.labelShow) {
// 处理初始状态时,数值显示的数量是否超过了配置的最大值 // 处理初始状态时,数值显示的数量是否超过了配置的最大值
if(this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) { if(this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) {
...@@ -124,6 +120,14 @@ ...@@ -124,6 +120,14 @@
this.$set(this.ec.option, 'xAxis.data', categories) this.$set(this.ec.option, 'xAxis.data', categories)
this.$set(this.ec.option, 'series', dealSeries) this.$set(this.ec.option, 'series', dealSeries)
this.$set(this.ec.option, 'dataZoom', this.elementInfo.dataZoom && this.elementInfo.dataZoom.show ? [{...this.elementInfo.dataZoom,...DATAZOOM_DEFAULT}] : [{show: false}]) this.$set(this.ec.option, 'dataZoom', this.elementInfo.dataZoom && this.elementInfo.dataZoom.show ? [{...this.elementInfo.dataZoom,...DATAZOOM_DEFAULT}] : [{show: false}])
if(categories.length < this.elementInfo.dataZoom.count) {
this.$set(this.ec.option, 'dataZoom.start', 0)
this.$set(this.ec.option, 'dataZoom.end', 100)
} else {
this.$set(this.ec.option, 'dataZoom.start', this.elementInfo.dataZoom.start)
this.$set(this.ec.option, 'dataZoom.end', this.elementInfo.dataZoom.end)
}
if(chart) { if(chart) {
const option = chart.getOption() const option = chart.getOption()
option.series = dealSeries option.series = dealSeries
......
...@@ -98,10 +98,6 @@ ...@@ -98,10 +98,6 @@
this.$nextTick().then(() => { this.$nextTick().then(() => {
const { categories, series } = this.elementData.dataList const { categories, series } = this.elementData.dataList
var count = categories.length var count = categories.length
if(count < this.elementInfo.dataZoom.count) {
this.elementInfo.dataZoom.start = 0
this.elementInfo.dataZoom.end = 100
}
if(this.labelShow) { if(this.labelShow) {
// 处理初始状态时,数值显示的数量是否超过了配置的最大值 // 处理初始状态时,数值显示的数量是否超过了配置的最大值
if(this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) { if(this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) {
...@@ -116,6 +112,14 @@ ...@@ -116,6 +112,14 @@
this.$set(this.ec.option, 'xAxis.data', categories) this.$set(this.ec.option, 'xAxis.data', categories)
this.$set(this.ec.option, 'series', dealSeries) this.$set(this.ec.option, 'series', dealSeries)
this.$set(this.ec.option, 'dataZoom', this.elementInfo.dataZoom && this.elementInfo.dataZoom.show ? [{...this.elementInfo.dataZoom,...DATAZOOM_DEFAULT}] : [{show: false}]) this.$set(this.ec.option, 'dataZoom', this.elementInfo.dataZoom && this.elementInfo.dataZoom.show ? [{...this.elementInfo.dataZoom,...DATAZOOM_DEFAULT}] : [{show: false}])
if(categories.length < this.elementInfo.dataZoom.count) {
this.$set(this.ec.option, 'dataZoom.start', 0)
this.$set(this.ec.option, 'dataZoom.end', 100)
} else {
this.$set(this.ec.option, 'dataZoom.start', this.elementInfo.dataZoom.start)
this.$set(this.ec.option, 'dataZoom.end', this.elementInfo.dataZoom.end)
}
if(chart) { if(chart) {
const option = chart.getOption() const option = chart.getOption()
option.series = dealSeries option.series = dealSeries
......
...@@ -97,10 +97,6 @@ ...@@ -97,10 +97,6 @@
this.$nextTick().then(() => { this.$nextTick().then(() => {
const { categories, series } = this.elementData.dataList const { categories, series } = this.elementData.dataList
var count = categories.length var count = categories.length
if(count < this.elementInfo.dataZoom.count) {
this.elementInfo.dataZoom.start = 0
this.elementInfo.dataZoom.end = 100
}
if(this.labelShow) { if(this.labelShow) {
// 处理初始状态时,数值显示的数量是否超过了配置的最大值 // 处理初始状态时,数值显示的数量是否超过了配置的最大值
if(this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) { if(this.elementInfo.dataZoom && this.elementInfo.dataZoom.show) {
...@@ -115,6 +111,14 @@ ...@@ -115,6 +111,14 @@
this.$set(this.ec.option, 'xAxis.data', categories) this.$set(this.ec.option, 'xAxis.data', categories)
this.$set(this.ec.option, 'series', dealSeries) this.$set(this.ec.option, 'series', dealSeries)
this.$set(this.ec.option, 'dataZoom', this.elementInfo.dataZoom && this.elementInfo.dataZoom.show ? [{...this.elementInfo.dataZoom,...DATAZOOM_DEFAULT}] : [{show: false}]) this.$set(this.ec.option, 'dataZoom', this.elementInfo.dataZoom && this.elementInfo.dataZoom.show ? [{...this.elementInfo.dataZoom,...DATAZOOM_DEFAULT}] : [{show: false}])
if(categories.length < this.elementInfo.dataZoom.count) {
this.$set(this.ec.option, 'dataZoom.start', 0)
this.$set(this.ec.option, 'dataZoom.end', 100)
} else {
this.$set(this.ec.option, 'dataZoom.start', this.elementInfo.dataZoom.start)
this.$set(this.ec.option, 'dataZoom.end', this.elementInfo.dataZoom.end)
}
if(chart) { if(chart) {
// 重新setOption,使得设置的formatter生效 // 重新setOption,使得设置的formatter生效
chart.setOption({ chart.setOption({
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</template> </template>
<u-dropdown v-if="elementInfo.option.tabs.type === 'dropdown'" :title-size="getFontSize()" ref="uDropdown" <u-dropdown v-if="elementInfo.option.tabs.type === 'dropdown'" :title-size="getFontSize()" ref="uDropdown"
:active-color="elementInfo.option.tabs.color" :inactive-color="elementInfo.option.tabs.color"> :active-color="elementInfo.option.tabs.color" :inactive-color="elementInfo.option.tabs.color" :menu-icon-size="getFontSize()" :height="elementInfo.height">
<u-dropdown-item v-model="tabsValue" :title="getSelectLabel(tabsValue)"> <u-dropdown-item v-model="tabsValue" :title="getSelectLabel(tabsValue)">
<view class="slot-content" :style="{'background-color': elementInfo.option.tabs.itemBackgroundColor}" v-for="(item, index) in elementData.dataList.series" :key="index"> <view class="slot-content" :style="{'background-color': elementInfo.option.tabs.itemBackgroundColor}" v-for="(item, index) in elementData.dataList.series" :key="index">
<view class="drop-item" @click="handleDropdownValue(item)" <view class="drop-item" @click="handleDropdownValue(item)"
......
...@@ -32,7 +32,7 @@ export default { ...@@ -32,7 +32,7 @@ export default {
*/ */
async handleDynamicData (value) { async handleDynamicData (value) {
const that = this const that = this
let { dataUrl, dataMethod, dataFormatter, dataProcessing } = { ...value } let { dataUrl, dataMethod, dataFormatter, dataProcessing, dataConfig } = { ...value }
if(value.queryFormatter) dataFormatter = {...dataFormatter, ...value.queryFormatter} if(value.queryFormatter) dataFormatter = {...dataFormatter, ...value.queryFormatter}
dataUrl = dataUrl.replace(/^(\/(dashboardCharts|dashboardAPI))?/, '') dataUrl = dataUrl.replace(/^(\/(dashboardCharts|dashboardAPI))?/, '')
dataFormatter = that.$u.common.filterRequestParams({...dataFormatter}) dataFormatter = that.$u.common.filterRequestParams({...dataFormatter})
...@@ -41,6 +41,8 @@ export default { ...@@ -41,6 +41,8 @@ export default {
}) })
if (dataProcessing) { if (dataProcessing) {
that.elementData.dataList = that.$u.common.converFunction(dataProcessing, res.data, value.queryFormatter) that.elementData.dataList = that.$u.common.converFunction(dataProcessing, res.data, value.queryFormatter)
} else if (dataConfig && dataConfig.value && dataConfig.value.length) {
that.elementData.dataList = that.$u.charts.parseChartData(res.data, that.elementInfo)
} else { } else {
that.elementData.dataList = JSON.parse(JSON.stringify(res.data.Result)) that.elementData.dataList = JSON.parse(JSON.stringify(res.data.Result))
} }
...@@ -50,9 +52,11 @@ export default { ...@@ -50,9 +52,11 @@ export default {
*/ */
handlePublicData (value) { handlePublicData (value) {
if (!this.vuex_globalData) return if (!this.vuex_globalData) return
const { dataProcessing } = { ...value } const { dataProcessing, dataConfig} = { ...value }
if (dataProcessing) { if (dataProcessing) {
this.elementData.dataList = this.$u.common.converFunction(dataProcessing, this.vuex_globalData, value.queryFormatter) this.elementData.dataList = this.$u.common.converFunction(dataProcessing, this.vuex_globalData, value.queryFormatter)
} else if (dataConfig && dataConfig.value && dataConfig.value.length) {
this.elementData.dataList = this.$u.charts.parseChartData(this.vuex_globalData, this.elementInfo)
} else { } else {
this.elementData.dataList = this.vuex_globalData this.elementData.dataList = this.vuex_globalData
} }
...@@ -130,7 +134,7 @@ export default { ...@@ -130,7 +134,7 @@ export default {
that.handleStaticData(newVal) that.handleStaticData(newVal)
} else if (newVal.dataType === 'dynamic') { } else if (newVal.dataType === 'dynamic') {
that.handleDynamicData(newVal) that.handleDynamicData(newVal)
if (newVal.dataPolling) { if (newVal.dataPolling && newVal.dataPollingInterval > 0) {
that.timer = setInterval(() => { that.timer = setInterval(() => {
that.handleDynamicData(newVal) that.handleDynamicData(newVal)
}, newVal.dataPollingInterval * 1000) }, newVal.dataPollingInterval * 1000)
...@@ -141,7 +145,7 @@ export default { ...@@ -141,7 +145,7 @@ export default {
that.handlePublicData(newVal) that.handlePublicData(newVal)
} else if (newVal.dataType === 'dataSet') { } else if (newVal.dataType === 'dataSet') {
that.handleDataSet(newVal) that.handleDataSet(newVal)
if (newVal.dataPolling) { if (newVal.dataPolling && newVal.dataPollingInterval > 0) {
that.timer = setInterval(() => { that.timer = setInterval(() => {
that.handleDataSet(newVal) that.handleDataSet(newVal)
}, newVal.dataPollingInterval * 1000) }, newVal.dataPollingInterval * 1000)
...@@ -150,7 +154,7 @@ export default { ...@@ -150,7 +154,7 @@ export default {
} }
} else if (newVal.dataType === 'viewConfig') { } else if (newVal.dataType === 'viewConfig') {
that.handleViewConfig(newVal) that.handleViewConfig(newVal)
if (newVal.dataPolling) { if (newVal.dataPolling && newVal.dataPollingInterval > 0) {
that.timer = setInterval(() => { that.timer = setInterval(() => {
that.handleViewConfig(newVal) that.handleViewConfig(newVal)
}, newVal.dataPollingInterval * 1000) }, newVal.dataPollingInterval * 1000)
......
<template> <template>
<view class="wrapper" :class="{'tabs-layout': showTabs}" :style="{width: `${theStyle.width - theStyle.left}px`, left:`${theStyle.left}px`}"> <view class="wrapper" :class="{'tabs-layout': showTabs}" :style="{width: `${theStyle.width - theStyle.left}px`, left:`${theStyle.left}px`}">
<!-- 普通选项卡 --> <!-- 普通选项卡 -->
<view v-if="showTabs"
style="position: fixed;top: 0;"
:style="{
width: `${parseInt(tabsElement.width * scale)}px`,
height: `${parseInt(tabsElement.height * (scale > 1 ? 1 : scale))}px`,
left: `${parseInt(tabsElement.left * scale)}px`,
zIndex: 10
}"
>
<NormalTabs <NormalTabs
v-if="showTabs"
:elementInfo="tabsElement" :elementInfo="tabsElement"
:style="{width: `${theStyle.width - theStyle.left}px`}"
></NormalTabs> ></NormalTabs>
<view :style="{height: `${theStyle.height}px`, width: `${theStyle.width - theStyle.left}px`}"> </view>
<view :style="{'margin-top': `${tabsElement.height * (scale > 1 ? 1 : scale)}px`, height: `${theStyle.height}px`, width: `${theStyle.width - theStyle.left}px`, zIndex: 9}">
<!-- 普通柱状图 --> <!-- 普通柱状图 -->
<NormalBar v-if="element.type == 'NormalBar'" :elementInfo="element"></NormalBar> <NormalBar v-if="element.type == 'NormalBar'" :elementInfo="element"></NormalBar>
<!-- 普通折线图 --> <!-- 普通折线图 -->
...@@ -42,6 +50,15 @@ ...@@ -42,6 +50,15 @@
left: safeArea.left left: safeArea.left
} }
}, },
scale() {
let info = JSON.parse(uni.getStorageSync('reportInfo'))
if(JSON.stringify(info) == "{}") {
return
}
const { windowWidth } = uni.getSystemInfoSync()
const { width, height } = info.info
return windowWidth / width
}
}, },
onLoad(option) { onLoad(option) {
this.element = JSON.parse(decodeURIComponent(option.element)) this.element = JSON.parse(decodeURIComponent(option.element))
......
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