echarts 实战应用

// 使用echarts
import * as echarts from 'echarts'
// 设备信息数据
const   EquipmentDatas = EquipmentInformationDatas => {
    return  {
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'line'
            }
        },
        xAxis: {
            type: 'category',
            boundaryGap: false
        },
        yAxis: {
            type: 'value',
            boundaryGap: [0, '30%'],
            axisTick: {
                alignWithLabel: true
            }
        },
        // visualMap: {
        //     type: 'piecewise',
        //     show: false,
        //     dimension: 0,
        //     seriesIndex: 0,
        //     pieces: [
        //         {
        //             gt: 1,
        //             lt: 3,
        //             color: 'rgba(0, 0, 180, 0.4)'
        //         },
        //         {
        //             gt: 5,
        //             lt: 7,
        //             color: 'rgba(0, 0, 180, 0.4)'
        //         }
        //     ]
        // },
        // dataZoom: [
        //     {
        //         type: 'inside',
        //         start: 0,
        //         end: 2
        //     },
        //     {
        //         start: 0,
        //         end: 2
        //     }
        // ],
        series: [
            {
                name: '消息量',
                type: 'line',
                smooth: 0,
                symbol: 'none',
                symbolSize: 1,
                lineStyle: {
                    color: '#1890ff'
                },
                // markLine: {
                //     symbol: ['none', 'none'],
                //     label: { show: false },
                //     data: [{ xAxis: 1 }, { xAxis: 3 }, { xAxis: 5 }, { xAxis: 7 }]
                // },
                areaStyle: {
                    color: echarts.graphic.LinearGradient(0, 0, 0, 1, [
                        {
                            offset: 0,
                            color: '#1890ff'
                        },
                        {
                            offset: 1,
                            color: '#1890ff'
                        }
                    ])
                },
                data: EquipmentInformationDatas
            }
        ]
    }
}

// 当前在线
const   deviceOnline = datas => {
    return {
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'none',
                axis: 'x',
                label: {
                    show: false,
                    fontStyle: 'lighter',
                    fontSize: 12
                }
            }
        },
        // grid: {
        //     left: '0%',
        //     right: '4%',
        //     bottom: '3%',
        //     top: '2%',
        //     containLabel: true
        // },
        xAxis: [
            {
                type: 'time',
                show: false

            }
        ],
        yAxis: {
            axisLine: {
                show: false
            },
            axisTick: {
                show: false
            },
            show: false

        },
        // series: [
        //     {
        //         name: 'Direct',
        //         type: 'bar',
        //         barWidth: '60%',
        //         data: datas
        //     }
        // ],
        series: [
            {
                name: '消息量',
                type: 'bar',
                smooth: 0,
                symbol: 'none',
                symbolSize: 1,
                // showBackground: true,
                itemStyle: {
                    color: echarts.graphic.LinearGradient(0, 0, 0, 1, [
                        { offset: 0, color: '#83bff6' },
                        { offset: 0, color: '#188df0' },
                        { offset: 0, color: '#188df0' }
                    ]),
                    shadowColor: false

                },
                data: datas
            }
        ]
    }
}

// 设备消息量
const   deviceInfoNum =  datas => {
    console.log(datas, '数据')
    return  {
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'none',
                axis: 'x',
                snap: true,
                // z: 0,
                triggerTooltip: true,
                label: {
                    show: false,
                    fontStyle: 'lighter',
                    fontSize: 18
                }

            }
        },
        xAxis: [
            {
                type: 'time',
                show: false

            }
        ],
        yAxis: {
            axisLine: {
                show: false
            },
            axisTick: {
                show: false
            },
            show: false

        },

        series: [
            {
                name: '消息量',
                data: datas,
                type: 'line',
                areaStyle: {},
                pointer: {
                    icon: 'circle'
                },

                symbol: 'circle',
                // cursor: 'pointer',

                showSymbol: false,

                lineStyle: {
                    color: '#fff'
                },
                labelLine: {
                    show: false
                },
                itemStyle: {
                    color: echarts.graphic.LinearGradient(0, 0, 0, 1, [
                        { offset: 0, color: '#975FE4' },
                        { offset: 0, color: '#A776E8' },
                        { offset: 0, color: '#8150C6' }
                    ]),
                    shadowColor: false

                }
            }
        ]
    }
}
// cpu图形数据
const  cpuDatas = datas => {
    console.log(datas)
    return   {
        tooltip: {
            formatter: '{a} <br/>{b} : {c}%'
        },

        series: [
            {

                radius: '78%',  // 仪表盘的半径
                name: '使用率',
                type: 'gauge',
                max: 10,
                splitNumber: 10, // 分割段数,默认为5
                splitLine: {
                    show: false, // 是否显示分割线
                    distance: 10
                },
                axisTick: {
                    show: true, // 是否显示刻度。
                    splitNumber: 1,
                    distance: -12,
                    lineStyle: {
                        color: '#63677A'
                    }
                },
                axisLabel: {
                    distance: 2
                },
                detail: {
                    formatter: '{value}%',
                    textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
                        color: '#333',
                        fontWeight: 'bold',
                        fontSize: 16
                    }
                },
                progress: {
                    show: true,
                    clip: true,
                    itemStyle: {
                        color: '#46DE71',
                        shadowColor: true

                    }
                },
                pointer: {
                    icon: 'roundRect',
                    width: 6,
                    itemStyle: {
                        color: echarts.graphic.LinearGradient(0, 0, 0, 1, [
                            { offset: 0, color: '#1890FF' },
                            { offset: 0, color: '#1890FF' },
                            { offset: 0, color: '#1890FF' }
                        ]),
                        shadowColor: false

                    }
                },
                data: [
                    {
                        value: 2
                        // name: 'SCORE'
                    }
                ]
            }
        ]
    }

}

