123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <script>
- import apiOperationAnalysis from "@/api/operation/apiOperationAnalysis";
- export default {
- data() {
- return {
- chart: null,
- option: {
- legend: {
- data: [
- '用电(kWh)',
- '用水(m³)',
- '用热(kWh)',
- '用冷(kWh)',
- '光伏(kWh)',
- ],
- selected: {
- '用电(kWh)': true,
- '用水(m³)': true,
- '用热(kWh)': false,
- '用冷(kWh)': false,
- '光伏(kWh)': true,
- }
- },
- grid: {
- left: "1%", //默认10%
- right: "1%", //默认10%
- bottom: "20px", //默认60
- top: "60px",
- containLabel: true,
- //grid区域是否包含坐标轴的刻度标签
- },
- xAxis: {
- data: [],
- },
- yAxis: [
- {
- type: "value",
- nameTextStyle: {
- padding: [10, 0, 10, -30],
- },
- },
- ],
- dataZoom: this.$constant.ECHARTS_OPTION_DATAZOOM,
- tooltip: {
- trigger: "axis",
- axisPointer: {
- type: "shadow",
- },
- textStyle: {
- color: "#fff",
- align: "left",
- fontSize: 14,
- },
- axisLine: {
- //x坐标轴轴线
- show: true,
- lineStyle: {
- //x坐标轴轴线样式
- color: "#000", //'#ccc' | 'rgb(128, 128, 128)' | 'rgba(128, 128, 128, 0.5)',设置标签颜色
- },
- },
- backgroundColor: "rgba(0,0,0,0.8)",
- },
- series: [
- {
- name: "用电(kWh)",
- data: [],
- type: "line",
- stack: "a",
- yAxisIndex: 0,
- smooth: true,
- showSymbol: false,
- lineStyle: {
- color: "#62CC97",
- width: 1,
- },
- itemStyle: {
- color: "#62CC97",
- },
- emphasis: {
- scale: 1.5,
- },
- },
- {
- name: "用水(m³)",
- data: [],
- type: "line",
- stack: "a",
- yAxisIndex: 0,
- smooth: true,
- showSymbol: false,
- itemStyle: {
- color: "#3AA7E6",
- },
- lineStyle: {
- color: "#3AA7E6",
- width: 1,
- },
- emphasis: {
- scale: 1.5,
- },
- },
- {
- name: "用热(kWh)",
- data: [],
- type: "line",
- stack: "a",
- yAxisIndex: 0,
- smooth: true,
- showSymbol: false,
- itemStyle: {
- color: "#4ACFB8",
- },
- lineStyle: {
- color: "#4ACFB8",
- width: 1,
- },
- emphasis: {
- scale: 1.5,
- },
- },
- {
- name: "用冷(kWh)",
- data: [],
- type: "line",
- stack: "a",
- yAxisIndex: 0,
- smooth: true,
- showSymbol: false,
- itemStyle: {
- color: "#F4955F",
- },
- lineStyle: {
- color: "#F4955F",
- width: 1,
- },
- emphasis: {
- scale: 1.5,
- },
- },
- {
- name: "光伏(kWh)",
- data: [],
- type: "line",
- stack: "a",
- yAxisIndex: 0,
- smooth: true,
- showSymbol: false,
- itemStyle: {
- color: "#F8797E",
- },
- lineStyle: {
- color: "#F8797E",
- width: 1,
- },
- emphasis: {
- scale: 1.5,
- },
- },
- ],
- },
- };
- },
- props: {
- height: Number,
- queryData: Object,
- },
- mounted() {
- this.$nextTick(() => {
- this.init();
- });
- },
- methods: {
- init() {
- let chart = this.$echarts.init(this.$refs.myChart);
- this.chart = chart;
- this.$util.chartsResize(this.chart);
- chart.setOption(this.option);
- this.getData();
- },
- getData() {
- return apiOperationAnalysis
- .getEnergyTrendsTotal(this.queryData)
- .then((res) => {
- let data = this.$util.dataUtil.covertDataToEcharts(res, [
- "power",
- "water",
- "hot",
- "cold",
- "cpv",
- ]);
- this.$util.dataUtil.refreshEchartsData(this.chart, this.option, data);
- });
- },
- },
- };
- </script>
- <template>
- <div
- style="width: 100%"
- :style="{ height: height + 'px' }"
- ref="myChart"
- ></div>
- </template>
- <style lang="less" scoped></style>
|