feat--新增中国地图-柱形地图-动态数据解析

qianming 1 year ago
parent df494710c8
commit 940d9eabd1

@ -1,5 +1,6 @@
import miment from 'miment' import miment from 'miment'
import {getData} from '@/api/bigscreen' import {getData} from '@/api/bigscreen'
export default { export default {
data() { data() {
return { return {
@ -180,6 +181,8 @@ export default {
return this.radarChartFn(params.chartProperties, data) return this.radarChartFn(params.chartProperties, data)
} else if (chartType == "widget-select") { } else if (chartType == "widget-select") {
return this.selectChartFn(params.chartProperties, data) return this.selectChartFn(params.chartProperties, data)
} else if (chartType == "widget-mapv2chart") {
return this.mapLLChartFn(params.chartProperties, data)
} else { } else {
return data return data
} }
@ -365,6 +368,27 @@ export default {
} }
return analysisData; return analysisData;
}, },
// 地图带经纬度数据解析
mapLLChartFn(chartProperties, data) {
const analysisData = [];
for (let i = 0; i < data.length; i++) {
const obj = {};
for (const key in chartProperties) {
const value = chartProperties[key];
if (value === "name") {
obj["name"] = data[i][key];
} else if (value === "longitude") {
obj["longitude"] = Number(data[i][key]);
} else if (value === "latitude") {
obj["latitude"] = Number(data[i][key]);
} else {
obj["value"] = data[i][key];
}
}
analysisData.push(obj);
}
return analysisData;
},
setUnique(arr) { setUnique(arr) {
let newArr = []; let newArr = [];
arr.forEach(item => { arr.forEach(item => {

@ -237,14 +237,6 @@ export const widgetBarMap = {
placeholder: '', placeholder: '',
value: 20, value: 20,
}, },
/*{
type: 'vue-color',
label: '柱体颜色',
name: 'barColor',
required: false,
placeholder: '',
value: 'rgba(22,255,255, 1)'
},*/
{ {
type: 'el-input-number', type: 'el-input-number',
label: '柱底外圆大小', label: '柱底外圆大小',
@ -253,14 +245,6 @@ export const widgetBarMap = {
placeholder: '', placeholder: '',
value: 30, value: 30,
}, },
/* {
type: 'vue-color',
label: '柱底外圆颜色',
name: 'barBottomOutColor',
required: false,
placeholder: '',
value: 'rgba(22,255,255, 1)'
},*/
], ],
}, },
{ {
@ -282,14 +266,6 @@ export const widgetBarMap = {
placeholder: '', placeholder: '',
value: 15, value: 15,
}, },
/* {
type: 'vue-color',
label: '文字颜色',
name: 'fontTextColor',
required: false,
placeholder: '',
value: '#D4EEFF'
},*/
{ {
type: 'el-select', type: 'el-select',
label: '文字粗细', label: '文字粗细',
@ -333,14 +309,6 @@ export const widgetBarMap = {
placeholder: '', placeholder: '',
value: 15, value: 15,
}, },
/*{
type: 'vue-color',
label: '数值颜色',
name: 'fontDataColor',
required: false,
placeholder: '',
value: '#D4EEFF'
},*/
{ {
type: 'el-select', type: 'el-select',
label: '数值粗细', label: '数值粗细',
@ -466,8 +434,8 @@ export const widgetBarMap = {
required: false, required: false,
placeholder: '', placeholder: '',
relactiveDom: 'dataType', relactiveDom: 'dataType',
chartType: 'widget-piechart', chartType: 'widget-mapv2chart',
dictKey: 'MAP_PROPERTIES', dictKey: 'MAP_V2_PROPERTIES',
relactiveDomValue: 'dynamicData', relactiveDomValue: 'dynamicData',
value: '', value: '',
}, },

@ -50,7 +50,7 @@ export default {
layoutSize: "80%", layoutSize: "80%",
label: { label: {
emphasis: { emphasis: {
show: true, show: false,
color: "white", color: "white",
}, },
}, },
@ -86,7 +86,7 @@ export default {
aspectScale: 0.75, aspectScale: 0.75,
type: 'map', type: 'map',
map: 'china', map: 'china',
roam: true, //roam: true,
effect: { effect: {
show: false, show: false,
period: 6, period: 6,
@ -318,8 +318,8 @@ export default {
// options // options
editorOptions() { editorOptions() {
this.setOptionsTitle(); this.setOptionsTitle();
this.setOptionsMap();
this.setOptionsTooltip(); this.setOptionsTooltip();
this.setOptionsMap();
this.setOptionsData(); this.setOptionsData();
}, },
// //
@ -344,6 +344,27 @@ export default {
}; };
this.options.title = title; this.options.title = title;
}, },
// tooltip
setOptionsTooltip() {
const optionsSetup = this.optionsSetup;
const tooltip = {
trigger: "item",
show: true,
enterable: true,
textStyle: {
color: optionsSetup.tipsColor,
fontSize: optionsSetup.tipsFontSize,
},
formatter: function (params) {
if (params.seriesType == 'scatter') {
return params.data.name + "" + params.data.value[2];
} else {
return params.name;
}
},
};
this.options.tooltip = tooltip;
},
// //
setOptionsMap() { setOptionsMap() {
const optionsSetup = this.optionsSetup; const optionsSetup = this.optionsSetup;
@ -357,7 +378,7 @@ export default {
fontSize: optionsSetup.fontSizeMap, fontSize: optionsSetup.fontSizeMap,
}, },
emphasis: { emphasis: {
show: true, show: false,
}, },
} }
const itemStyle = { const itemStyle = {
@ -410,7 +431,7 @@ export default {
const maxValue = Math.max.apply(null, val.map(item => item.value)) const maxValue = Math.max.apply(null, val.map(item => item.value))
return heightRate / maxValue; return heightRate / maxValue;
}, },
// //
calScatterTrunk(val, heightRate) { calScatterTrunk(val, heightRate) {
return val.map((item) => { return val.map((item) => {
return { return {
@ -418,13 +439,13 @@ export default {
} }
}) })
}, },
// //
calScatterTop(val, heightRate) { calScatterTop(val, heightRate) {
return val.map((item) => { return val.map((item) => {
return [geoCoordMap[item.name][0], geoCoordMap[item.name][1] + item.value * this.calMaxHeight(val, heightRate), item.value] return [geoCoordMap[item.name][0], geoCoordMap[item.name][1] + item.value * this.calMaxHeight(val, heightRate), item.value]
}) })
}, },
// //
calScatterBottom(val) { calScatterBottom(val) {
return val.map((item) => { return val.map((item) => {
return { return {
@ -433,27 +454,6 @@ export default {
} }
}) })
}, },
// tooltip
setOptionsTooltip() {
const optionsSetup = this.optionsSetup;
const tooltip = {
trigger: "item",
show: true,
enterable: true,
textStyle: {
color: optionsSetup.tipsColor,
fontSize: optionsSetup.tipsFontSize,
},
formatter: function (params) {
if (params.seriesType == 'scatter') {
return params.data.name + "" + params.data.value[2];
} else {
return params.name;
}
},
};
this.options.tooltip = tooltip;
},
// //
getOptionsBarTrunk(optionsSetup, arrColor, allData, heightRate) { getOptionsBarTrunk(optionsSetup, arrColor, allData, heightRate) {
const barTrunk = { const barTrunk = {
@ -635,7 +635,6 @@ export default {
longitude[i] = val[i].longitude; longitude[i] = val[i].longitude;
value[i] = val[i].value; value[i] = val[i].value;
} }
// console.log(Object.keys(val[0]))
let allData = []; let allData = [];
for (const i in name) { for (const i in name) {
geoCoordMap[name[i]] = [latitude[i], longitude[i]] geoCoordMap[name[i]] = [latitude[i], longitude[i]]
@ -678,28 +677,45 @@ export default {
}); });
}, },
renderingFn(val) { renderingFn(val) {
this.options.series[0]["data"] = val; let name = [];
let latitude = [];
let longitude = [];
let value = [];
for (const i in val) {
name[i] = val[i].name;
latitude[i] = val[i].latitude;
longitude[i] = val[i].longitude;
value[i] = val[i].value;
}
for (const i in val) {
name[i] = val[i].name;
latitude[i] = val[i].latitude;
longitude[i] = val[i].longitude;
value[i] = val[i].value;
}
let allData = [];
for (const i in name) {
geoCoordMap[name[i]] = [latitude[i], longitude[i]]
const obj = {
name: name[i],
value: value[i]
}
allData.push(obj)
}
const optionsSetup = this.optionsSetup; const optionsSetup = this.optionsSetup;
const label = this.options.series[1]["label"]; const heightRate = optionsSetup.heightRate;
const normal = { //
show: true, const customColor = optionsSetup.customColor;
color: "#fff", if (!customColor) return;
fontWeight: "bold", const arrColor = [];
position: "inside", for (const i in val) {
formatter: function (para) { arrColor.push(customColor[i % customColor.length].color)
return "{cnNum|" + para.data.value[2] + "}"; }
},
rich: { this.$set(this.options.series,1,this.getOptionsBarTrunk(optionsSetup, arrColor, allData, heightRate))
cnNum: { this.$set(this.options.series,2,this.getOptionsBarTop(optionsSetup, arrColor, allData, heightRate))
fontSize: optionsSetup.fontDataSize, this.$set(this.options.series,3,this.getOptionsBarBottom(optionsSetup, arrColor, allData))
color: optionsSetup.fontDataColor, this.$set(this.options.series,4,this.getOptionsBarBottomOut(optionsSetup, arrColor, allData))
fontWeight: optionsSetup.fontDataWeight,
},
},
};
const data = convertData(val);
this.options.series[1]["data"] = data;
label["normal"] = normal;
}, },
}, },
}; };

Loading…
Cancel
Save