xuechunyuan 3 years ago
commit 6a71a0c820
  1. 236
      src/views/components/showmap.vue
  2. 106
      src/views/dashboard/home.vue

@ -11,6 +11,9 @@ export default {
props: { props: {
mapData:{ mapData:{
type:Array, type:Array,
},
datas:{
type:Array
} }
}, },
data() { data() {
@ -96,7 +99,7 @@ export default {
小店镇: [118.81007, 35.422484], 小店镇: [118.81007, 35.422484],
夏庄镇: [118.700674, 35.419525], 夏庄镇: [118.700674, 35.419525],
}, },
datas: [ datas1: [
[{ name: "夏庄镇", value: 120057.34 }, { name: "莒县电子商务公共服务中心" }], [{ name: "夏庄镇", value: 120057.34 }, { name: "莒县电子商务公共服务中心" }],
[{ name: "库山乡", value: 15477.48 }, { name: "莒县电子商务公共服务中心" }], [{ name: "库山乡", value: 15477.48 }, { name: "莒县电子商务公共服务中心" }],
[{ name: "棋山镇", value: 131686.1 }, { name: "莒县电子商务公共服务中心" }], [{ name: "棋山镇", value: 131686.1 }, { name: "莒县电子商务公共服务中心" }],
@ -146,26 +149,15 @@ export default {
}; };
}, },
mounted() { mounted() {
// this.createCharts1(); this.createCharts1();
this.myChart = this.$echarts.init(document.getElementById("chart_map"));
this.$echarts.registerMap("莒县", prefecture, {});
this.render3DMap();
}, },
created() { created() {
this.$nextTick(() =>{ // this.$nextTick(() =>{
console.log(this.$parent.mapData) // })
console.log(JSON.parse(JSON.stringify(this.$parent.mapData)))
})
}, },
watch:{ watch:{
mapData:{ mapData:{
handler(newValue,oldValue){ handler(newValue,oldValue){
console.log(newValue)
// if(newValue.length !== 0){
// this.render3DMap();
// }
} }
} }
}, },
@ -179,34 +171,33 @@ export default {
var toCoord = this.geoCoordMap[dataItem[1].name]; var toCoord = this.geoCoordMap[dataItem[1].name];
if (fromCoord && toCoord) { if (fromCoord && toCoord) {
res.push([ res.push([
// { {
// coord: toCoord, coord: toCoord,
// fromName: dataItem[0].name, fromName: dataItem[0].name,
// value: dataItem[0].value, value: dataItem[0].value,
// // name: dataItem[0].name, // name: dataItem[0].name,
// visualMap: false, visualMap: false,
// },
// {
// coord: fromCoord,
// toName: dataItem[1].name,
// visualMap: false,
// }, },
{ {
fromName: dataItem[0].name, coord: fromCoord,
toName: dataItem[1].name, toName: dataItem[1].name,
coords: [ visualMap: false,
toCoord,
fromCoord,
]
}, },
]); ]);
} }
} }
return res; return res;
}; };
this.mapData = this.mapData.sort(function (a, b) {
return b.value - a.value;
});
this.mapData.map((item,index) =>{
if(index > 2){
this.mapData[index].label = {show:false}
}
})
var yMax = 0; var yMax = 0;
for (var j = 0; j < this.mapData.length; j++) { for (var j = 0; j < this.mapData.length; j++) {
if (yMax < this.mapData[j].value) { if (yMax < this.mapData[j].value) {
@ -217,8 +208,6 @@ export default {
var color = ['#000']; var color = ['#000'];
// //广 // //广
[[`${this.datas[0][1].name}`, this.datas]].forEach((item, i) => { [[`${this.datas[0][1].name}`, this.datas]].forEach((item, i) => {
console.log(item[1])
console.log(convertData(this.datas));
series.push( series.push(
{ {
type: "lines", type: "lines",
@ -226,76 +215,77 @@ export default {
tooltip: { tooltip: {
trigger: "item", trigger: "item",
formatter(params) { formatter(params) {
// console.log(params);
}, },
}, },
effect: { effect: {
show: true, show: true,
period: 6, // period: 10, //
trailLength: 0, // [0,1] trailLength: 0.1, // [0,1]
symbol: "arrow", // symbol: "arrow", //
symbolSize: 5, // symbolSize: 6, //
trailColor: '#ffd419',
color: '#ffd419', //
}, },
lineStyle: { lineStyle: {
// normal: { // normal: {
color: color[i], color: "#ffd419",
width: 3, // 线 width: 1, // 线
opacity: 0.6, // 线 opacity: 0.6, // 线
curveness: 0.2, // 线 curveness: 0.2, // 线
// }, // },
}, },
data: convertData(item[1]), data: convertData(item[1]),
}, },
{ // {
type: "effectScatter", // type: "effectScatter",
coordinateSystem: "geo", // coordinateSystem: "geo",
zlevel: 2, // zlevel: 2,
rippleEffect: { // rippleEffect: {
// // //
period: 4, // // period: 4, //
brushType: "stroke", // stroke, fill // brushType: "stroke", // stroke, fill
scale: 3, // // scale: 3, //
}, // },
tooltip: { // tooltip: {
trigger: "item", // trigger: "item",
formatter(params) { // formatter(params) {
return params.data.name + ':' + params.data.value[2] // return params.data.name + ':' + params.data.value[2]
}, // },
}, // },
label: { // label: {
normal: { // normal: {
show: true, // show: true,
position: "right", // // position: "right", //
offset: [5, 0], // // offset: [5, 0], //
formatter(params) { // formatter(params) {
// // //
return ''; // return '';
}, // },
fontSize: 13, // fontSize: 13,
}, // },
emphasis: { // emphasis: {
show: true, // show: true,
}, // },
}, // },
symbol: "circle", // symbol: "circle",
symbolSize: 3, // symbolSize: 3,
// itemStyle: { // // itemStyle: {
// normal: { // // normal: {
// // show: false, // // // show: false,
// color: "#000", // // color: "#000",
// }, // // },
// }, // // },
itemStyle: { // itemStyle: {
color: "#000" // color: "#000"
}, // },
data: item[1].map((dataItem) => { // data: item[1].map((dataItem) => {
return { // return {
visualMap: false, // visualMap: false,
name: dataItem[0].name, // name: dataItem[0].name,
value: this.geoCoordMap[dataItem[0].name].concat([dataItem[0].value]), // value: this.geoCoordMap[dataItem[0].name].concat([dataItem[0].value]),
}; // };
}), // }),
}, // },
{ {
name: "数据名称", name: "数据名称",
type: "map", type: "map",
@ -306,32 +296,38 @@ export default {
trigger: "item", trigger: "item",
formatter: "{b}<br/>{c} (件)", formatter: "{b}<br/>{c} (件)",
}, },
itemStyle: { aspectScale:'1.5',
normal: { label: {
borderWidth: 1, show: true,
borderColor: "#0e94eb", textStyle:{
label: { color:'#fff'
show: false, }
},
},
emphasis: {
//
borderWidth: 1,
borderColor: "#fff",
backgroundColor: "red",
label: {
show: true,
textStyle: {
color: "#fff",
},
},
},
}, },
// itemStyle: {
// normal: {
// borderWidth: 1,
// borderColor: "#0e94eb",
// // label: {
// // show: false,
// // },
// },
// emphasis: {
// //
// borderWidth: 1,
// borderColor: "#fff",
// backgroundColor: "red",
// label: {
// show: false,
// textStyle: {
// color: "#fff",
// },
// },
// },
// },
data: this.mapData, data: this.mapData,
} }
); );
}); });
console.log(series);
this.myChart1 = this.$echarts.init(document.getElementById("chart_map")); this.myChart1 = this.$echarts.init(document.getElementById("chart_map"));
// this.myCharts1 = this.$echarts.init(document.getElementById('gdMaps')); // this.myCharts1 = this.$echarts.init(document.getElementById('gdMaps'));
// this.$echarts.registerMap("china1", china1, {}); // this.$echarts.registerMap("china1", china1, {});
@ -359,14 +355,14 @@ export default {
text: ["高", "低"], text: ["高", "低"],
orient: "horizontal", orient: "horizontal",
itemWidth: 15, itemWidth: 15,
itemHeight: 200, itemHeight: 150,
right: 0, right: 0,
bottom: 30, bottom: 3,
inRange: { inRange: {
color: ["#75ddff", "#0e94eb"], color: ["#1e73dd", "#04296f"],
}, },
textStyle: { textStyle: {
color: "#000", color: "#fff",
}, },
}, },
geo: { geo: {
@ -377,6 +373,7 @@ export default {
show: false, show: false,
}, },
}, },
aspectScale:'1.5',
roam: true, // roam: true, //
itemStyle: { itemStyle: {
normal: { normal: {
@ -442,9 +439,6 @@ export default {
} }
return res; return res;
}; };
console.log(convertData(this.datas))
// var color = ['#000'];
var seriesData = []; var seriesData = [];
this.datas.map((item, i) => { this.datas.map((item, i) => {
seriesData.push( seriesData.push(
@ -453,7 +447,6 @@ export default {
} }
); );
}) })
console.log(seriesData)
var yMax = 0; var yMax = 0;
for (var j = 0; j < this.mapData.length; j++) { for (var j = 0; j < this.mapData.length; j++) {
if (yMax < this.mapData[j].value) { if (yMax < this.mapData[j].value) {
@ -468,7 +461,6 @@ export default {
this.mapData[index].label = {show:false} this.mapData[index].label = {show:false}
} }
}) })
console.log(this.mapData)
let option = { let option = {
// backgroundColor: '#000f1e', // backgroundColor: '#000f1e',

@ -166,8 +166,8 @@
</div> </div>
<div class="center_bottom"> <div class="center_bottom">
<div class="charts_box map-box"> <div class="charts_box map-box">
<!-- <ShowMap :mapData="mapData"></ShowMap> --> <ShowMap :mapData="mapData" :datas="datas" v-if="mapData && datas && isMap"></ShowMap>
<div id="chart_map" class="map_box"></div> <!-- <div id="chart_map" class="map_box"></div> -->
</div> </div>
<div class="charts_box"> <div class="charts_box">
<div id="trendChart" class="trend_box"></div> <div id="trendChart" class="trend_box"></div>
@ -348,13 +348,14 @@ export default {
小店镇: [118.81007, 35.422484], 小店镇: [118.81007, 35.422484],
夏庄镇: [118.700674, 35.419525], 夏庄镇: [118.700674, 35.419525],
}, },
isMap:false
}; };
}, },
created() { created() {
this.getTime(); this.getTime();
this.readExcelFile("http://" + location.host + "/excel/wuliu.xlsx");
}, },
mounted() { mounted() {
this.readExcelFile("http://" + location.host + "/excel/wuliu.xlsx");
queryWeath().then((res) => { queryWeath().then((res) => {
this.temp = res.result.now.temp; this.temp = res.result.now.temp;
this.weather = res.result.now.text; this.weather = res.result.now.text;
@ -425,6 +426,7 @@ export default {
} }
content1[2].map((item, index) => { content1[2].map((item, index) => {
this.mapData.push({ name: item.名称, value: item.收件量 }); this.mapData.push({ name: item.名称, value: item.收件量 });
this.isMap = true
this.datas.push([ this.datas.push([
{ name: item.名称, value: item.收件量 }, { name: item.名称, value: item.收件量 },
{ name: "莒县电子商务公共服务中心" }, { name: "莒县电子商务公共服务中心" },
@ -450,6 +452,7 @@ export default {
return b.count - a.count; return b.count - a.count;
}); });
}); });
content1[0].map((item) => { content1[0].map((item) => {
this.pieData.push({ this.pieData.push({
name: item.快递名称, name: item.快递名称,
@ -460,9 +463,9 @@ export default {
this.pieData = this.pieData.sort(function (a, b) { this.pieData = this.pieData.sort(function (a, b) {
return b.y - a.y; return b.y - a.y;
}); });
this.pieData[0].h = 15; this.pieData[0].h = 10;
this.pieData[1].h = 10; this.pieData[1].h = 5;
this.pieData[2].h = 5; this.pieData[2].h = 2;
this.shouData.map((item, index) => { this.shouData.map((item, index) => {
if (index <= 10) { if (index <= 10) {
this.slideList[0].arr.push({ no: index + 1, name: item.name, count: item.count }); this.slideList[0].arr.push({ no: index + 1, name: item.name, count: item.count });
@ -473,13 +476,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.createChart(); this.createChart();
this.createPieChart(this.pieData); this.createPieChart(this.pieData);
this.render3DMap() // this.render3DMap()
this.run(); this.run();
this.run1(); this.run1();
}); });
}, },
render3DMap() { render3DMap() {
var convertData = (data) => { var convertData = (data) => {
var res = []; var res = [];
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
@ -691,14 +694,14 @@ export default {
fontSize: 15, fontSize: 15,
color: "#fff", color: "#fff",
}, },
top: 12, top: 0,
}, },
legend: { legend: {
data: ["到件量", "派件量"], data: ["到件量", "派件量"],
textStyle: { textStyle: {
color: "#fff", color: "#fff",
}, },
top: 12, top: 0,
right: 10, right: 10,
itemHeight: 8, itemHeight: 8,
}, },
@ -835,7 +838,7 @@ export default {
beta: 0, beta: 0,
}, },
backgroundColor: null, backgroundColor: null,
marginTop: -45, marginTop: -10,
}, },
colors: ["#00bdff", "#52f4c1", "#00dbec"], colors: ["#00bdff", "#52f4c1", "#00dbec"],
title: { title: {
@ -844,20 +847,14 @@ export default {
legend: { legend: {
enabled: false, // enabled: false, //
}, },
tooltip: {
enabled: false,
},
plotOptions: { plotOptions: {
pie: { pie: {
allowPointSelect: true, allowPointSelect: true,
cursor: "pointer", cursor: "pointer",
depth: 35, depth: 15,
// dataLabels: {
// enabled: true,
// formatter: function (params) {
// //this console.log(this)
// return `<span class="my-class" style="color:#e39054;font-size:0.16rem">${this.key}:</span>
// <span style="color:#e39054;font-size:0.14rem;">${((this.y / this.total) * 100).toFixed(2)}%</span><br />
// <span style="font-size:0.14rem;color:#fff;line-height: 0.12rem;font-family: 'FZSK';">${this.y}</span>`
// },
// },
dataLabels: { dataLabels: {
enabled: true, //线tip enabled: true, //线tip
distance: "11%", distance: "11%",
@ -896,73 +893,6 @@ export default {
], ],
}); });
}, },
//3d
getHeight3D(series, height) {
series.sort((a, b) => {
return b.pieData.value - a.pieData.value;
});
return (height * 25) / series[0].pieData.value;
},
getParametricEquation(startRatio, endRatio, isSelected, isHovered, k, h) {
//
let midRatio = (startRatio + endRatio) / 2;
let startRadian = startRatio * Math.PI * 2;
let endRadian = endRatio * Math.PI * 2;
let midRadian = midRatio * Math.PI * 2;
//
if (startRatio === 0 && endRatio === 1) {
isSelected = true;
}
// / k 1/3
k = typeof k !== "undefined" ? k : 1 / 3;
// x y 0
let offsetX = isSelected ? Math.cos(midRadian) * 0.1 : 0;
let offsetY = isSelected ? Math.sin(midRadian) * 0.1 : 0;
// 1
let hoverRate = isHovered ? 1.05 : 1;
//
return {
u: {
min: -Math.PI,
max: Math.PI * 3,
step: Math.PI / 32,
},
v: {
min: 0,
max: Math.PI * 2,
step: Math.PI / 20,
},
x: (u, v) => {
if (u < startRadian) {
return offsetX + Math.cos(startRadian) * (1 + Math.cos(v) * k) * hoverRate;
}
if (u > endRadian) {
return offsetX + Math.cos(endRadian) * (1 + Math.cos(v) * k) * hoverRate;
}
return offsetX + Math.cos(u) * (1 + Math.cos(v) * k) * hoverRate;
},
y: (u, v) => {
if (u < startRadian) {
return offsetY + Math.sin(startRadian) * (1 + Math.cos(v) * k) * hoverRate;
}
if (u > endRadian) {
return offsetY + Math.sin(endRadian) * (1 + Math.cos(v) * k) * hoverRate;
}
return offsetY + Math.sin(u) * (1 + Math.cos(v) * k) * hoverRate;
},
z: (u, v) => {
if (u < -Math.PI * 0.5) {
return Math.sin(u);
}
if (u > Math.PI * 2.5) {
return Math.sin(u) * h * 0.1;
}
return Math.sin(v) > 0 ? 1 * h * 0.1 : -1;
},
};
},
// //
changeData(val) { changeData(val) {
this.active = val; this.active = val;

Loading…
Cancel
Save