feat:修复组件尺寸问题,以及优化地图

main
liu.tao3 2 years ago
parent 84a2d76f7f
commit 5de5afbe4f

@ -59,7 +59,25 @@ export default {
this.charts?.clear()
},
methods: {
buildOption (config, data) {
chartInit () {
let config = this.config
// keycodelist
if (this.config.code === this.config.key || this.isPreview) {
//
this.changeDataByCode(config).then((res) => {
//
// config = this.changeStyle(res)
this.newChart(config)
}).catch(() => {})
} else {
// changeStylekey,chart
this.changeData(config).then((res) => {
//
this.newChart(res)
})
}
},
dataFormatting (config, data) {
const dataList = []
data?.data?.forEach(item => {
dataList.push({ name: item[config.customize.name], value: [item[config.customize.xaxis], item[config.customize.yaxis], item[config.customize.value]] })
@ -70,19 +88,19 @@ export default {
}
return config
},
async newChart (options) {
async newChart (config) {
this.charts = echarts.init(
document.getElementById(`chart${this.config.code}`)
)
const option = {
//
backgroundColor: this.config.customize.backgroundColor,
backgroundColor: config.customize.backgroundColor,
geo: {
map: this.config.customize.scope,
map: config.customize.scope,
label: {
//
normal: {
show: this.config.customize.mapName,
show: config.customize.mapName,
textStyle: {
color: '#fff'
}
@ -97,9 +115,9 @@ export default {
//
itemStyle: {
normal: {
borderColor: this.config.customize.mapLineColor,
borderColor: config.customize.mapLineColor,
borderWidth: 1,
areaColor: this.config.customize.areaColor,
areaColor: config.customize.areaColor,
shadowColor: 'fffff',
shadowOffsetX: -2,
shadowOffsetY: 2,
@ -117,8 +135,8 @@ export default {
show: false,
trigger: 'item',
alwaysShowContent: false,
backgroundColor: this.config.customize.tooltipBackgroundColor,
borderColor: this.config.customize.borderColor,
backgroundColor: config.customize.tooltipBackgroundColor,
borderColor: config.customize.borderColor,
hideDelay: 100,
triggerOn: 'mousemove',
enterable: true,
@ -131,7 +149,7 @@ export default {
},
showDelay: 100
},
series: this.config.customize.scatter
series: config.customize.scatter
? [
// {
// type: 'effectScatter',
@ -188,29 +206,29 @@ export default {
formatter (value) {
return value.data.value[2]
},
color: this.config.customize.scatterColor
color: config.customize.scatterColor
},
//
itemStyle: {
normal: {
color: this.config.customize.scatterBackgroundColor,
color: config.customize.scatterBackgroundColor,
shadowBlur: 2,
shadowColor: 'D8BC37'
}
},
data: options.data
data: config.option?.data
}
]
: [
{
type: 'map',
map: this.config.customize.scope,
map: config.customize.scope,
geoIndex: 0,
roam: false,
zoom: 1.5,
center: [105, 36],
showLegendSymbol: false, // legend
data: options.data,
data: config.option?.data,
tooltip: {
formatter (params) {
return `<p style="text-align:center;line-height: 30px;height:30px;font-size: 14px;border-bottom: 1px solid #7A8698;">${
@ -225,20 +243,20 @@ export default {
}
]
}
if (this.config.customize.visual) {
if (config.customize.visual) {
option.visualMap = {
show: true,
min: this.config.customize.range[0],
max: this.config.customize.range[1],
min: config.customize.range[0],
max: config.customize.range[1],
seriesIndex: [0],
inRange: {
color: this.config.customize.rangeColor
color: config.customize.rangeColor
}
}
}
const mapUrl = `${window.BS_CONFIG?.httpConfigs?.baseURL}/static/chinaMap/${this.config.customize.level}/${this.config.customize.dataMap}`
const mapUrl = `${window.BS_CONFIG?.httpConfigs?.baseURL}/static/chinaMap/${config.customize.level}/${config.customize.dataMap}`
const map = await get(decodeURI(mapUrl), {}, true)
echarts.registerMap(this.config.customize.scope, map)
echarts.registerMap(config.customize.scope, map)
this.charts.setOption(option)
// this.charts.on('click', (params) => {
// get(

@ -151,6 +151,7 @@ export default {
'changeLayout',
'changeActiveCode',
'changeChartConfig',
'changeActiveItemConfig',
'changeActiveItemWH',
'addItem',
'delItem',
@ -237,6 +238,13 @@ export default {
x: left,
y: top
})
this.changeActiveItemConfig({
...chart,
w: width,
h: height,
x: left,
y: top
})
if (chart.code === this.activeCode) {
this.changeActiveItemWH({
w: width,
@ -258,6 +266,11 @@ export default {
x: left,
y: top
})
this.changeActiveItemConfig({
...chart,
x: left,
y: top
})
if (chart.code === this.activeCode) {
this.changeActiveItemWH({
x: left,

@ -107,6 +107,15 @@ export default {
state.activeId = activeItem.code
// state.settingJson = _.cloneDeep(activeItem.settingConfig) || {}
},
// 改变当前组件的xywh
changeActiveItemWH(state, chart) {
if (chart.code === state.activeItemConfig.code) {
state.activeItemConfig = {
...state.activeItemConfig,
...chart
}
}
},
// 清空卡尺对齐线
resetPresetLine (state) {
state.presetLine = []

Loading…
Cancel
Save