diff --git a/stdiet-ui/public/index.html b/stdiet-ui/public/index.html
index 6d64bf957..34b70ae6f 100644
--- a/stdiet-ui/public/index.html
+++ b/stdiet-ui/public/index.html
@@ -6,6 +6,7 @@
+
<%= webpackConfig.name %>
diff --git a/stdiet-ui/src/views/custom/recipesBuild/InfoView/PieChart/index.vue b/stdiet-ui/src/views/custom/recipesBuild/InfoView/PieChart/index.vue
index 6444d1e80..265002f95 100644
--- a/stdiet-ui/src/views/custom/recipesBuild/InfoView/PieChart/index.vue
+++ b/stdiet-ui/src/views/custom/recipesBuild/InfoView/PieChart/index.vue
@@ -3,8 +3,25 @@
:class="`aspect_pie_chart_wrapper ${className || ''}`"
:style="{ height: height, width: width }"
>
-
-
+
+
+
+
+
+
+
+
+
+
-
- 查看全部
-
+ 查看全部
@@ -76,10 +88,19 @@ export default {
f: "脂肪",
c: "碳水",
},
+ menuDict: {
+ 1: "早餐",
+ 2: "早加餐",
+ 3: "午餐",
+ 4: "午加餐",
+ 5: "晚餐",
+ 6: "晚加餐",
+ },
typeDict: {
Weight: "摄入量",
Rate: "供能比",
},
+ view: 1,
};
},
computed: {
@@ -119,16 +140,17 @@ export default {
methods: {
initChart() {
this.chart = echarts.init(this.$refs.echart, "myShine");
- this.updateChart(this.data.length > 0 ? this.data[0] : {});
+ this.updateChart(this.data[0] || {});
},
backToAll() {
this.resetCurrentDay({ currentDay: -1 });
},
updateChart(data) {
+ // console.log(data);
this.chart.clear();
- this.chart.setOption({
+ const option = {
title: {
- text: "营养分析",
+ text: !this.view ? "营养分析" : "热量分析",
subtext: data.name,
},
tooltip: {
@@ -142,26 +164,90 @@ export default {
percent,
data: { value, oriData, dim },
} = params;
- return [
- `${marker} ${name}`,
- `摄入量:${oriData[`${dim}Weight`].toFixed(1)}克`,
- `摄入热量:${value.toFixed(1)}千卡`,
- `供能比:${percent}%`,
- ].join("");
+ return !this.view
+ ? [
+ `${marker} ${name}`,
+ `摄入量:${oriData[`${dim}Weight`].toFixed(1)}克`,
+ `摄入热量:${value.toFixed(1)}千卡`,
+ `供能比:${percent}%`,
+ ]
+ : [
+ `${marker} ${name}`,
+ `热量:${data[`heat${dim}`].toFixed(1)}千卡`,
+ `供能比:${percent}%`,
+ ].join("");
},
},
+ graphic:
+ this.view === 1
+ ? [
+ {
+ type: "group",
+ top: 60,
+ left: 10,
+ silent: true,
+ children: [
+ {
+ type: "text",
+ style: {
+ text: "总热量",
+ fill: "#606266",
+ },
+ },
+ {
+ type: "text",
+ top: 18,
+ left: 8,
+ style: {
+ text: `${this.totalHeat.toFixed(1)}千卡`,
+ font: '14px "Microsoft YaHei", sans-serif',
+ },
+ },
+ ],
+ },
+ {
+ type: "group",
+ top: 36,
+ right: 10,
+ silent: true,
+ children: Object.keys(this.menuDict).reduce((arr, cur) => {
+ const tarData = data[`heat${cur}`];
+ if (tarData) {
+ arr.push({
+ type: "text",
+ top: arr.length * 20,
+ right: 10,
+ style: {
+ text: `${this.menuDict[cur]}:${tarData.toFixed(1)}`,
+ fill: "#606266",
+ },
+ });
+ }
+ return arr;
+ }, []),
+ },
+ ]
+ : [],
series: [
{
name: data.name,
type: "pie",
- radius: [0, 40],
+ radius: [0, !this.view ? 40 : 60],
center: ["50%", "55%"],
- data: ["p", "f", "c"].map((dim) => ({
- dim,
- value: data[`${dim}Heat`],
- name: this.nameDict[dim],
- oriData: data,
- })),
+ data: (!this.view
+ ? Object.keys(this.nameDict)
+ : Object.keys(this.menuDict)
+ ).reduce((arr, dim) => {
+ if (!this.view || data[`heat${dim}`]) {
+ arr.push({
+ dim,
+ value: !this.view ? data[`${dim}Heat`] : data[`heat${dim}`],
+ name: (!this.view ? this.nameDict : this.menuDict)[dim],
+ oriData: data,
+ });
+ }
+ return arr;
+ }, []),
// labelLine: {
// length: 5,
// length2: 5,
@@ -170,7 +256,7 @@ export default {
show: true,
position: "inside",
color: "#fff",
- fontSize: 10,
+ fontSize: !this.view ? 10 : 12,
fontWeight: "bold",
},
itemStyle: {
@@ -179,7 +265,16 @@ export default {
},
},
],
+ };
+ console.log(option);
+ this.chart.setOption(option);
+ },
+ handleOnViewChange(view) {
+ this.view = view;
+ this.chart.resize({
+ width: !this.view ? 100 : 364,
});
+ this.updateChart(this.data[0] || {});
},
...mapMutations(["resetCurrentDay"]),
},
@@ -195,21 +290,24 @@ export default {
};