123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <template>
- <div class="myChart" ref="myChart" :style="{height: height+'px'}">
- </div>
- </template>
- <script>
- import apiOperationAnalysis from "@/api/operation/apiOperationAnalysis";
- export default {
- data() {
- return {
- option: {
- color: ['#80D4FF','#A6A6FF','#79F2E8','#FFDF80','#FF7C1F'],
- legend: {
- data: [
- '发电量',
- '能耗比',
- ]
- },
- grid: {
- left: '2%', //默认10%
- right: '2%', //默认10%
- bottom: '15%', //默认60
- top: '15%',
- containLabel: true
- //grid区域是否包含坐标轴的刻度标签
- },
- xAxis: {
- type: 'category',
- data: []
- },
- yAxis: [
- {
- name: 'kwh',
- type: 'value',
- nameTextStyle: {
- padding: [10, 0, 10, -20]
- },
- },
- {
- name: '能耗比(%)',
- type: 'value',
- nameTextStyle: {
- padding: [10, 0, 10, -30]
- },
- },
- ],
- 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: '发电量',
- data: [],
- type: 'bar',
- barWidth: '30%',
- itemStyle: {
- color: '#3AA7E6'
- },
- backgroundStyle: {
- color: 'rgba(180, 180, 180, 0.2)'
- }
- },
- {
- name: '能耗比',
- data: [],
- type: 'line',
- smooth:true,
- showSymbol:false,
- yAxisIndex: 1,
- backgroundStyle: {
- color: 'rgba(180, 180, 180, 0.2)'
- }
- },
- ]
- },
- }
- },
- props: {
- height: Number,
- queryData: Object
- },
- mounted() {
- 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.getEnergyTrendsAnalyseCpv(this.queryData).then(res=>{
- let data = this.$util.dataUtil.covertDataToEcharts(res, ['outputPower','powerGeneration'])
- this.$util.dataUtil.refreshEchartsData(this.chart, this.option, data)
- })
- }
- }
- }
- </script>
- <style lang="less" scoped>
- </style>
|