| | |
| | | }; |
| | | }, |
| | | }, |
| | | // xdata: { |
| | | // type: Array, |
| | | // require: true, |
| | | // }, |
| | | // ydata: { |
| | | // type: Array, |
| | | // require: true, |
| | | // }, |
| | | }, |
| | | data() { |
| | | return { |
| | | // chartData: { |
| | | // datax: [], |
| | | // datay: [], |
| | | // }, |
| | | startValue: 0, |
| | | endValue: 5, |
| | | chartTimer: null, |
| | | }; |
| | | }, |
| | | watch: { |
| | | "chartData.datay"(val) { |
| | | console.log(val, "设备变更数据"); |
| | | this.ydata = val; |
| | | this.startValue = 0; |
| | | this.endValue = 5; |
| | | this.pieChart("chart", this.chartData); |
| | | }, |
| | | }, |
| | | mounted() { |
| | | // this.pieChart("chart", this.chartData); |
| | | }, |
| | | mounted() {}, |
| | | methods: { |
| | | //在职 |
| | | pieChart(chartName, data) { |
| | | let that = this; |
| | | let chartDomTwo = this.$refs[chartName]; |
| | | let myChartTwo = echarts.init(chartDomTwo) |
| | | myChartTwo.dispose() |
| | | clearInterval(this.chartTimer); |
| | | let chartDom = this.$refs[chartName]; |
| | | if (myChart != null && myChart != "" && myChart != undefined) { |
| | | myChart.dispose(); //销毁 |
| | | } |
| | | myChart = echarts.init(chartDom); |
| | | // if (myChart != null && myChart != "" && myChart != undefined) { |
| | | // console.log("222222222"); |
| | | // myChart.dispose(); //销毁 |
| | | // myChart.resize(); |
| | | // } |
| | | // console.log(myChart, "ssssssss"); |
| | | let option; |
| | | let lineColor = "#35ddc74d"; |
| | | if (this.ydata) { |
| | | let spirit = "/cockpitPage/order-bg.png"; |
| | | if (data) { |
| | | option = { |
| | | color: ["#00FFFF", "#dcb018"], |
| | | color: ["#00FFFF", "#fccd1d"], |
| | | tooltip: { |
| | | trigger: "axis", |
| | | axisPointer: { |
| | | type: "none", |
| | | }, |
| | | textStyle: { |
| | | color: "#00FFFF", |
| | | }, |
| | | borderColor: "#00FFFF", |
| | | backgroundColor: "#238d8d6b", |
| | | valueFormatter: function (value) { |
| | | return value + "%"; |
| | | }, |
| | | }, |
| | | grid: { |
| | | right: "80px", |
| | | bottom: "60px", |
| | | left: "60px", |
| | | left: "70px", |
| | | top: "30px", |
| | | }, |
| | | dataZoom: [ |
| | |
| | | show: false, |
| | | startValue: that.startValue, // 从头开始 |
| | | endValue: that.endValue, // 一次性展示几个 |
| | | zoomOnMouseWheel: false, |
| | | moveOnMouseWheel: true, |
| | | moveOnMouseMove: true, |
| | | }, |
| | | ], |
| | | legend: { |
| | |
| | | // rotate:45, |
| | | margin: 10, |
| | | show: true, |
| | | fontSize: 12, |
| | | textStyle: { |
| | | color: function (params, index) { |
| | | let colorList = ["#dcb018", "#00FFFF"]; |
| | | let colorList = ["#fccd1d", "#00FFFF"]; |
| | | if (index % 2 == 0) { |
| | | return colorList[0]; |
| | | } else { |
| | | return colorList[1]; |
| | | } |
| | | }, |
| | | }, |
| | | formatter: function (value) { |
| | | if (value.length > 5) { |
| | | return `${value.slice(0, 4)}...`; |
| | | } |
| | | return value; |
| | | }, |
| | | }, |
| | | data: data.datax ? data.datax : [], |
| | |
| | | axisTick: { |
| | | show: false, |
| | | }, |
| | | |
| | | axisLabel: { |
| | | textStyle: { |
| | | color: "#00FFFF", |
| | | }, |
| | | formatter: "{value}%", |
| | | formatter: function (value) { |
| | | return `${value}%`; |
| | | }, |
| | | }, |
| | | }, |
| | | ], |
| | | series: [ |
| | | { |
| | | type: "bar", |
| | | type: "pictorialBar", |
| | | name: "", |
| | | barWidth: "15", |
| | | symbol: spirit, |
| | | symbolRepeat: true, |
| | | symbolMargin: "25%", |
| | | symbolClip: true, |
| | | symbolSize: [4, 11], |
| | | barCategoryGap: "40%", |
| | | label: { |
| | | show: true, |
| | | position: "right", |
| | | color: "#00FFFF", |
| | | formatter: function (params) { |
| | | if (params.dataIndex % 2 == 0) { |
| | | return `{a|${params.value}%}`; |
| | | } else { |
| | | return `{b|${params.value}%}`; |
| | | } |
| | | }, |
| | | rich: { |
| | | a: { |
| | | color: "#00FFFF", |
| | | }, |
| | | b: { |
| | | color: "#fccd1d", |
| | | }, |
| | | }, |
| | | }, |
| | | itemStyle: { |
| | | normal: { |
| | | //柱形图圆角,初始化效果 |
| | | barBorderRadius: [4, 4, 0, 0], |
| | | color: function (params) { |
| | | let colorList = ["#dcb018", "#00FFFF"]; |
| | | let colorList = ["#fccd1d", "#00FFFF"]; |
| | | if (params.dataIndex % 2 == 0) { |
| | | return colorList[0]; |
| | | } else { |
| | |
| | | ], |
| | | }; |
| | | |
| | | setInterval(function () { |
| | | this.chartTimer = setInterval(function () { |
| | | if (option.dataZoom[0].endValue == data.datay.length) { |
| | | option.dataZoom[0].startValue = that.startValue; |
| | | option.dataZoom[0].endValue = that.endValue; |