3 Star 0 Fork 0

徐童博/final-project

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
itemThree.vue 2.17 KB
一键复制 编辑 原始数据 按行查看 历史
徐童博 提交于 2023-05-04 17:28 . 完成
<template>
<div>
<div class="chart" id="myEcharts">
<span>图表加载中...</span>
</div>
</div>
</template>
<script>
import { inject, onMounted, reactive } from "vue";
export default {
setup() {
let $echarts = inject("echarts");
let $http = inject("axios");
// 存储数据
let data = reactive({});
// 请求获取数据
async function getState() {
data = await $http({ url: "/three/data" });
}
onMounted(() => {
getState().then(() => {
// 设置表格
let myChart = $echarts.init(document.getElementById("myEcharts"));
myChart.setOption({
title: {
subtext: "单位:百万元",
subtextStyle: {
color: "#fff"
}
},
tooltip: {
trigger: "axis"
},
legend: {
data: ["运输费用", "保管费用", "管理费用"]
},
textStyle: {
color: "#fff",
fontSize: 12
},
legend: {
// orient: "vertical",
right: "top",
textStyle: {
color: "#fff"
}
},
grid: {
left: "3%",
right: "4%",
bottom: "3%",
containLabel: true
},
xAxis: {
type: "category",
boundaryGap: false,
data: ["2020", "2021", "2023"]
},
yAxis: {
type: "value"
},
series: [
{
name: "运输费用",
type: "line",
stack: "Total",
data: [120, 132, 101, 134, 90, 230, 210]
},
{
name: "保管费用",
type: "line",
stack: "Total",
data: [220, 182, 191, 234, 290, 330, 310]
},
{
name: "管理费用",
type: "line",
stack: "Total",
data: [150, 232, 201, 154, 190, 330, 410]
}
]
});
});
});
return {
getState,
data
};
}
};
</script>
<style>
.chart {
height: 210px;
}
</style>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xutobo/final-project.git
git@gitee.com:xutobo/final-project.git
xutobo
final-project
final-project
master

搜索帮助