|
|
|
@ -3,6 +3,7 @@
|
|
|
|
|
style="width: 100%; height: 100%"
|
|
|
|
|
class="bs-design-wrap bs-bar"
|
|
|
|
|
>
|
|
|
|
|
<el-button class="button" v-if="this.level=='province'&&config.customize.down" @click="jumpTo(config)" type='text' > 返回上一级</el-button>
|
|
|
|
|
<div
|
|
|
|
|
:id="`chart${config.code}`"
|
|
|
|
|
style="width: 100%; height: 100%"
|
|
|
|
@ -32,7 +33,8 @@ export default {
|
|
|
|
|
return {
|
|
|
|
|
charts: null,
|
|
|
|
|
hasData: false,
|
|
|
|
|
level:''
|
|
|
|
|
level:'',
|
|
|
|
|
option:{}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
@ -88,11 +90,20 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
return config
|
|
|
|
|
},
|
|
|
|
|
async jumpTo(config){
|
|
|
|
|
this.level='country'
|
|
|
|
|
const mapUrl =`${window.BS_CONFIG?.httpConfigs?.baseURL}/static/chinaMap/country/中华人民共和国.json`
|
|
|
|
|
const map = await this.$dataRoomAxios.get(decodeURI(mapUrl), {}, true)
|
|
|
|
|
this.option.geo.map = '中华人民共和国';
|
|
|
|
|
this.changeData({...config,customize:{...config.customize,level:'country',scope:'中国'}})
|
|
|
|
|
echarts.registerMap('中华人民共和国', map);
|
|
|
|
|
this.charts.setOption(this.option, true);
|
|
|
|
|
},
|
|
|
|
|
async newChart (config) {
|
|
|
|
|
this.charts = echarts.init(
|
|
|
|
|
document.getElementById(`chart${this.config.code}`)
|
|
|
|
|
)
|
|
|
|
|
const option = {
|
|
|
|
|
this.option = {
|
|
|
|
|
// 背景颜色
|
|
|
|
|
backgroundColor: config.customize.backgroundColor,
|
|
|
|
|
graphic: [
|
|
|
|
@ -252,7 +263,7 @@ export default {
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
if (config.customize.visual) {
|
|
|
|
|
option.visualMap = {
|
|
|
|
|
this.option.visualMap = {
|
|
|
|
|
show: true,
|
|
|
|
|
min: config.customize.range[0],
|
|
|
|
|
max: config.customize.range[1],
|
|
|
|
@ -262,72 +273,20 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(config.customize.down){
|
|
|
|
|
// config?.customize?.graphic?.forEach((item,index)=>{
|
|
|
|
|
option.graphic.push({
|
|
|
|
|
type: "text",
|
|
|
|
|
left: `220px`,
|
|
|
|
|
top: "5%",
|
|
|
|
|
style: {
|
|
|
|
|
text: '中国',
|
|
|
|
|
font: `bolder ${config.customize.fontSize}px "Microsoft YaHei", sans-serif`,
|
|
|
|
|
fill: config.customize.fontGraphicColor,
|
|
|
|
|
},
|
|
|
|
|
onclick:async()=>{
|
|
|
|
|
this.level='country'
|
|
|
|
|
const index = option.graphic.findIndex(i => i.style.text === '中国');
|
|
|
|
|
// 点击元素之后的所有元素全部删除
|
|
|
|
|
option.graphic.splice(index + 1);
|
|
|
|
|
const mapUrl =`${window.BS_CONFIG?.httpConfigs?.baseURL}/static/chinaMap/country/中华人民共和国.json`
|
|
|
|
|
const map = await this.$dataRoomAxios.get(decodeURI(mapUrl), {}, true)
|
|
|
|
|
option.geo.map = '中华人民共和国'
|
|
|
|
|
this.changeData({...config,customize:{...config.customize,level:'country',scope:'中国'}})
|
|
|
|
|
echarts.registerMap('中华人民共和国', map);
|
|
|
|
|
this.charts.setOption(option, true);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
},)
|
|
|
|
|
// })
|
|
|
|
|
}
|
|
|
|
|
const mapUrl = `${window.BS_CONFIG?.httpConfigs?.baseURL}/static/chinaMap/${config.customize.level}/${config.customize.dataMap}`
|
|
|
|
|
const map = await this.$dataRoomAxios.get(decodeURI(mapUrl), {}, true)
|
|
|
|
|
echarts.registerMap(config.customize.scope, map)
|
|
|
|
|
this.charts.setOption(option)
|
|
|
|
|
this.charts.setOption(this.option)
|
|
|
|
|
this.charts.on('click', async(params)=> {
|
|
|
|
|
const index = option.graphic.findIndex(i => i.style.text === params.name);
|
|
|
|
|
if(params.name=='' || index !== -1) return
|
|
|
|
|
if(params.name=='') return
|
|
|
|
|
if(config.customize.down===false||this.level==='province') return
|
|
|
|
|
const idx = option.graphic.length + 1;
|
|
|
|
|
option.graphic.push({
|
|
|
|
|
type: "text",
|
|
|
|
|
left: `${idx * 220}px`,
|
|
|
|
|
top: "5%",
|
|
|
|
|
style: {
|
|
|
|
|
text: params.name,
|
|
|
|
|
font: `bolder ${config.customize.fontSize}px "Microsoft YaHei", sans-serif`,
|
|
|
|
|
fill: config.customize.fontGraphicColor,
|
|
|
|
|
},
|
|
|
|
|
onclick: async() => {
|
|
|
|
|
const mapUrl =`${window.BS_CONFIG?.httpConfigs?.baseURL}/static/chinaMap/${params.name=='中华人民共和国'?'country':'province'}/${params.name}.json`
|
|
|
|
|
const map = await this.$dataRoomAxios.get(decodeURI(mapUrl), {}, true)
|
|
|
|
|
// 利用函数的作用域,可以直接拿上面的name来用
|
|
|
|
|
const index = option.graphic.findIndex(i => i.style.text === params.name);
|
|
|
|
|
// 点击元素之后的所有元素全部删除
|
|
|
|
|
option.graphic.splice(index + 1);
|
|
|
|
|
// 很多操作重复了,你可以将公共部分抽离出来
|
|
|
|
|
option.geo.map = params.name;
|
|
|
|
|
this.changeData({...config,customize:{...config.customize,level:'province',scope:params.name}})
|
|
|
|
|
echarts.registerMap(params.name, map);
|
|
|
|
|
this.charts.setOption(option, true);
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
this.level='province'
|
|
|
|
|
const mapUrl =`${window.BS_CONFIG?.httpConfigs?.baseURL}/static/chinaMap/province/${params.name}.json`
|
|
|
|
|
const map = await this.$dataRoomAxios.get(decodeURI(mapUrl), {}, true)
|
|
|
|
|
this.changeData({...config,customize:{...config.customize,level:'province',scope:params.name}})
|
|
|
|
|
option.geo.map = params.name
|
|
|
|
|
this.option.geo.map = params.name
|
|
|
|
|
echarts.registerMap(params.name, map);
|
|
|
|
|
this.charts.setOption(option, true);
|
|
|
|
|
this.charts.setOption(this.option, true);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -343,4 +302,11 @@ export default {
|
|
|
|
|
.auto-theme {
|
|
|
|
|
background-color: rgba(0, 0, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
.bs-design-wrap{
|
|
|
|
|
position: relative;
|
|
|
|
|
.button{
|
|
|
|
|
position: absolute;
|
|
|
|
|
z-index: 999;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|