Browse Source

Merge branch 'release-sy-v1.0.0' of http://gitlab.datameta.com/project/water/shuili-vue into release-sy-v1.0.0

sy-water-data-board-ui
hejunjie 1 month ago
parent
commit
b61df66735
  1. 83
      src/utils/echartsUtils.js
  2. 52
      src/views/dike/runManage/patrolMaintenance/statisticsAnalysis/index.vue

83
src/utils/echartsUtils.js

@ -167,3 +167,86 @@ export const initCommonPieRingOptions = ({
series: series,
};
};
// 极坐标
export const initCommonAngleAxisOptions = ({
data = {},
colors = ["#36b29e", "#29CCCC", "#0099df", "#81b84a"],
seriesOptions = {},
}) => {
const { title, yaxis } = data;
let radiusAxisData = [];
let seriesData = [];
let maxVal = 0;
if (yaxis && yaxis.length) {
let newSeries = yaxis.flatMap((v) => v.series);
newSeries.forEach((v, i) => {
radiusAxisData.push(v.name);
seriesData.push({
value: Number(v.sum ?? null),
itemStyle: {
color: colors[i],
},
});
});
// 设置这个极坐标的最大值,防止占满
maxVal = Math.max(...newSeries.map((v) => Number(v.sum ?? null))) * 1.25;
}
return {
color: colors,
title: [
{
show: false,
text: title || "",
},
],
polar: {
radius: ["50%", "80%"],
},
angleAxis: {
max: maxVal,
startAngle: 90,
axisLine: {
show: false,
},
axisTick: {
show: false,
},
axisLabel: {
show: false,
},
splitLine: {
show: false,
},
},
radiusAxis: {
show: true,
zlevel: 10,
type: "category",
data: radiusAxisData,
axisLabel: {
interval: 0, // 强制显示所有标签
},
axisTick: {
show: false,
},
axisLine: {
show: false,
},
splitLine: {
show: false,
},
},
tooltip: {},
series: {
type: "bar",
data: seriesData,
coordinateSystem: "polar",
label: {
show: false,
position: "middle",
formatter: "{b}: {c}",
},
...seriesOptions,
},
};
};

52
src/views/dike/runManage/patrolMaintenance/statisticsAnalysis/index.vue

@ -141,6 +141,7 @@ import { getV2PatrolStatisticChart, getRunProjectList } from "@/api/dike";
import {
initCommonBarLineOptions,
initCommonPieRingOptions,
initCommonAngleAxisOptions,
} from "@/utils/echartsUtils";
export default {
@ -579,13 +580,50 @@ export default {
this.yhCompareRefPieInstance = echarts.init(
this.$refs.yhCompareRefPie
);
this.yhCompareRefPieInstance.setOption(
initCommonPieRingOptions({
data: res.data || {},
colors: ["#0099DF", "#81B84A"],
seriesOptions: {},
})
);
let options = initCommonAngleAxisOptions({
data: res.data || {},
colors: [
{
type: "linear",
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
color: "rgba(54, 163, 217, 1)", // 0%
},
{
offset: 1,
color: "rgba(54, 163, 217, 0.1)", // 100%
},
],
global: false, // false
},
{
type: "linear",
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
color: "rgba(129, 184, 74, 1)", // 0%
},
{
offset: 1,
color: "rgba(129, 184, 74, 0.1)", // 100%
},
],
global: false, // false
},
],
seriesOptions: {},
});
console.log("options >>>>> ", options);
this.yhCompareRefPieInstance.setOption(options);
});
}
});

Loading…
Cancel
Save