echarts曲线图例自定义dataZoom

option = {
    backgroundColor: '#0c1e55', //背景颜色
    title: {
        text: '大声道', //表头
        x: 'center',
        top: "20",
        textStyle: {
            //文字颜色
            color: '#ffff',
            //字体风格
            fontStyle: 'normal',
            //字体粗细 
            fontWeight: 'bold',
            //字体系列
            fontFamily: 'sans-serif',
            //字体大小
            fontSize: 18

        },
    },
    tooltip: {
        trigger: 'axis',
        //  transitionDuration: 0,
        //   confine: true,
        //   bordeRadius: 51,
        borderWidth: 1, //提示框边框的大小
        borderColor: '#333', //提示框边框的颜色
        backgroundColor: 'rgba(255,255,255,0.9)', //提示框的背景颜色(0.9为透明度)
        textStyle: {
            fontSize: 12, //提示框的字体大小
            color: '#333', //提示框里的字体颜色
            aligin: 'center',

        },
    },
    color: ['red', '#12C3C3', '#FBCD14'], //颜色配置
    legend: {
        data: ['叠翠园', '北岳北'],
        // right:'30',//标签头 居右距离
        bottom: '70',
        // top:'20', //标签头 居上距离
        textStyle: {
            // color: [ '#','#'], // 标签头 提示文字的颜色
            color: '#ffff'
        },
        icon: "circle", //icon 长方形 circle 圆形 arrow箭头型 diamond菱形
        // triangle三角形  emptyDiamond 空心菱形
        //emptyCircle 空心圆型 emptyRectangle 空心长方形 emptyTriangle 空心三角形
    },
    // dataZoom: [{
    //     type: 'slider',
    //     realtime: true,
    //     //拖拉
    //     handleSize: '100%', //滑动条两侧的大小
    //     start: 0, //开始位置
    //     end: 50, //结束位置
    //     bottom: 25, //居下的距离
    //     textStyle: {
    //         color: '#1bb4f6' // 滑动条的文字颜色
    //     },
    // }],
    dataZoom: [
  {
    type: "slider",
    
    show: true,
    zoomLock: true,
    // orient: "vertical",
    // filterMode: "none",
    // right: "2%",
    start:100,
    end: 60,
    bottom: 25, //居下的距离
    // width: 10,
    height:10,
    textStyle: {
      color: "#FFF",
      fontSize: 9,
    },
    fillerColor: "rgba(21, 220, 247, 1)",
    brushSelect: false,
    handleIcon:
      "path://M30.9,53.2C16.8,53.2,5.3,41.7,5.3,27.6S16.8,2,30.9,2C45,2,56.4,13.5,56.4,27.6S45,53.2,30.9,53.2z M30.9,3.5M36.9,35.8h-1.3z M27.8,35.8 h-1.3H27L27.8,35.8L27.8,35.8z", // 画一个圆形
    handleSize: "100%",
    handleStyle: {
      color: "rgba(21, 220, 247, 1)",
      borderWidth: 0,
    },
    backgroundColor: "rgba(38, 108, 252, 0.1)", //两边未选中的滑动条区域的颜色

    borderColor: "transparent",
    filterMode: "filter",
  },
],
// dataZoom: [{
//     type: 'slider', // slider表示有滑动块的,inside表示内置的
//     show: true, // 是否显示dataZoom,在完全自定义的时候需要用到
//     xAxisIndex: [0], // dataZoom控制的图标的是哪条x轴,因为会有多轴一图,可以控制多轴
//     yAxisIndex: [1,0], // dataZoom控制的图标的是哪条y轴,因为会有多轴一图,可以控制多轴
//     start: 10, // 和startValue不要弄混,这里是百分比
//     end: 50, // 和endValue不要弄混,这里是百分比
//     startValue: 0, // 滑块左端对应的x值
//     endValue: 500, // 滑块右端对应的x值
//     height: 10, // dataZoom整体高度
//     filterMode: 'none', // 过滤模式,有filter, weakFilter, empty, none四个值,过滤会把整个数据段隐藏,而none则只是移动坐标轴
//     left: 0,
//     right: 0,
//     top: 0,
//     bottom: 25, // dataZoom相对图标的位置
//     animation:true, // 设置动画效果
//     throttle: 100, // 设置视图刷新的频率,ms
//     showDetail: false,
//     showDataShadow: false,
//     borderColor: '#0000', // dataZoom边框颜色
//     fillerColor: '#ffffff4c', //  滑块颜色
//     handleSize: '0%',
//     brushSelect: false // 是否允许拖动滑块长度改变视图范围,不允许就是固定范围
//   }],

    grid: {
        left: '3%', //整个曲线居左的距离
        right: '4%', //整个曲线居右左的距离
        bottom: '20%', //整个曲线居下左的距离
        height: '70%', //整个曲线的高
        containLabel: true
    },
    toolbox: {
        show: true,
        feature: {
            // dataZoom: {},
            dataView: {
                readOnly: true
            },
            magicType: {
                type: ['line', 'bar', 'pie']
            },
            restore: {},
            textStyle: {
                color: '#1bb4f6', // 左上角切换的颜色
            },
            // saveAsImage: {}
        }
    },
    optionToContent: function(opt) {
        let axisData = opt.xAxis[0].data; //坐标数据
        let series = opt.series; //折线图数据
        let tdHeads = '<td  style="padding: 0 10px;">时间</td>'; //表头
        let tdBodys = ''; //数据
        series.forEach(function(item) {
            //组装表头
            tdHeads += `<td style="padding: 0 10px">${item.name}</td>`;
        });
        let table = `<table border="1" style="margin-left:50px;border-collapse:collapse;font-size:24px;text-align:center;"><tbody><tr>${tdHeads} </tr>`;
        for (let i = 0, l = axisData.length; i < l; i++) {
            for (let j = 0; j < series.length; j++) {
                //组装表数据
                tdBodys += `<td>${ series[j].data[i]}</td>`;
            }
            table += `<tr><td style="padding: 0 10px">${axisData[i]}</td>${tdBodys}</tr>`;
            tdBodys = '';
        }
        table += '</tbody></table>';
        return table;
    },
    xAxis: {
        type: 'category',
        boundaryGap: false,
        data: ['10月1日', '10月2日', '10月3日', '10月4日', '10月5日', '10月6日', '10月7日'],

        axisLine: {
            lineStyle: {
                color: '#BA55D3', //设置X轴的颜色
                width: 1.5, //设置X轴的粗细
            }
        },
        axisLabel: {
            show: true,
            textStyle: {
                color: '#00FF00' //Y轴的数据字体颜色
            },
        },

    },
    yAxis: [{
            name: "亿元", //左侧单位
            nameTextStyle: {
                color: "#ebf8ac" //左侧单位文字
            },
            type: 'value',
            axisLine: {
                lineStyle: {
                    color: '#FFFF', //设置Y轴的颜色
                    width: 1.5, //设置Y轴的粗细
                }
            },
            axisLabel: {
                show: true,
                //formatter: "{value} %", //左侧单位添加后缀
                textStyle: {

                    color: '#00FF00' //Y轴的数据字体颜色
                },
            },
            splitLine: {
                show: true,
                lineStyle: {
                    color: '#FFC125' //网格线的颜色
                }
            }
        },
        {
            type: "value",
            name: "同比",
            nameTextStyle: {
                color: "red"
            },
            position: "right",
            splitLine: {
                show: false
            },
            axisTick: {
                show: false
            },
            axisLine: {
                lineStyle: {
                    color: 'red', //设置Y轴的颜色
                    width: 1.5, //设置Y轴的粗细
                }
            },
            axisLabel: {
                show: true,
                formatter: "{value} %", //右侧Y轴文字显示
                textStyle: {
                    color: "red"
                }
            }
        },
    ],
    series: [{
            name: '叠翠园',
            type: 'line',
            smooth: true, //圆滑的曲线
            data: [180, 92, 81, 174, 210, 280, 210],
            symbolSize: 1,
            //  color: '#BA55D3',
            yAxisIndex: 1, //下标以右侧同比数据参考
            lineStyle: {
                width: 5 //改变线条的粗细
            },
             label: {
                        show: true, //是否显示
                        // position: 'top', //位置
                        // distance: 15, //高度
                        // 			color: '#DB5E6A', //颜色
                        // fontWeight: 'bolder', //加粗
                        // fontSize: 20, //字体大小
                    },

        },
        {
            name: '北岳北',
            type: 'line',
            smooth: true,
            data: [340, 382, 391, 334, 390, 390, 410],
            // symbolSize: 1,
            //  label: {
            //             show: true, //是否显示
            //             position: 'top', //位置
            //             distance: 15, //高度
            //             // 			color: '#DB5E6A', //颜色
            //             fontWeight: 'bolder', //加粗
            //             // fontSize: 20, //字体大小
            //         },
        }
    ]
};

