【Echarts】图表制作—折线图

1.引入 echarts.js

     <script type="text/javascript" src="/static/js/echarts.js"></script>

2.为ECharts准备一个具备大小(宽高)的Dom

    <div id="container" style="border-style: solid;border-width: 0px;color:#666666;height: 430px;"></div>

3.初始化echarts实例

    var myChart = echarts.init(document.getElementById('container'));
    $.get('/admin/devData/sendqueueshow').done(function (data) {
                if (data != null) {
                    var series = [];
                    for (var i = 0; i < data.channelList.length; i++) {
                        series.push({
                            name: data.channelList[i],
                            type: 'line',
                            data: data.sendQueueList[i],
                            // markPoint: {
                            //     data: [
                            //         {type: 'max', name: '最大值'},
                            //         {type: 'min', name: '最小值'}
                            //     ]
                            // }
                        });
                    }
    
                    myChart.resize();
                    myChart.clear();		//清除旧图
                    myChart.setOption({
                        tooltip: {
                            trigger: 'axis'
                        },
                        grid: {
                            x: 5,   //左侧与y轴的距离
                            y: 12,   //top部与x轴的距离
                            x2: 20,   //右侧与y轴的距离
                            y2: -6,    //bottom部与x轴的距离},
                            containLabel: true
                        },
                        xAxis: [{
                            show: false,
                            type: 'category',
                            data: data.timeList,
                            axisLabel: {                        //字体
                                show: true,
                                textStyle: {
                                    // color: '#666666',
                                    color: '#ffffff',
                                    fontSize: '12'
                                }
                                // interval:0,                     //隔几个标签显示一个标签
                                // rotate:40                       //标签倾斜角度
                            }
                        }],
                        yAxis: [{
                            type: 'value',
                            axisLabel: {                        //字体
                                show: true,
                                textStyle: {
                                    // color: '#666666',
                                    color: '#ffffff',
                                    fontSize: '12'
                                }
                            }
                        }],
                        series: series
                    })
                }
     });
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值