Commit a74052f3 authored by leon's avatar leon

fix: datazoom enable when show is true

parent 6e627ad2
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
...this.elementInfo.option.yAxis, ...this.elementInfo.option.yAxis,
data: this.dealSeriesData(series).categories data: this.dealSeriesData(series).categories
}, },
dataZoom: this.elementInfo.dataZoom, dataZoom: this.elementInfo.dataZoom.show ? this.elementInfo.dataZoom : [],
series: { series: {
id: 'associate', id: 'associate',
type: 'bar', type: 'bar',
......
...@@ -45,26 +45,26 @@ ...@@ -45,26 +45,26 @@
...this.elementInfo.option.yAxis, ...this.elementInfo.option.yAxis,
data: categories data: categories
}, },
tooltip: { tooltip: {
...this.elementInfo.option.tooltip, ...this.elementInfo.option.tooltip,
trigger: "axis" trigger: "axis"
}, },
dataZoom: this.elementInfo.dataZoom, dataZoom: this.elementInfo.dataZoom.show ? this.elementInfo.dataZoom : [],
series: this.dealSeriesData(series) series: this.dealSeriesData(series)
} }
chart.setOption(this.ec.option) chart.setOption(this.ec.option)
const that = this const that = this
chart.on('click', event => { chart.on('click', event => {
const { preview, images } = that.elementData.dataList const { preview, images } = that.elementData.dataList
var urls = [] var urls = []
var caches = uni.getStorageSync('cacheImages') var caches = uni.getStorageSync('cacheImages')
images.forEach(url => { images.forEach(url => {
if(caches.hasOwnProperty(url)) { if(caches.hasOwnProperty(url)) {
urls.push(caches[url]) urls.push(caches[url])
} else { } else {
urls.push(url) urls.push(url)
} }
}) })
// 特殊处理,如果preview为true,代表点击显示图片 // 特殊处理,如果preview为true,代表点击显示图片
if (preview) { if (preview) {
uni.previewImage({ uni.previewImage({
...@@ -74,19 +74,19 @@ ...@@ -74,19 +74,19 @@
} else { } else {
that.handleEchartsClick(event) that.handleEchartsClick(event)
} }
}) })
chart.on('datazoom', event => { chart.on('datazoom', event => {
that.echartsDataZoom(event) that.echartsDataZoom(event)
}) })
return chart return chart
}, },
initChart() { initChart() {
const { categories, series, preview, images } = this.elementData.dataList const { categories, series, preview, images } = this.elementData.dataList
this.$set(this.ec.option, 'yAxis.data', categories) this.$set(this.ec.option, 'yAxis.data', categories)
this.$set(this.ec.option, 'series', this.dealSeriesData(series)) this.$set(this.ec.option, 'series', this.dealSeriesData(series))
this.$set(this.ec.option, 'dataZoom', this.elementInfo.dataZoom) this.$set(this.ec.option, 'dataZoom', this.elementInfo.dataZoom.show ? this.elementInfo.dataZoom : [])
if(preview) { if(preview) {
this.cacheImages(images) this.cacheImages(images)
} }
}, },
/** /**
...@@ -113,30 +113,30 @@ ...@@ -113,30 +113,30 @@
} }
}) })
return newData return newData
}, },
/** /**
* 缓存图片数据 * 缓存图片数据
*/ */
cacheImages(images) { cacheImages(images) {
var caches = uni.getStorageSync('cacheImages') var caches = uni.getStorageSync('cacheImages')
if(!caches) { if(!caches) {
caches = {} caches = {}
} }
images.forEach(url => { images.forEach(url => {
// 如果包含当前url,就不再下载 // 如果包含当前url,就不再下载
if(!caches.hasOwnProperty(url)) { if(!caches.hasOwnProperty(url)) {
uni.downloadFile({ uni.downloadFile({
url: url, url: url,
success: (res) => { success: (res) => {
if(res.statusCode === 200) { if(res.statusCode === 200) {
caches[url] = res.tempFilePath caches[url] = res.tempFilePath
uni.setStorageSync('cacheImages', caches) uni.setStorageSync('cacheImages', caches)
} }
} }
}) })
} }
}) })
} }
} }
} }
......
...@@ -54,11 +54,11 @@ ...@@ -54,11 +54,11 @@
type: 'value' type: 'value'
} }
], ],
tooltip: { tooltip: {
...this.elementInfo.option.tooltip, ...this.elementInfo.option.tooltip,
trigger: "axis" trigger: "axis"
}, },
dataZoom: this.elementInfo.dataZoom, dataZoom: this.elementInfo.dataZoom.show ? this.elementInfo.dataZoom : [],
series: this.dealSeriesData(series) series: this.dealSeriesData(series)
} }
chart.setOption(this.ec.option) chart.setOption(this.ec.option)
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
const {categories, series } = this.elementData.dataList const {categories, series } = this.elementData.dataList
this.$set(this.ec.option, 'xAxis.data', categories) this.$set(this.ec.option, 'xAxis.data', categories)
this.$set(this.ec.option, 'series', this.dealSeriesData(series)) this.$set(this.ec.option, 'series', this.dealSeriesData(series))
this.$set(this.ec.option, 'dataZoom', this.elementInfo.dataZoom) this.$set(this.ec.option, 'dataZoom', this.elementInfo.dataZoom.show ? this.elementInfo.dataZoom : [])
}, },
/** /**
* 处理数据 * 处理数据
......
...@@ -39,12 +39,12 @@ ...@@ -39,12 +39,12 @@
xAxis: { xAxis: {
...this.elementInfo.option.xAxis, ...this.elementInfo.option.xAxis,
data: categories data: categories
}, },
tooltip: { tooltip: {
...this.elementInfo.option.tooltip, ...this.elementInfo.option.tooltip,
trigger: "axis" trigger: "axis"
}, },
dataZoom: this.elementInfo.dataZoom, dataZoom: this.elementInfo.dataZoom.show ? this.elementInfo.dataZoom : [],
series: this.dealSeriesData(series) series: this.dealSeriesData(series)
} }
chart.setOption(this.ec.option) chart.setOption(this.ec.option)
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
const { categories, series } = this.elementData.dataList const { categories, series } = this.elementData.dataList
this.$set(this.ec.option, 'xAxis.data', categories) this.$set(this.ec.option, 'xAxis.data', categories)
this.$set(this.ec.option, 'series', this.dealSeriesData(series)) this.$set(this.ec.option, 'series', this.dealSeriesData(series))
this.$set(this.ec.option, 'dataZoom', this.elementInfo.dataZoom) this.$set(this.ec.option, 'dataZoom', this.elementInfo.dataZoom.show ? this.elementInfo.dataZoom : [])
}, },
/** /**
* 处理数据 * 处理数据
......
...@@ -41,12 +41,12 @@ ...@@ -41,12 +41,12 @@
xAxis: { xAxis: {
...this.elementInfo.option.xAxis, ...this.elementInfo.option.xAxis,
data: categories data: categories
}, },
tooltip: { tooltip: {
...this.elementInfo.option.tooltip, ...this.elementInfo.option.tooltip,
trigger: "axis" trigger: "axis"
}, },
dataZoom: this.elementInfo.dataZoom, dataZoom: this.elementInfo.dataZoom.show ? this.elementInfo.dataZoom : [],
series: this.dealSeriesData(series) series: this.dealSeriesData(series)
} }
chart.setOption(this.ec.option) chart.setOption(this.ec.option)
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
initChart() { initChart() {
const { categories, series } = this.elementData.dataList const { categories, series } = this.elementData.dataList
this.$set(this.ec.option, 'xAxis.data', categories) this.$set(this.ec.option, 'xAxis.data', categories)
this.$set(this.ec.option, 'series', this.dealSeriesData(series)) this.$set(this.ec.option, 'series', this.dealSeriesData(series))
this.$set(this.ec.option, 'dataZoom', this.elementInfo.dataZoom) this.$set(this.ec.option, 'dataZoom', this.elementInfo.dataZoom.show ? this.elementInfo.dataZoom : [])
}, },
/** /**
* 处理数据 * 处理数据
......
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