Echarts是一个用于数据可视化的JavaScript库,可以绘制各种类型的图表,包括曲线图。要使用Echarts绘制曲线图,首先需要下载Echarts.js包,可以从Echarts官网或其他来源下载\[2\]。下载完成后,将Echarts.js文件保存到项目的js文件夹下\[3\]。然后,在需要使用曲线图的网页中引入Echarts.js文件\[3\]。接下来,可以使用Echarts提供的API来绘制曲线图。在Vue.js中,可以在mounted钩子函数中调用绘制曲线图的方法\[1\]。在该方法中,首先需要初始化一个Echarts,然后通过设置option来配置曲线图的样式和数据,最后调用setOption方法将配置应用到图表中\[1\]。通过这些步骤,就可以在网页中使用Echarts绘制曲线图了。 #### 引用[.reference_title] - *1* [echarts--多条曲线图--vue](https://blog.csdn.net/qq_41579104/article/details/106940506)[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^v91^insert_down28v1,239^v4^insert_chatgpt"}} ] [.reference_item] - *2* *3* [Echarts曲线图)](https://blog.csdn.net/weixin_44591357/article/details/113184353)[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^v91^insert_down28v1,239^v4^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

花归去

客官赏点吧

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

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

打赏作者

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

抵扣说明:

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

余额充值