Commit a74052f3 authored by leon's avatar leon

fix: datazoom enable when show is true

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