Commit 358b490b authored by kaitly205422@163.com's avatar kaitly205422@163.com

大屏事故类型排序

parent 82a447f4
...@@ -32,7 +32,7 @@ export default { ...@@ -32,7 +32,7 @@ export default {
this.mapTableContainerHeight = mapTableContainer.offsetHeight - 50; this.mapTableContainerHeight = mapTableContainer.offsetHeight - 50;
} }
let mapTableList = this.$refs.mapTableList; let mapTableList = this.$refs.mapTableList;
this.mapTableListHeight = mapTableList.offsetHeight; this.mapTableListHeight = mapTableList?.offsetHeight;
}, },
// 比较map-table-list高度 // 比较map-table-list高度
compareH() { compareH() {
......
...@@ -505,7 +505,7 @@ export default { ...@@ -505,7 +505,7 @@ export default {
const num = res.data.find(val => val.levelName == x.name) const num = res.data.find(val => val.levelName == x.name)
return { return {
...x, ...x,
y: num?.levelNum - '', y: num?.levelNum - '' || 0,
} }
}) })
setTimeout(() => { setTimeout(() => {
...@@ -539,14 +539,29 @@ export default { ...@@ -539,14 +539,29 @@ export default {
accidentType() { accidentType() {
rightAccidentType({ areaName: this.areaName, type: '', level: this.level - 1 }).then(res => { rightAccidentType({ areaName: this.areaName, type: '', level: this.level - 1 }).then(res => {
d3.select("#circleEchart svg").remove() d3.select("#circleEchart svg").remove();
if (!res.data.length) return; if (!res.data.length) return;
const data = res.data, count = res.data.length - 1, centerCount = Math.ceil(count / 2), start = centerCount - 1, end = centerCount + 1;
let mapData = res.data.slice(start, end); //取中间值作为圆心
let countI = 0;
while (countI < count / 2) { //将数据按照大小交替排序
const inverCountI = end + countI;
inverCountI <= count && mapData.push(data[inverCountI]);
countI < start && mapData.push(data[countI]);
countI++;
}
//
if (mapData.length >= 6) {
mapData.length == 6 && mapData.push({ typeName: '' });
[mapData[5], mapData[6]] = [mapData[6], mapData[5]];
}
const maxNum = res.data[0].typeNum; const maxNum = res.data[0].typeNum;
const max = 30, min = 12; const max = 40, min = 15;
// 使用D3.js库中的circlePack布局 // 使用D3.js库中的circlePack布局
const ele = document.querySelector('#accident') const ele = document.querySelector('#accident')
const containerWidth = ele.offsetWidth, containerHeight = ele.offsetHeight; const containerWidth = ele.offsetWidth, containerHeight = ele.offsetHeight;
const circles = res.data.map((x, index) => { const circles = mapData.map((x, index) => {
return { return {
radius: Math.max(max * x.typeNum / maxNum, min), radius: Math.max(max * x.typeNum / maxNum, min),
name: x.typeName, name: x.typeName,
...@@ -560,25 +575,12 @@ export default { ...@@ -560,25 +575,12 @@ export default {
.padding(10); // 可选项,设置圆之间的间距 .padding(10); // 可选项,设置圆之间的间距
let i = 0 let i = 0
const root = d3.hierarchy({ children: circles }) const root = d3.hierarchy({ children: circles })
.sum(d => d.radius * 2) .sum(d => d.radius * 2);
.sort((a, b) => { //圆从中间开始排序,所有要把中间的球放在最开始
i++
if (i < (res.data.length / 2)) {
return a.data.radius - b.data.radius
}
return b.data.radius - a.data.radius
});
/** /**
* 重排圆 * 重排圆
* 1.获取大圆&&小圆中有y比它小的 * 1.获取大圆&&小圆中有y比它小的
*/ */
pack(root); pack(root);
// root.children.forEach((val, index) => {
// if (index > 1 && index < (res.data.length / 2) && index % 2 == 0) {
// [root.children[index], root.children[res.data.length - 1 - index]] = [root.children[res.data.length - 1 - index], root.children[index]]
// }
// })
// 将root.children按照从小到大排序 // 将root.children按照从小到大排序
// const rootChildren = root.children; // const rootChildren = root.children;
...@@ -600,7 +602,6 @@ export default { ...@@ -600,7 +602,6 @@ export default {
// } // }
// } // }
console.log(root.children.map(x => x.data.name))
pack(root); pack(root);
// 渲染结果 // 渲染结果
const svg = d3.select("#circleEchart") const svg = d3.select("#circleEchart")
...@@ -784,6 +785,7 @@ export default { ...@@ -784,6 +785,7 @@ export default {
scatters.push(...val.projectList.map(x => { scatters.push(...val.projectList.map(x => {
return { return {
value: [x.lng - '', x.lat - '', 0], value: [x.lng - '', x.lat - '', 0],
// symbol: "image://" + require('@/assets/login/user.png'),
itemStyle: { itemStyle: {
color: x.riskColor, color: x.riskColor,
}, },
...@@ -811,6 +813,8 @@ export default { ...@@ -811,6 +813,8 @@ export default {
} }
}) })
} }
// 自定义scatter3D系列的symbol
this.myMap.setOption( this.myMap.setOption(
{ {
geo3D: { geo3D: {
...@@ -870,7 +874,8 @@ export default { ...@@ -870,7 +874,8 @@ export default {
{ {
type: "scatter3D", type: "scatter3D",
symbol: 'circle', symbol: 'circle',
symbolSize: 6, // symbol: 'image://' + require('@/assets/map/circle.jpg'),
symbolSize: 8,
coordinateSystem: "geo3D", coordinateSystem: "geo3D",
data: scatters, data: scatters,
zlevel: 1, zlevel: 1,
......
...@@ -37,10 +37,10 @@ module.exports = { ...@@ -37,10 +37,10 @@ module.exports = {
// detail: https://cli.vuejs.org/config/#devserver-proxy // detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: { [process.env.VUE_APP_BASE_API]: {
// target: "http://192.168.10.137:8080/", // target: "http://192.168.10.137:8080/",
// target: `http://192.168.4.232:8080`, //服务器地址 target: `http://192.168.4.232:8080`, //服务器地址
// target: `http://192.168.15.230:8081`, //晓晋本地地址 // target: `http://192.168.15.230:8081`, //晓晋本地地址
// target: `http://192.168.15.152:8081`, //鲍德本地地址 // target: `http://192.168.15.152:8081`, //鲍德本地地址
target: `http://127.0.0.1:8080`, //本地地址 // target: `http://127.0.0.1:8080`, //本地地址
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
["^" + process.env.VUE_APP_BASE_API]: "", ["^" + process.env.VUE_APP_BASE_API]: "",
...@@ -48,10 +48,10 @@ module.exports = { ...@@ -48,10 +48,10 @@ module.exports = {
}, },
"/app-api": { "/app-api": {
// target: "http://192.168.10.137:8080/", // target: "http://192.168.10.137:8080/",
// target: `http://192.168.4.232:8080/`, //服务器地址 target: `http://192.168.4.232:8080/`, //服务器地址
// target: `http://192.168.15.230:8081`, //晓晋本地地址 // target: `http://192.168.15.230:8081`, //晓晋本地地址
// target: `http://192.168.15.152:8081`, //鲍德本地地址 // target: `http://192.168.15.152:8081`, //鲍德本地地址
target: `http://127.0.0.1:8080`, //本地地址 // target: `http://127.0.0.1:8080`, //本地地址
changeOrigin: true, changeOrigin: true,
}, },
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment