Echars-折线图

本文详细介绍使用ECharts进行图表初始化及配置的过程,包括图表显示条件设置、数据系列定义、颜色样式设定及区域填充效果实现。通过具体代码示例,展示如何在Vue环境下创建并定制动态响应的数据可视化图表。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!-- 图表 -->
<div class="chartdiv bg-white border">
    <div v-if="currentData.length===0" class="no-data" style="height:300px;">
        暂无数据
    </div>
    <div v-show="currentData.length>0" ref="netValueChart" style="height:300px;"></div>
</div>


//初始化图表
        chartInit() {
            if (!this.lineArt) this.lineArt = echarts.init(this.$refs["netValueChart"]);
            const option = {
                xAxis: {
                    type: "category",
                    boundaryGap: false,
                    data: this.fundNavChartDate
                },
                yAxis: {
                    type: "value"
                },
                tooltip: {
                    trigger: "axis",
                    axisPointer: {
                        type: "cross",
                        label: {
                            backgroundColor: "#6a7985"
                        }
                    }
                },
                legend: {
                    data: [第一组数据,第二组数据]
                },
                series: [{
                    data: this.dataOne,
                    name: "第一组数据",
                    type: "line",
                    smooth: true,
                    symbol: "none",
                    lineStyle: { normal: { width: 2 } },
                    itemStyle: {
                        normal: {
                            color: "#e99400",
                            lineStyle: {
                                color: "#e99400"
                            }
                        }
                    },
                    areaStyle: {
                        normal: {
                            color: new echarts.graphic.LinearGradient(
                                0, 0, 0, 0,
                                [
                                    { offset: 0, color: "#e99400" },
                                    { offset: 0.7, color: "#FFE2C6" },
                                    { offset: 1, color: "#ffffff" }
                                ]
                            )
                        }
                    }
                },{
                    data: this.dataTwo,
                    name: "第二组数据",
                    type: "line",
                    smooth: true,
                    symbol: "none",
                    lineStyle: { normal: { width: 2 } },
                    itemStyle: {
                        normal: {
                            color: "#409EFF",
                            lineStyle: {
                                color: "#409EFF"
                            }
                        }
                    },
                    areaStyle: {
                        normal: {
                            color: new echarts.graphic.LinearGradient(
                                0, 0, 0, 0,
                                [
                                    { offset: 0, color: "#409EFF" },
                                    { offset: 0.1, color: "#409EFF" },
                                    { offset: 1, color: "#ffffff" }
                                ]
                            )
                        }
                    }
                }]
            };
            this.lineArt.setOption(option);
        }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值