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

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

@ -59,7 +59,25 @@ export default {
this.charts?.clear() this.charts?.clear()
}, },
methods: { 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 = [] const dataList = []
data?.data?.forEach(item => { data?.data?.forEach(item => {
dataList.push({ name: item[config.customize.name], value: [item[config.customize.xaxis], item[config.customize.yaxis], item[config.customize.value]] }) 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 return config
}, },
async newChart (options) { async newChart (config) {
this.charts = echarts.init( this.charts = echarts.init(
document.getElementById(`chart${this.config.code}`) document.getElementById(`chart${this.config.code}`)
) )
const option = { const option = {
// //
backgroundColor: this.config.customize.backgroundColor, backgroundColor: config.customize.backgroundColor,
geo: { geo: {
map: this.config.customize.scope, map: config.customize.scope,
label: { label: {
// //
normal: { normal: {
show: this.config.customize.mapName, show: config.customize.mapName,
textStyle: { textStyle: {
color: '#fff' color: '#fff'
} }
@ -97,9 +115,9 @@ export default {
// //
itemStyle: { itemStyle: {
normal: { normal: {
borderColor: this.config.customize.mapLineColor, borderColor: config.customize.mapLineColor,
borderWidth: 1, borderWidth: 1,
areaColor: this.config.customize.areaColor, areaColor: config.customize.areaColor,
shadowColor: 'fffff', shadowColor: 'fffff',
shadowOffsetX: -2, shadowOffsetX: -2,
shadowOffsetY: 2, shadowOffsetY: 2,
@ -117,8 +135,8 @@ export default {
show: false, show: false,
trigger: 'item', trigger: 'item',
alwaysShowContent: false, alwaysShowContent: false,
backgroundColor: this.config.customize.tooltipBackgroundColor, backgroundColor: config.customize.tooltipBackgroundColor,
borderColor: this.config.customize.borderColor, borderColor: config.customize.borderColor,
hideDelay: 100, hideDelay: 100,
triggerOn: 'mousemove', triggerOn: 'mousemove',
enterable: true, enterable: true,
@ -131,7 +149,7 @@ export default {
}, },
showDelay: 100 showDelay: 100
}, },
series: this.config.customize.scatter series: config.customize.scatter
? [ ? [
// { // {
// type: 'effectScatter', // type: 'effectScatter',
@ -188,29 +206,29 @@ export default {
formatter (value) { formatter (value) {
return value.data.value[2] return value.data.value[2]
}, },
color: this.config.customize.scatterColor color: config.customize.scatterColor
}, },
// //
itemStyle: { itemStyle: {
normal: { normal: {
color: this.config.customize.scatterBackgroundColor, color: config.customize.scatterBackgroundColor,
shadowBlur: 2, shadowBlur: 2,
shadowColor: 'D8BC37' shadowColor: 'D8BC37'
} }
}, },
data: options.data data: config.option?.data
} }
] ]
: [ : [
{ {
type: 'map', type: 'map',
map: this.config.customize.scope, map: config.customize.scope,
geoIndex: 0, geoIndex: 0,
roam: false, roam: false,
zoom: 1.5, zoom: 1.5,
center: [105, 36], center: [105, 36],
showLegendSymbol: false, // legend showLegendSymbol: false, // legend
data: options.data, data: config.option?.data,
tooltip: { tooltip: {
formatter (params) { formatter (params) {
return `<p style="text-align:center;line-height: 30px;height:30px;font-size: 14px;border-bottom: 1px solid #7A8698;">${ 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 = { option.visualMap = {
show: true, show: true,
min: this.config.customize.range[0], min: config.customize.range[0],
max: this.config.customize.range[1], max: config.customize.range[1],
seriesIndex: [0], seriesIndex: [0],
inRange: { 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) 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.setOption(option)
// this.charts.on('click', (params) => { // this.charts.on('click', (params) => {
// get( // get(

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

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

Loading…
Cancel
Save