使用单选框radio切换echarts图,和lable绑定

该博客主要展示了如何在Vue项目中利用模板和data属性创建一个动态折线图组件。页面包含一个可滚动区域,显示多个折线图选项,用户可以通过点击选择不同的折线图。折线图使用了ECharts库,数据来源于后台,包括'胖的水'和'胖的料'两个系列,同时配置了图例、网格和坐标轴等细节。
摘要由CSDN通过智能技术生成

默认选中第一个

1. 页面使用

<template>
    <div class="headerH">
        <div style="height: 15%;overflow: auto;">
            <template v-for="(curveTitle,index) in feedTitle">
                <input type="radio" name="check"
                       :value="curveTitle.feedingCurveTitle" :id=index
                       @click="getAllCurves(index)" :checked="index == getAllCurvesIndex"/>
                <label :for=index style="cursor:pointer">{{curveTitle.feedingCurveTitle}}
                    <i style="color: #ff5e03;margin-right: 8px">{{curveTitle.otherTypeTitle}}</i></label>
            </template>
        </div>
        <div style="height: 85%">
            <lineEcharts v-model="option" v-on:paramsName="echartsParams"></lineEcharts>
        </div>
    </div>
</template>
        data() {
            return {
                option: {},
                feedTitle: '', //存后台传过来的数据
                feedingCurveData: [],
                getAllCurvesIndex: 0,
                majorType: 1,
            };
        },

2. 折线数据

                        this.option = {
                            backgroundColor: "#fff",
                            tooltip: {
                                trigger: "axis",
                                show: true,
                            },
                            series: [{
                                name: "胖的水",
                                type: "line",
                                smooth: true,
                                symbol: "circle",
                                symbolSize: 13,
                                itemStyle: {
                                    color: "#fb7636",
                                    borderColor: "#fff",
                                    borderWidth: 2,
                                },
                                data: waterData,
                            }, {
                                name: "胖的料",
                                type: "line",
                                smooth: true,
                                symbol: "circle",
                                symbolSize: 13,
                                itemStyle: {
                                    color: "#24b314",
                                    borderColor: "#fff",
                                    borderWidth: 2,
                                },
                                data: feedData, //后台数据
                            }],
                            legend: {
                                show: true,
                                icon: "circle",
                                top: 20,
                                textStyle: {
                                    fontSize: 12,
                                    color: "#c8c8c8",
                                },
                            },
                            grid: {
                                left: "5%",
                                right: "5%",
                                top: "15%",
                                bottom: "6%",
                                containLabel: true,
                            },
                            xAxis: {
                                axisLine: {
                                    show: false,
                                },
                                axisTick: {
                                    show: false,
                                },
                                axisLabel: {
                                    interval: 0,
                                },
                                data: seriesArr, //后台数据
                            },
                            yAxis: {
                                axisLine: {
                                    show: false,
                                },
                                axisTick: {
                                    show: false,
                                },
                            },

                        };

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值