| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- <template>
- <div class="chart" :id="id"></div>
- </template>
- <script>
- import util from "@/helper/util.js";
- import partten from "@/helper/partten.js";
- import * as echarts from "echarts";
- export default {
- name: "double-line-chart",
- componentName: "double-line-chart",
- props: {
- width: {
- type: String,
- default: "100%",
- },
- height: {
- type: String,
- default: "13.889vh",
- },
- // 传入数据
- lossPower: {
- type: Object,
- default: () => {},
- },
- // 单位
- unit: {
- type: String,
- default: "",
- },
- //倍率
- ratio: {
- type: Number,
- default: 1,
- },
- showLegend: {
- type: Boolean,
- default: false,
- },
- // 颜色
- color: {
- type: Array,
- default: () => [
- "#005bd9",
- "#019f2e",
- "#db6200",
- "#a10f0f",
- "#850894",
- "#9fa0a2",
- ],
- },
- },
- data() {
- return {
- id: "",
- chart: null,
- newlist: null,
- };
- },
- watch: {
- list: {
- handler(newValue, oldValue) {
- this.newlist = newValue;
- this.$nextTick(() => {
- this.newlist = this.list;
- this.initChart();
- });
- },
- deep: true,
- },
- "$store.state.themeName"() {
- this.initChart();
- },
- },
- methods: {
- resize() {},
- initChart() {
- const chart = echarts.init(this.$el);
- let that = this;
- let option = {
- color: this.color,
- legend: {
- type: "scroll",
- top: 20,
- itemWidth: 8,
- itemHeight: 8,
- textStyle: {
- color: "#fff",
- fontSize: 12,
- },
- // formatter(params) {
- // switch (params) {
- // case "实发电量":
- // return (
- // params +
- // " " +
- // (that.lossPower?.SFDL
- // ? that.lossPower?.SFDL?.toFixed(2)
- // : "0")
- // );
- // case "故障损失":
- // return (
- // params +
- // " " +
- // (that.lossPower?.GZSS
- // ? that.lossPower?.GZSS?.toFixed(2)
- // : "0")
- // );
- // case "检修损失":
- // return (
- // params +
- // " " +
- // (that.lossPower?.WHSS
- // ? that.lossPower?.WHSS?.toFixed(2)
- // : "0")
- // );
- // case "受累损失":
- // return (
- // params +
- // " " +
- // (that.lossPower?.SLSS
- // ? that.lossPower?.SLSS?.toFixed(2)
- // : "0")
- // );
- // case "限电损失":
- // return (
- // params +
- // " " +
- // (that.lossPower?.XDSS
- // ? that.lossPower?.XDSS?.toFixed(2)
- // : "0")
- // );
- // case "性能损失":
- // return (
- // params +
- // " " +
- // (that.lossPower?.XNSS
- // ? that.lossPower?.XNSS?.toFixed(2)
- // : "0")
- // );
- // }
- // },
- },
- tooltip: {
- trigger: "item",
- formatter(params) {
- return `${params?.marker} ${
- params?.name
- } ${params?.data?.realVal?.toFixed(2)}`;
- },
- },
- radar: [
- {
- indicator: [{ text: "" }],
- center: ["50%", "60%"],
- radius: [0, 79],
- startAngle: 60,
- splitNumber: 5,
- shape: "circle",
- name: {
- formatter: "",
- textStyle: {
- color: "#0000FF",
- },
- },
- splitArea: {
- areaStyle: {
- color: "rgba(0, 0, 0, 0)",
- },
- },
- axisLine: {
- lineStyle: {
- color: "rgba(0, 0, 0, 0)",
- },
- },
- splitLine: {
- lineStyle: {
- color: "#0a389c",
- shadowColor: "#0a389c",
- shadowBlur: 10,
- },
- },
- },
- ],
- series: [
- {
- name: "",
- type: "pie",
- radius: [0, 80],
- center: ["50%", "60%"],
- roseType: "area",
- label: {
- normal: {
- color: "#fff",
- formatter: "{d}%",
- },
- },
- data: [
- {
- value: this.lossPower.SFDL
- ? this.lossPower?.SFDL / this.lossPower?.SUM
- : 0,
- name: "实发电量",
- realVal: this.lossPower?.SFDL,
- },
- {
- value: this.lossPower.XNSS
- ? this.lossPower?.XNSS / this.lossPower?.SUM
- : 0,
- name: "性能损失",
- realVal: this.lossPower?.XNSS,
- },
- {
- value: this.lossPower.WHSS
- ? this.lossPower?.WHSS / this.lossPower?.SUM
- : 0,
- name: "检修损失",
- realVal: this.lossPower?.WHSS,
- },
- {
- value: this.lossPower.GZSS
- ? this.lossPower?.GZSS / this.lossPower?.SUM
- : 0,
- name: "故障损失",
- realVal: this.lossPower?.GZSS,
- },
- {
- value: this.lossPower.XDSS
- ? this.lossPower?.XDSS / this.lossPower?.SUM
- : 0,
- name: "限电损失",
- realVal: this.lossPower?.XDSS,
- },
- {
- value: this.lossPower.SLSS
- ? this.lossPower?.SLSS / this.lossPower?.SUM
- : 0,
- name: "受累损失",
- realVal: this.lossPower?.SLSS,
- },
- ],
- },
- ],
- };
- chart.clear();
- chart.setOption(option);
- this.resize = function () {
- chart.resize();
- };
- window.addEventListener("resize", this.resize);
- },
- },
- created() {
- this.$nextTick(() => {
- this.id = "pie-chart-" + util.newGUID();
- });
- this.newlist = this.list;
- },
- mounted() {
- this.$nextTick(() => {
- this.$el.style.width = this.width;
- this.$el.style.height = this.height;
- this.initChart();
- });
- },
- updated() {
- this.$nextTick(() => {
- this.initChart();
- });
- },
- unmounted() {
- window.removeEventListener("resize", this.resize);
- },
- };
- </script>
- <style lang="less">
- .chart {
- width: 100%;
- height: 100%;
- display: inline-block;
- }
- </style>
|