• 需要复制的demo


    echart demo

    <template>
      <div>
          <div ref="chart" style="width:26vw;height:28vw"></div>
          
      </div>
    </template>
    <script lang="ts" setup>
    import { ref, reactive, onMounted } from 'vue'
    import * as echarts from 'echarts'
    import {sitegetAsyncMonthEarningData,groupgetAsyncMonthEarningData} from '../../../api/fenxi'
    
    import { selectedStoreHook,useselectedStore } from "../../../store/modules/selected";
    
    import {getConsistency} from '@/api/jianshi'
    onMounted(()=>{
      fetchDatas()
       init(); // 将init函数调用移动到test赋值之后
      // fetchData(); // 在mounted钩子函数中调用fetchData函数
     
    })
    const fetchDatas = () => {
      getConsistency
    
    
    }
    const chart = ref();
    
    async function init() {
      var myChart = echarts.init(chart.value);
    
    
    var option = {
    
    
      legend: [{
          x2: 300,
          y: 20,
          icon: 'rect',
          itemGap: 3,
          itemWidth: 11,
          itemHeight: 11,
          orient: 'vertical',
          data: ['接收', '发送']
      }],
      grid: [{
          left: 20,
          right: 20,
          top: 80,
          bottom: 20,
          containLabel: true
      }],
      
      dataZoom: {
          type: 'inside',
          filterMode: 'filter',
          orient: 'horizontal',
          xAxisIndex: [0],
      },
      tooltip: {
          trigger: 'axis',
          axisPointer: {
              lineStyle: {
                  color: '#57617B'
              }
          },
    
          
          // formatter: function (params) {
          //         //文字加单位
          //         var relVal = params[0].name;
          //         for (var i = 0, l = params.length; i < l; i++) {
          //           relVal +=
          //             "
    " +
    // params[i].marker + // params[i].seriesName + // " : " + // params[i].value + // "%"; // } // return relVal; // }, }, xAxis: [{ type: 'category', boundaryGap: false, axisLine: { lineStyle: { color: '#57617B' } }, data: date }], yAxis: { type: 'value', axisTick: { show: false }, axisLine: { lineStyle: { color: '#57617B' } }, axisLabel: { formatter: '{value}', textStyle: { fontSize: 12 } }, splitLine: { lineStyle: { color: '#cccccc' } }, }, series: [{ name: '电流', type: 'line', showSymbol: false, tooltip: { valueFormatter: function (value) { return value.toFixed(0) + 'A'; } }, lineStyle: { normal: { width: 0 } }, itemStyle: { normal: { color: 'rgba(0,0,255)' } }, areaStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'rgba(0,0,255, 1)' }, { offset: 0.8, color: 'rgba(0,0,255, 0.5)' }]) }, }, data: cur }, { name: '电压', tooltip: { valueFormatter: function (value) { return value.toFixed(0) + 'V'; } }, type: 'line', showSymbol: false, lineStyle: { normal: { width: 0 } }, itemStyle: { normal: { color: 'rgba(0,255,0)' } }, areaStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'rgba(0,255,0,1)' }, { offset: 0.8, color: 'rgba(0,255,0, 0.5)' }]) }, }, data: vol }, { name: '电容', type: 'line', tooltip: { valueFormatter: function (value) { return value.toFixed(0) + 'Kwh'; } }, showSymbol: true, lineStyle: { normal: { width: 2 } }, itemStyle: { normal: { color: 'black' } }, data: cap }, ] }; myChart.setOption(option); } </script>
    • 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
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211

    echarts 的demo2

    <template>
      <div>
          <div ref="chart" style="width:40vw;height:20vw"></div>
          
      </div>
    </template>
    <script lang="ts" setup>
    import { ref, reactive, onMounted } from 'vue'
    import * as echarts from 'echarts'
    import {sitegetAsyncMonthEarningData,groupgetAsyncMonthEarningData} from '../../../api/fenxi'
    
    import { selectedStoreHook,useselectedStore } from "../../../store/modules/selected";
    
    import {GetGroupItem} from '@/api/celue'
    onMounted(()=>{
      fetchDatas()
       init(); // 将init函数调用移动到test赋值之后
      // fetchData(); // 在mounted钩子函数中调用fetchData函数
     
    })
    const fetchDatas = () => {
    
        GetGroupItem().then(response => {
           console.log(response);
        })
    }
    const chart = ref();
    
    async function init() {
      var myChart = echarts.init(chart.value);
    
      var plantCap = [{
        name: '设备组1',
        isopen: '充电中',
        moshiid:'手动',//0 手动 1 自动模式-削峰填谷  2 自动模式 -- 需量控制
        devicenum:12
    
    }, {
        name: '设备组1',
        isopen: '放电中',
        moshiid:'削峰填谷',//0 手动 1 自动模式-削峰填谷  2 自动模式 -- 需量控制
        devicenum:12
    },
    {
        name: '设备组1',
        isopen: '充电中',
        moshiid:'手动',//0 手动 1 自动模式-削峰填谷  2 自动模式 -- 需量控制
        devicenum:12
    }, {
        name: '设备组1',
        isopen: '放电中',
        moshiid:'削峰填谷',//0 手动 1 自动模式-削峰填谷  2 自动模式 -- 需量控制
        devicenum:12
    },
    {
        name: '设备组1',
        isopen: '充电中',
        moshiid:'手动',//0 手动 1 自动模式-削峰填谷  2 自动模式 -- 需量控制
        devicenum:12
    }, {
        name: '设备组1',
        isopen: '放电中',
        moshiid:'削峰填谷',//0 手动 1 自动模式-削峰填谷  2 自动模式 -- 需量控制
        devicenum:12
    },{
        name: '设备组1',
        isopen: '放电中',
        moshiid:'削峰填谷',//0 手动 1 自动模式-削峰填谷  2 自动模式 -- 需量控制
        devicenum:12
    },
    {
        name: '设备组1',
        isopen: '放电中',
        moshiid:'削峰填谷',//0 手动 1 自动模式-削峰填谷  2 自动模式 -- 需量控制
        devicenum:12
    },
    ];
    var datalist = [{
        offset: [56, 48],
        symbolSize: 100,
        color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{
            offset: 0,
            color: 'rgba(67, 186, 255, 0)',
        }, {
            offset: 1,
            color: 'rgb(67, 186, 255)'
        }])
    
    }, {
        offset: [30, 70],
        symbolSize: 70,
        color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{
            offset: 0,
            color: 'rgba(67, 186, 255, 0)',
        }, {
            offset: 1,
            color: 'rgb(67, 186, 255)'
        }])
    }, {
        offset: [10, 43],
        symbolSize: 70,
        color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{
            offset: 0,
            color: 'rgba(27, 96, 255, 0)',
        }, {
            offset: 1,
            color: 'rgb(27, 96, 255)'
        }])
    
    }, {
        offset: [90, 30],
        symbolSize: 65,
        color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{
            offset: 0,
            color: 'rgba(48, 191, 191, 0)',
        }, {
            offset: 1,
            color: 'rgb(48, 191, 191)'
        }])
    }, {
        offset: [35, 25],
        symbolSize: 60,
        color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{
            offset: 0,
            color: 'rgba(0, 166, 166, 0)',
        }, {
            offset: 1,
            color: 'rgb(0, 166, 166)'
        }])
    }, {
        offset: [75, 75],
        symbolSize: 55,
        color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{
            offset: 0,
            color: 'rgba(84, 136, 255, 0)',
        }, {
            offset: 1,
            color: 'rgb(84, 136, 255)'
        }])
    
    },
    {
        offset: [95, 65],
        symbolSize: 50,
        color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{
            offset: 0,
            color: 'rgba(54, 150, 250, 0)',
        }, {
            offset: 1,
            color: 'rgb(54, 150, 250)'
        }])
    
    },
    {
        offset: [89, 90],
        symbolSize: 40,
        color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{
            offset: 0,
            color: 'rgba(54, 150, 250, 0)',
        }, {
            offset: 1,
            color: 'rgb(54, 150, 250)'
        }])
    
    }
    ];
    
    var datas = [];
    for (var i = 0; i < plantCap.length; i++) {
        var item = plantCap[i];
        var itemToStyle = datalist[i];
        datas.push({
            name: item.name+'\n'+item.isopen + '\n' + item.moshiid,
            value: itemToStyle.offset,
            symbolSize: itemToStyle.symbolSize,
            label: {
                normal: {
                    textStyle: {
                        fontSize: 14
                    }
                }
            },
            itemStyle: {
                normal: {
                    color: itemToStyle.color,
                    opacity: itemToStyle.opacity
                }
            },
        })
    }
    var  option = {
        grid: {
            show: false,
            top: 10,
            bottom: 10
        },
    
        xAxis: [{
            gridIndex: 0,
            type: 'value',
            show: false,
            min: 0,
            max: 100,
            nameLocation: 'middle',
            nameGap: 5
        }],
    
        yAxis: [{
            gridIndex: 0,
            min: 0,
            show: false,
            max: 100,
            nameLocation: 'middle',
            nameGap: 30
        }],
        series: [{
            type: 'effectScatter',
        symbol: 'path://M160 960V192L293.333 64h405.334L832 192v768H160z m640-256V224H192v704h608V704z m-32-256H224V256h544v192zM576 320H416v32h160v-32z m192 352H224V480h544v192zM576 544H416v32h160v-32z m192 352H224V704h544v192zM576 768H416v32h160v-32z',
         symbolSize: 120,
            label: {
                normal: {
                    show: true,
                    formatter: '{b}',
                    color: '#FFF',
                    lineHeight: 15,
                    textStyle: {
                        fontSize: '30'
                    }
                },
            },
            itemStyle: {
                normal: {
                    borderWidth: '1',
                    borderType: 'solid',
                    borderColor: '#00ffff',
                    shadowColor: 'rgba(0, 0, 0, .6)',
                    shadowBlur: 10,
    
                }
            },
            data: datas
        }]
    
    }
    
    
      myChart.setOption(option);
      
    }
    
    </script>
    
    • 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
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
  • 相关阅读:
    【android】当数据库需要更新时我们该怎么办?
    [iOS开发]编译过程
    NL2SQL技术方案系列(1):NL2API、NL2SQL技术路径选择;LLM选型与Prompt工程技巧,揭秘项目落地优化之道
    大数据学习(16)-mapreduce详解
    孙卫琴的《精通Vue.js》读书笔记-Vue组件的单向数据流
    DeepSeek 不能识图?装个开源 Skill,纯文本模型也能"睁眼"了
    正向代理和反向代理
    初级软件测试工程师如何涨薪?
    python-20220928
    nginx环境下laravel框架URL省略输入index.php的配置
  • 原文地址:https://blog.csdn.net/m0_56666791/article/details/134317888