| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <script>
- export default {
- data() {
- return {
- }
- },
- props: {
- height: Number,
- },
- mounted() {
- this.$nextTick(()=>{
- this.initChart()
- })
- },
- methods: {
- initChart() {
- let chart = this.$echarts.init(this.$refs.myChart)
- let defaultOption = {
- legend: {
- data: [
- '用冷量',
- '温度',
- ]
- },
- grid: {
- left: '0%', //默认10%
- right: '0%', //默认10%
- bottom: '15%', //默认60
- top: '15%',
- containLabel: true
- //grid区域是否包含坐标轴的刻度标签
- },
- xAxis: {
- data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
- },
- yAxis: [
- {
- name: '冷量(kWh)',
- type: 'value',
- nameTextStyle: {
- padding: [10, 0, 10, 0]
- },
- },
- {
- name: '温度(℃)',
- type: 'value',
- nameTextStyle: {
- padding: [10, 0, 10, -12]
- },
- },
- ],
- dataZoom: [
- {
- start: 0,
- end: 100,
- height: 16,
- }
- ],
- 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: [35, 71, 51, 32, 28, 66, 42, 42, 87, 34, 88, 45],
- type: 'line',
- stack: 'a',
- yAxisIndex:0,
- smooth: true,
- lineStyle: {
- color: "#62CC97",
- width: 1,
- },
- itemStyle: {
- color: '#62CC97'
- },
- emphasis: {
- scale:1.5
- }
- },
- {
- name: '温度',
- data: [23, 23, 17, 19, 20, 24, 23, 22, 22, 18, 25, 16],
- type: 'line',
- stack: 'b',
- smooth: true,
- yAxisIndex:1,
- lineStyle: {
- color: "#FDB456",
- width: 1,
- },
- itemStyle: {
- color: '#FDB456'
- },
- emphasis: {
- scale:1.5
- },
- },
- ]
- };
- //Object.assign(defaultOption, this.option)
- chart.setOption(defaultOption)
- }
- }
- }
- </script>
- <template>
- <div style="width: 100%" :style="{height: height+'px'}" ref="myChart"></div>
- </template>
- <style lang="less" scoped>
- </style>
|