zyh
This commit is contained in:
parent
803c22c317
commit
a4eafbbdba
|
|
@ -131,7 +131,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="chartBox">
|
<div class="chartBox">
|
||||||
<div class="chart-container">
|
<div class="chart-container">
|
||||||
<div class="chart" ref="chart"></div>
|
<div class="chart" ref="chart" id="fhzb"></div>
|
||||||
<!-- 底座背景 -->
|
<!-- 底座背景 -->
|
||||||
<div class="bg"></div>
|
<div class="bg"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -178,9 +178,9 @@
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import * as echarts from "echarts";
|
import * as echarts from "echarts";
|
||||||
import "echarts-gl";
|
// import "echarts-gl";
|
||||||
import { getPie3D, getParametricEquation } from "../../../utils/fhgl";
|
// import { getPie3D, getParametricEquation } from "../../../utils/fhgl";
|
||||||
const color = ["#099FE3", "#00DBEB", "#50F4C1"];
|
// const color = ["#099FE3", "#00DBEB", "#50F4C1"];
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -1530,248 +1530,249 @@ export default {
|
||||||
|
|
||||||
//
|
//
|
||||||
// 初始化label样式
|
// 初始化label样式
|
||||||
setLabel() {
|
// setLabel() {
|
||||||
this.optionData.forEach((item, index) => {
|
// this.optionData.forEach((item, index) => {
|
||||||
item.itemStyle = {
|
// item.itemStyle = {
|
||||||
color: color[index],
|
// color: color[index],
|
||||||
};
|
// };
|
||||||
item.label = {
|
// item.label = {
|
||||||
normal: {
|
// normal: {
|
||||||
show: true,
|
// show: true,
|
||||||
color: color[index],
|
// color: color[index],
|
||||||
position: "right",
|
// position: "right",
|
||||||
// distance:-10,
|
// // distance:-10,
|
||||||
offset: [0, 3],
|
// offset: [0, 3],
|
||||||
formatter: [
|
// formatter: [
|
||||||
"{d|{d}%}",
|
// "{d|{d}%}",
|
||||||
"————",
|
// "————",
|
||||||
// '{c|{c}}{b|台}',
|
// // '{c|{c}}{b|台}',
|
||||||
"{b|{b}}",
|
// "{b|{b}}",
|
||||||
].join("\n"), // 用\n来换行
|
// ].join("\n"), // 用\n来换行
|
||||||
rich: {
|
// rich: {
|
||||||
b: {
|
// b: {
|
||||||
lineHeight: 25,
|
// lineHeight: 25,
|
||||||
align: "left",
|
// align: "left",
|
||||||
fontSize: 30,
|
// fontSize: 30,
|
||||||
color: "#fff",
|
// color: "#fff",
|
||||||
},
|
// },
|
||||||
c: {
|
// c: {
|
||||||
fontSize: 22,
|
// fontSize: 22,
|
||||||
// color: '#fff',
|
// // color: '#fff',
|
||||||
textShadowColor: "#1c90a6",
|
// textShadowColor: "#1c90a6",
|
||||||
textShadowOffsetX: 0,
|
// textShadowOffsetX: 0,
|
||||||
textShadowOffsetY: 2,
|
// textShadowOffsetY: 2,
|
||||||
textShadowBlur: 5,
|
// textShadowBlur: 5,
|
||||||
color: color[index],
|
// color: color[index],
|
||||||
},
|
// },
|
||||||
d: {
|
// d: {
|
||||||
color: color[index],
|
// color: color[index],
|
||||||
fontSize: 40,
|
// fontSize: 40,
|
||||||
align: "left",
|
// align: "left",
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
};
|
// };
|
||||||
item.labelLine = {
|
// item.labelLine = {
|
||||||
normal: {
|
// normal: {
|
||||||
length2: 200,
|
// length2: 200,
|
||||||
lineStyle: {
|
// lineStyle: {
|
||||||
width: 2,
|
// width: 2,
|
||||||
color: color[index],
|
// color: color[index],
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
};
|
// };
|
||||||
});
|
// });
|
||||||
},
|
// },
|
||||||
// // 图表初始化
|
// // 图表初始化
|
||||||
initChart() {
|
// initChart() {
|
||||||
this.statusChart = echarts.init(this.$refs.chart);
|
// this.statusChart = echarts.init(this.$refs.chart);
|
||||||
// 传入数据生成 option, 构建3d饼状图, 参数工具文件已经备注的很详细
|
// // 传入数据生成 option, 构建3d饼状图, 参数工具文件已经备注的很详细
|
||||||
this.option = getPie3D(this.optionData, 0, 270, 26, 40, 1);
|
// this.option = getPie3D(this.optionData, 0, 270, 26, 40, 1);
|
||||||
this.statusChart.setOption(this.option);
|
// this.statusChart.setOption(this.option);
|
||||||
// 是否需要label指引线,如果要就添加一个透明的2d饼状图并调整角度使得labelLine和3d的饼状图对齐,并再次setOption
|
// // 是否需要label指引线,如果要就添加一个透明的2d饼状图并调整角度使得labelLine和3d的饼状图对齐,并再次setOption
|
||||||
this.option.series.push({
|
// this.option.series.push({
|
||||||
name: "信用评价", //自己根据场景修改
|
// name: "信用评价", //自己根据场景修改
|
||||||
backgroundColor: "transparent",
|
// backgroundColor: "transparent",
|
||||||
type: "pie",
|
// type: "pie",
|
||||||
label: {
|
// label: {
|
||||||
opacity: 1,
|
// opacity: 1,
|
||||||
fontSize: 13,
|
// fontSize: 13,
|
||||||
lineHeight: 20,
|
// lineHeight: 20,
|
||||||
},
|
// },
|
||||||
startAngle: -40, // 起始角度,支持范围[0, 360]。
|
// startAngle: -40, // 起始角度,支持范围[0, 360]。
|
||||||
clockwise: false, // 饼图的扇区是否是顺时针排布。上述这两项配置主要是为了对齐3d的样式
|
// clockwise: false, // 饼图的扇区是否是顺时针排布。上述这两项配置主要是为了对齐3d的样式
|
||||||
radius: ["20%", "60%"],
|
// radius: ["20%", "60%"],
|
||||||
center: ["50%", "50%"],
|
// center: ["50%", "50%"],
|
||||||
data: this.optionData,
|
// data: this.optionData,
|
||||||
itemStyle: {
|
// itemStyle: {
|
||||||
opacity: 0, //这里必须是0,不然2d的图会覆盖在表面
|
// opacity: 0, //这里必须是0,不然2d的图会覆盖在表面
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
this.statusChart.setOption(this.option);
|
// this.statusChart.setOption(this.option);
|
||||||
this.bindListen(this.statusChart);
|
// this.bindListen(this.statusChart);
|
||||||
},
|
// },
|
||||||
// // 监听鼠标事件,实现饼图选中效果(单选),近似实现高亮(放大)效果。
|
// // 监听鼠标事件,实现饼图选中效果(单选),近似实现高亮(放大)效果。
|
||||||
// // optionName是防止有多个图表进行定向option传递,单个图表可以不传,默认是opiton
|
// // optionName是防止有多个图表进行定向option传递,单个图表可以不传,默认是opiton
|
||||||
bindListen(myChart, optionName = "option") {
|
// bindListen(myChart, optionName = "option") {
|
||||||
let selectedIndex = "";
|
// let selectedIndex = "";
|
||||||
let hoveredIndex = "";
|
// let hoveredIndex = "";
|
||||||
// 监听点击事件,实现选中效果(单选)
|
// // 监听点击事件,实现选中效果(单选)
|
||||||
// myChart.on("click", (params) => {
|
// // myChart.on("click", (params) => {
|
||||||
// console.log(this[optionName].series[params.seriesIndex],'this[optionName].series[params.seriesIndex].pieStatus');
|
// // console.log(this[optionName].series[params.seriesIndex],'this[optionName].series[params.seriesIndex].pieStatus');
|
||||||
// // 从 option.series 中读取重新渲染扇形所需的参数,将是否选中取反。
|
// // // 从 option.series 中读取重新渲染扇形所需的参数,将是否选中取反。
|
||||||
// const isSelected =
|
// // const isSelected =
|
||||||
// !this[optionName].series[params.seriesIndex].pieStatus.selected;
|
// // !this[optionName].series[params.seriesIndex].pieStatus.selected;
|
||||||
// const isHovered =
|
// // const isHovered =
|
||||||
// this[optionName].series[params.seriesIndex].pieStatus.hovered;
|
// // this[optionName].series[params.seriesIndex].pieStatus.hovered;
|
||||||
// const k = this[optionName].series[params.seriesIndex].pieStatus.k;
|
// // const k = this[optionName].series[params.seriesIndex].pieStatus.k;
|
||||||
// const startRatio =
|
// // const startRatio =
|
||||||
// this[optionName].series[params.seriesIndex].pieData.startRatio;
|
// // this[optionName].series[params.seriesIndex].pieData.startRatio;
|
||||||
// const endRatio =
|
// // const endRatio =
|
||||||
// this[optionName].series[params.seriesIndex].pieData.endRatio;
|
// // this[optionName].series[params.seriesIndex].pieData.endRatio;
|
||||||
// // 如果之前选中过其他扇形,将其取消选中(对 option 更新)
|
// // // 如果之前选中过其他扇形,将其取消选中(对 option 更新)
|
||||||
// if (selectedIndex !== "" && selectedIndex !== params.seriesIndex) {
|
// // if (selectedIndex !== "" && selectedIndex !== params.seriesIndex) {
|
||||||
// this[optionName].series[selectedIndex].parametricEquation =
|
// // this[optionName].series[selectedIndex].parametricEquation =
|
||||||
// getParametricEquation(
|
// // getParametricEquation(
|
||||||
// this[optionName].series[selectedIndex].pieData.startRatio,
|
// // this[optionName].series[selectedIndex].pieData.startRatio,
|
||||||
// this[optionName].series[selectedIndex].pieData.endRatio,
|
// // this[optionName].series[selectedIndex].pieData.endRatio,
|
||||||
// false,
|
// // false,
|
||||||
// false,
|
// // false,
|
||||||
// k,
|
// // k,
|
||||||
// this[optionName].series[selectedIndex].pieData.value
|
// // this[optionName].series[selectedIndex].pieData.value
|
||||||
// );
|
// // );
|
||||||
// this[optionName].series[selectedIndex].pieStatus.selected = false;
|
// // this[optionName].series[selectedIndex].pieStatus.selected = false;
|
||||||
// }
|
// // }
|
||||||
// // 对当前点击的扇形,执行选中/取消选中操作(对 option 更新)
|
// // // 对当前点击的扇形,执行选中/取消选中操作(对 option 更新)
|
||||||
// this[optionName].series[params.seriesIndex].parametricEquation =
|
// // this[optionName].series[params.seriesIndex].parametricEquation =
|
||||||
// getParametricEquation(
|
// // getParametricEquation(
|
||||||
// startRatio,
|
// // startRatio,
|
||||||
// endRatio,
|
// // endRatio,
|
||||||
// isSelected,
|
// // isSelected,
|
||||||
// isHovered,
|
// // isHovered,
|
||||||
// k,
|
// // k,
|
||||||
// this[optionName].series[params.seriesIndex].pieData.value
|
// // this[optionName].series[params.seriesIndex].pieData.value
|
||||||
// );
|
// // );
|
||||||
// this[optionName].series[params.seriesIndex].pieStatus.selected =
|
// // this[optionName].series[params.seriesIndex].pieStatus.selected =
|
||||||
// isSelected;
|
// // isSelected;
|
||||||
// // 如果本次是选中操作,记录上次选中的扇形对应的系列号 seriesIndex
|
// // // 如果本次是选中操作,记录上次选中的扇形对应的系列号 seriesIndex
|
||||||
// selectedIndex = isSelected ? params.seriesIndex : null;
|
// // selectedIndex = isSelected ? params.seriesIndex : null;
|
||||||
// // 使用更新后的 option,渲染图表
|
// // // 使用更新后的 option,渲染图表
|
||||||
// myChart.setOption(this[optionName]);
|
// // myChart.setOption(this[optionName]);
|
||||||
// });
|
// // });
|
||||||
// 监听 mouseover,近似实现高亮(放大)效果
|
// // 监听 mouseover,近似实现高亮(放大)效果
|
||||||
myChart.on("mouseover", (params) => {
|
// myChart.on("mouseover", (params) => {
|
||||||
// 准备重新渲染扇形所需的参数
|
// // 准备重新渲染扇形所需的参数
|
||||||
let isSelected;
|
// let isSelected;
|
||||||
let isHovered;
|
// let isHovered;
|
||||||
let startRatio;
|
// let startRatio;
|
||||||
let endRatio;
|
// let endRatio;
|
||||||
let k;
|
// let k;
|
||||||
// 如果触发 mouseover 的扇形当前已高亮,则不做操作
|
// // 如果触发 mouseover 的扇形当前已高亮,则不做操作
|
||||||
if (hoveredIndex === params.seriesIndex) {
|
// if (hoveredIndex === params.seriesIndex) {
|
||||||
// 否则进行高亮及必要的取消高亮操作
|
// // 否则进行高亮及必要的取消高亮操作
|
||||||
} else {
|
// } else {
|
||||||
// 如果当前有高亮的扇形,取消其高亮状态(对 option 更新)
|
// // 如果当前有高亮的扇形,取消其高亮状态(对 option 更新)
|
||||||
if (hoveredIndex !== "") {
|
// if (hoveredIndex !== "") {
|
||||||
// 从 option.series 中读取重新渲染扇形所需的参数,将是否高亮设置为 false。
|
// // 从 option.series 中读取重新渲染扇形所需的参数,将是否高亮设置为 false。
|
||||||
isSelected =
|
// isSelected =
|
||||||
this[optionName].series[hoveredIndex].pieStatus.selected;
|
// this[optionName].series[hoveredIndex].pieStatus.selected;
|
||||||
isHovered = false;
|
// isHovered = false;
|
||||||
startRatio =
|
// startRatio =
|
||||||
this[optionName].series[hoveredIndex].pieData.startRatio;
|
// this[optionName].series[hoveredIndex].pieData.startRatio;
|
||||||
endRatio = this[optionName].series[hoveredIndex].pieData.endRatio;
|
// endRatio = this[optionName].series[hoveredIndex].pieData.endRatio;
|
||||||
k = this[optionName].series[hoveredIndex].pieStatus.k;
|
// k = this[optionName].series[hoveredIndex].pieStatus.k;
|
||||||
// 对当前点击的扇形,执行取消高亮操作(对 option 更新)
|
// // 对当前点击的扇形,执行取消高亮操作(对 option 更新)
|
||||||
this[optionName].series[hoveredIndex].parametricEquation =
|
// this[optionName].series[hoveredIndex].parametricEquation =
|
||||||
getParametricEquation(
|
// getParametricEquation(
|
||||||
startRatio,
|
// startRatio,
|
||||||
endRatio,
|
// endRatio,
|
||||||
isSelected,
|
// isSelected,
|
||||||
isHovered,
|
// isHovered,
|
||||||
k,
|
// k,
|
||||||
this[optionName].series[hoveredIndex].pieData.value
|
// this[optionName].series[hoveredIndex].pieData.value
|
||||||
);
|
// );
|
||||||
this[optionName].series[hoveredIndex].pieStatus.hovered = isHovered;
|
// this[optionName].series[hoveredIndex].pieStatus.hovered = isHovered;
|
||||||
// 将此前记录的上次选中的扇形对应的系列号 seriesIndex 清空
|
// // 将此前记录的上次选中的扇形对应的系列号 seriesIndex 清空
|
||||||
hoveredIndex = "";
|
// hoveredIndex = "";
|
||||||
}
|
// }
|
||||||
// 如果触发 mouseover 的扇形不是透明圆环,将其高亮(对 option 更新)
|
// // 如果触发 mouseover 的扇形不是透明圆环,将其高亮(对 option 更新)
|
||||||
if (
|
// if (
|
||||||
params.seriesName !== "mouseoutSeries" &&
|
// params.seriesName !== "mouseoutSeries" &&
|
||||||
params.seriesName !== "信用评价"
|
// params.seriesName !== "信用评价"
|
||||||
) {
|
// ) {
|
||||||
// 从 option.series 中读取重新渲染扇形所需的参数,将是否高亮设置为 true。
|
// // 从 option.series 中读取重新渲染扇形所需的参数,将是否高亮设置为 true。
|
||||||
isSelected =
|
// isSelected =
|
||||||
this[optionName].series[params.seriesIndex].pieStatus.selected;
|
// this[optionName].series[params.seriesIndex].pieStatus.selected;
|
||||||
isHovered = true;
|
// isHovered = true;
|
||||||
startRatio =
|
// startRatio =
|
||||||
this[optionName].series[params.seriesIndex].pieData.startRatio;
|
// this[optionName].series[params.seriesIndex].pieData.startRatio;
|
||||||
endRatio =
|
// endRatio =
|
||||||
this[optionName].series[params.seriesIndex].pieData.endRatio;
|
// this[optionName].series[params.seriesIndex].pieData.endRatio;
|
||||||
k = this[optionName].series[params.seriesIndex].pieStatus.k;
|
// k = this[optionName].series[params.seriesIndex].pieStatus.k;
|
||||||
// 对当前点击的扇形,执行高亮操作(对 option 更新)
|
// // 对当前点击的扇形,执行高亮操作(对 option 更新)
|
||||||
this[optionName].series[params.seriesIndex].parametricEquation =
|
// this[optionName].series[params.seriesIndex].parametricEquation =
|
||||||
getParametricEquation(
|
// getParametricEquation(
|
||||||
startRatio,
|
// startRatio,
|
||||||
endRatio,
|
// endRatio,
|
||||||
isSelected,
|
// isSelected,
|
||||||
isHovered,
|
// isHovered,
|
||||||
k,
|
// k,
|
||||||
this[optionName].series[params.seriesIndex].pieData.value + 60
|
// this[optionName].series[params.seriesIndex].pieData.value + 60
|
||||||
);
|
// );
|
||||||
this[optionName].series[params.seriesIndex].pieStatus.hovered =
|
// this[optionName].series[params.seriesIndex].pieStatus.hovered =
|
||||||
isHovered;
|
// isHovered;
|
||||||
// 记录上次高亮的扇形对应的系列号 seriesIndex
|
// // 记录上次高亮的扇形对应的系列号 seriesIndex
|
||||||
hoveredIndex = params.seriesIndex;
|
// hoveredIndex = params.seriesIndex;
|
||||||
}
|
// }
|
||||||
// 使用更新后的 option,渲染图表
|
// // 使用更新后的 option,渲染图表
|
||||||
myChart.setOption(this[optionName]);
|
// myChart.setOption(this[optionName]);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
// 修正取消高亮失败的 bug
|
// // 修正取消高亮失败的 bug
|
||||||
myChart.on("globalout", () => {
|
// myChart.on("globalout", () => {
|
||||||
// 准备重新渲染扇形所需的参数
|
// // 准备重新渲染扇形所需的参数
|
||||||
let isSelected;
|
// let isSelected;
|
||||||
let isHovered;
|
// let isHovered;
|
||||||
let startRatio;
|
// let startRatio;
|
||||||
let endRatio;
|
// let endRatio;
|
||||||
let k;
|
// let k;
|
||||||
if (hoveredIndex !== "") {
|
// if (hoveredIndex !== "") {
|
||||||
// 从 option.series 中读取重新渲染扇形所需的参数,将是否高亮设置为 true。
|
// // 从 option.series 中读取重新渲染扇形所需的参数,将是否高亮设置为 true。
|
||||||
isSelected = this[optionName].series[hoveredIndex].pieStatus.selected;
|
// isSelected = this[optionName].series[hoveredIndex].pieStatus.selected;
|
||||||
isHovered = false;
|
// isHovered = false;
|
||||||
k = this[optionName].series[hoveredIndex].pieStatus.k;
|
// k = this[optionName].series[hoveredIndex].pieStatus.k;
|
||||||
startRatio = this[optionName].series[hoveredIndex].pieData.startRatio;
|
// startRatio = this[optionName].series[hoveredIndex].pieData.startRatio;
|
||||||
endRatio = this[optionName].series[hoveredIndex].pieData.endRatio;
|
// endRatio = this[optionName].series[hoveredIndex].pieData.endRatio;
|
||||||
// 对当前点击的扇形,执行取消高亮操作(对 option 更新)
|
// // 对当前点击的扇形,执行取消高亮操作(对 option 更新)
|
||||||
this[optionName].series[hoveredIndex].parametricEquation =
|
// this[optionName].series[hoveredIndex].parametricEquation =
|
||||||
getParametricEquation(
|
// getParametricEquation(
|
||||||
startRatio,
|
// startRatio,
|
||||||
endRatio,
|
// endRatio,
|
||||||
isSelected,
|
// isSelected,
|
||||||
isHovered,
|
// isHovered,
|
||||||
k,
|
// k,
|
||||||
this[optionName].series[hoveredIndex].pieData.value
|
// this[optionName].series[hoveredIndex].pieData.value
|
||||||
);
|
// );
|
||||||
this[optionName].series[hoveredIndex].pieStatus.hovered = isHovered;
|
// this[optionName].series[hoveredIndex].pieStatus.hovered = isHovered;
|
||||||
// 将此前记录的上次选中的扇形对应的系列号 seriesIndex 清空
|
// // 将此前记录的上次选中的扇形对应的系列号 seriesIndex 清空
|
||||||
hoveredIndex = "";
|
// hoveredIndex = "";
|
||||||
}
|
// }
|
||||||
// 使用更新后的 option,渲染图表
|
// // 使用更新后的 option,渲染图表
|
||||||
myChart.setOption(this[optionName]);
|
// myChart.setOption(this[optionName]);
|
||||||
});
|
// });
|
||||||
},
|
// },
|
||||||
},
|
},
|
||||||
created(){
|
created(){
|
||||||
this.setLabel();
|
// this.setLabel();
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.defineEcharts("pdsssdh", this.option1);
|
this.defineEcharts("pdsssdh", this.option1);
|
||||||
// this.defineEcharts("pdsydl", this.option2);
|
// this.defineEcharts("pdsydl", this.option2);
|
||||||
this.pdsydl();
|
this.pdsydl();
|
||||||
// this.getEchart();
|
this.getEchart();
|
||||||
this.defineEcharts("pdstpt", this.option3);
|
this.defineEcharts("pdstpt", this.option3);
|
||||||
this.initChart();
|
// this.initChart();
|
||||||
|
this.getbing();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue