| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div> |
| | | <div id='singleDataChart' style='height:200px'></div> |
| | | </div> |
| | | </template> |
| | | <script> |
| | | import echarts from 'echarts' |
| | | export default { |
| | | data () { |
| | | return { |
| | | xAxisList: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00'], |
| | | powerList: [620, 952, 981, 634, 190, 1830, 620, 952, 981, 634, 190, 190, 1830], |
| | | lightList: [820, 932, 901, 934, 1290, 1330, 1320, 820, 932, 901, 934, 1290, 1330] |
| | | } |
| | | }, |
| | | activated () { |
| | | this.init() |
| | | this.drawChart() |
| | | }, |
| | | methods: { |
| | | init () { |
| | | var h = window.innerHeight || document.body.clientHeight |
| | | var body = document.getElementById('singleDataChart') |
| | | var num = (h / 3) - 100 |
| | | body.style.height = num + 'px' |
| | | }, |
| | | drawChart () { |
| | | var option = { |
| | | legend: { |
| | | orient: 'horizontal', |
| | | position: 'center', |
| | | top: 10, |
| | | data: ['çµæºäº®åº¦', 'çµæºæååç'], |
| | | textStyle: { |
| | | color: 'white' |
| | | } |
| | | }, |
| | | xAxis: { |
| | | axisLine: { |
| | | lineStyle: { |
| | | color: 'white' |
| | | } |
| | | }, |
| | | type: 'category', |
| | | boundaryGap: false, |
| | | data: this.xAxisList |
| | | }, |
| | | tooltip: { |
| | | trigger: 'axis', |
| | | position: function (pt) { |
| | | return [pt[0], '10%'] |
| | | } |
| | | }, |
| | | yAxis: { |
| | | axisLine: { |
| | | lineStyle: { |
| | | color: 'white' |
| | | } |
| | | }, |
| | | type: 'value', |
| | | axisLabel: { |
| | | formatter: function (param) { |
| | | return param / 10 |
| | | } |
| | | }, |
| | | splitLine: { |
| | | show: false |
| | | } |
| | | }, |
| | | series: [ |
| | | { |
| | | name: 'çµæºæååç', |
| | | data: this.powerList, |
| | | type: 'line', |
| | | symbol: 'circle', // æçº¿ç¹è®¾ç½®ä¸ºå®å¿ç¹ |
| | | symbolSize: 10, // 设å®å®å¿ç¹çå¤§å° |
| | | lineStyle: { |
| | | width: 5 |
| | | }, |
| | | itemStyle: { |
| | | normal: { |
| | | color: '#68A2D1', // æçº¿ç¹çé¢è² |
| | | lineStyle: { |
| | | color: '#68A2D1' // æçº¿çé¢è² |
| | | } |
| | | } |
| | | }, |
| | | areaStyle: { |
| | | normal: { |
| | | // é¢è²æ¸å彿° ååä¸ªåæ°åå«è¡¨ç¤ºå个ä½ç½®ä¾æ¬¡ä¸ºå·¦ãä¸ãå³ãä¸ |
| | | color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ |
| | | { |
| | | offset: 0, |
| | | color: 'rgba(0,0,0,0.2)' |
| | | }, |
| | | { |
| | | offset: 0.5, |
| | | color: 'rgba(25,64,121,.7)' |
| | | }, |
| | | { |
| | | offset: 1, |
| | | color: '#1B3C72' |
| | | } |
| | | ]) |
| | | } |
| | | } |
| | | }, |
| | | { |
| | | name: 'çµæºäº®åº¦', |
| | | data: this.lightList, |
| | | symbol: 'circle', // æçº¿ç¹è®¾ç½®ä¸ºå®å¿ç¹ |
| | | symbolSize: 10, // 设å®å®å¿ç¹çå¤§å° |
| | | type: 'line', |
| | | lineStyle: { |
| | | width: 5 |
| | | }, |
| | | itemStyle: { |
| | | normal: { |
| | | color: '#F81136', // æçº¿ç¹çé¢è² |
| | | lineStyle: { |
| | | color: '#F81136' // æçº¿çé¢è² |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | |
| | | var singleDataChart = echarts.init( |
| | | document.getElementById('singleDataChart') |
| | | ) |
| | | singleDataChart.setOption(option) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | <style> |
| | | </style> |
| | | |
| | | |