1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
| <template>
| <div style="width: 100%;height: 100%;">
| <div style="width: 100%;height: 100%;" :id="'main'+ids"></div>
| </div>
| </template>
| <script>
| import * as echarts from 'echarts';
| export default{
| props:{
| ids:{
| type:String,
| default: '0',
| },
| colorType:{
| type:Number,
| default: 0,
| }
| },
| data () {
| return {
| myChart:"",
| };
| },
| methods: {
| initCharts () {
| var chartDom = document.getElementById('main'+this.ids);
| var myChart = echarts.init(chartDom, 'dark');
| var option;
| var greenOrRed="";
| var greenOrReds="";
| console.log(this.colorType)
| if(this.colorType>0){
| greenOrRed='rgba(65,172,117,0.6)'
| greenOrReds='rgba(65,172,117,0.05)'
| }else{
| greenOrRed='rgba(166,10,36,0.6)'
| greenOrReds='rgba(166,10,36,0.05)'
| }
| option = {
| xAxis: {
| show:false,
| type: 'category',
| boundaryGap: false,
|
| },
| yAxis: {
| show:false,
| type: 'value'
| },
| tooltip: {
| show: true,
| extraCssText:'100%;height: 1.5385rem;'
| },
| backgroundColor: 'rgba(0,0,0,0)',
| color: {
| type: 'linear',
| x:0,
| y:0,
| x2: 0,
| y2: 1,
| colorStops: [{
| offset: 0, color: greenOrRed // 0% 处的颜色
| }, {
| offset: 1, color: greenOrReds // 100% 处的颜色
| }],
| globalCoord: false // 缺省为 false
| },
| series: [
| {
| data: [820, 932, 901, 934, 1000, 900, 1320,820, 932, 901, 934, 1000, 900,],
| type: 'line',
| areaStyle: {}
| }
| ]
| };
|
| option && myChart.setOption(option);
| }
| },
| mounted () {
| this.initCharts();
| window.onresize = function() {
| this.myChart.resize();
| };
| }
| }
| </script>
|
|