echarts 进度条实现
<template>
<div class="container">
<div id="echart" class="container"></div>
</div>
</template>
<script>
export default {
data() {
return {
timmerOneAnim: null,
myChart: null,
};
},
created() { },
mounted() {
this.$nextTick(() => {
this.Init();
});
},
methods: {
Init() {
const echarts = require("echart");
if (
//判断是否存在echarts实例化对象,如果存在则销毁
this.myChart != null &&
this.myChart != "" &&
this.myChart != undefined
) {
this.myChart.dispose();
}
var myChartDom = document.getElementById("lowerEcharts");
this.myChart = this.$echarts.init(myChartDom);
this.myChart.clear(); //清空画布数据
var option = {
// backgroundColor: "#031d33",
grid: {
top: 0,
bottom: 0,
left: 0,
right: 0,
},
xAxis: {
show: false,
type: "value",
boundaryGap: [0, 0],
},
yAxis: [
{
type: "category",
data: [""],
axisLine: { show: false },
axisTick: [
{
show: false,
},
],
},
],
series: [
{
name: "金额",
type: "bar",
zlevel: 1,
itemStyle: {
normal: {
barBorderRadius: 30,
// color: "#00eeff",
color: new echarts.graphic.LinearGradient(1, 0, 0, 1, [
{
offset: 1,
// color: "rgba(255,51,51, 1)",
color: "#56ab2f",
},
{
offset: 0,
// color: "rgba(255,51,51, 0.4)",
color: "#a8e063",
},
]),
},
},
barWidth: 10,
data: [60],
},
{
name: "背景",
type: "bar",
barWidth: 10,
barGap: "-100%",
data: [100],
itemStyle: {
normal: {
color: "rgba(229,230,231, 0.4)",
barBorderRadius: 30,
},
},
},
],
};
option && this.myChart.setOption(option, true);
// 设置宽度自适应
window.addEventListener("resize", () => {
this.myChart.resize();
});
},
},
beforeDestroy() { },
};
</script>
<style lang="scss" scoped>
.container {
height: 100%;
width: 100%;
}
</style>
效果图
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端
2022-09-01 vue前端解析Excel表格数据
2021-09-01 maven中如何防止资源导出失败问题