// jvm图形数据
const  jvmDatas = val => {
    console.log(val)
    return   {
        tooltip: {
            formatter: '{a} <br/>{b} : {c}%'
        },

        series: [
            {

                radius: '78%',  // 仪表盘的半径
                name: '使用率',
                type: 'gauge',
                max: 10,
                splitNumber: 10, // 分割段数,默认为5
                splitLine: {
                    show: false, // 是否显示分割线
                    distance: 10
                },
                axisTick: {
                    show: true, // 是否显示刻度。
                    splitNumber: 1,
                    distance: -12,
                    lineStyle: {
                        color: '#63677A'
                    }
                },
                axisLabel: {
                    distance: 2
                },
                detail: {
                    formatter: '{value}%',
                    textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
                        color: '#333',
                        fontWeight: 'bold',
                        fontSize: 16
                    }
                },

                progress: {
                    show: true,
                    clip: true,
                    itemStyle: {
                        color: '#1890FF',
                        shadowColor: true

                    }
                },
                pointer: {
                    // icon: 'roundRect',
                    width: 6,
                    itemStyle: {
                        color: echarts.graphic.LinearGradient(0, 0, 0, 1, [
                            { offset: 0, color: '#2F9CFF' },
                            { offset: 0, color: '#2F9CFF' },
                            { offset: 0, color: '#2F9CFF' }
                        ]),
                        shadowColor: false

                    }
                },
                data: [
                    {
                        value: 2,
                        // name: 'SCORE',

                        detail: {
                            show: true,
                            color: '#654332'
                        },
                        itemStyle: {
                            color: echarts.graphic.LinearGradient(0, 0, 0, 1, [
                                { offset: 0, color: '#83bff6' },
                                { offset: 0, color: '#83bff6' },
                                { offset: 0, color: '#83bff6' }
                            ]),
                            shadowColor: false

                        }
                    }
                ]
            }
        ]
    }

}

// 暴露出去
export  default {
    EquipmentDatas,
    deviceOnline,
    deviceInfoNum,
    cpuDatas,
    jvmDatas

}

效果图:

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
在Vue和Echarts的项目实战中,首先要使用vue-cli3创建项目。可以通过运行命令"vue create 项目名称"来创建一个Vue项目。接下来,进入项目目录,使用命令"npm run serve"来运行项目。这样就可以在本地开发环境中开始项目实战了。 在数据可视化方面,Echarts是一个非常流行的图表库之一。除了Echarts外,还有其他一些流行的图表库,比如AntV、Highcharts和D3.js。这些图表库都是基于浏览器图形渲染技术实现的,主要有两种类型: Canvas和SVG。Canvas适合于大型渲染区域的应用程序,而SVG适合于图像密集型的应用。它们各自有不同的特点和适用场景,具体选择哪种图表库要根据项目需求和特点进行选择。 在具体的项目实战中,可以使用Echarts来创建各种图表和地图。Echarts提供了丰富的图表类型和交互功能,可以根据数据灵活地进行配置和展示。例如,可以使用Echarts来创建柱状图、折线图、饼图等各种类型的图表。同时,Echarts还支持对地图进行可视化展示,可以绘制各种地理信息和相关数据。使用Echarts可以通过配置项和数据来实现对图表和地图的定制化展示,使数据更加直观和易于理解。 在Vue和Echarts项目实战中,除了使用Echarts来创建图表和地图,还可以结合其他技术和工具来实现更多功能。例如,可以使用全局模态框来实现弹窗效果,使用Flex布局来实现页面的自适应布局,使用数字滚动来展示数据的动态变化,使用自定义小部件来实现一些炫酷的效果等等。此外,还可以利用rem和flexible.js进行智能大屏适配,使用cssrem插件来方便地使用rem单位进行样式开发等。 总之,在Vue和Echarts的项目实战中,可以根据具体需求和项目特点,结合Vue的开发框架和Echarts的数据可视化能力,实现丰富多样的图表和地图展示,同时还可以利用其他技术和工具来增强项目的功能和用户体验。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [echarts学习——(上)Vue+Echarts构建可视化大数据平台实战项目分享(附源码)](https://blog.csdn.net/weixin_43148111/article/details/123982183)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

你的美,让我痴迷

你的好,我会永远记住你的。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值