添加备注,柱状图标线

This commit is contained in:
huangdeliang
2021-03-03 19:25:03 +08:00
parent b8fad6218f
commit 96a405a314
8 changed files with 271 additions and 98 deletions

View File

@ -279,7 +279,7 @@
controls-position="right"
@change="handleInputChange"
:min="0"
:step="50"
:step="5"
/>
</template>
</el-table-column>
@ -298,13 +298,14 @@
label="碳水/100g"
align="center"
/>
<el-table-column label="热量/100g" align="center">
<el-table-column label="热量" align="center">
<template slot-scope="scope">
{{
`${(
scope.row.proteinRatio * 4 +
scope.row.fatRatio * 9 +
scope.row.carbonRatio * 4
((scope.row.proteinRatio * scope.row.weight) / 100) *
4 +
((scope.row.fatRatio * scope.row.weight) / 100) * 9 +
((scope.row.carbonRatio * scope.row.weight) / 100) * 4
).toFixed(1)} kcal`
}}
</template>
@ -753,21 +754,25 @@ export default {
},
getSummaries(param) {
const { columns, data } = param;
console.log(data);
return columns.reduce(
(arr, cur, idx) => {
if (idx > 1) {
if (idx === 6) {
// 备注
return arr;
arr[6] = arr[3] * 4 + arr[4] * 9 + arr[5] * 4 + ' kcal';
} else {
arr[idx] = data.reduce((acc, dAcc) => {
if (idx === 2) {
return acc + parseFloat(dAcc.weight);
}
return parseFloat(
(
acc +
(dAcc[cur.property] * parseFloat(dAcc.weight)) / 100
).toFixed(1)
);
}, 0);
}
arr[idx] = data.reduce((acc, dAcc) => {
if (idx === 2) {
return acc + parseFloat(dAcc.weight);
}
return parseFloat(
(acc + (dAcc[cur.property] * dAcc.weight) / 100).toFixed(1)
);
}, 0);
}
return arr;
},

View File

@ -30,6 +30,10 @@ export default {
type: Array,
default: [],
},
max: {
type: Number,
default: 0,
},
},
data() {
return {
@ -64,6 +68,7 @@ export default {
this.updateChart(this.data.length > 0 ? this.data : {});
},
updateChart(source) {
console.log(this.max);
this.chart.clear();
this.chart.setOption({
title: {
@ -112,7 +117,7 @@ export default {
grid: {
top: 55,
left: 20,
right: 20,
right: 50,
bottom: 10,
containLabel: true,
},
@ -135,6 +140,13 @@ export default {
y: dim,
x: 0,
},
markLine: {
data: [{ name: "BMR", yAxis: this.max - 400 }],
symbol: "none",
lineStyle: {
color: "red",
},
},
itemStyle: {
borderWidth: 2,
borderColor: "#fff",

View File

@ -58,6 +58,16 @@
:data="data"
height="170px"
width="500px"
:max="
healthyData.basicBMR
? parseFloat(
healthyData.basicBMR.substring(
0,
healthyData.basicBMR.indexOf('千卡')
)
)
: 0
"
/>
<PieChart
v-if="data.length === 1"
@ -89,7 +99,7 @@ export default {
},
props: ["collapse", "data"],
computed: {
...mapState(["recipesId", "reviewStatus"]),
...mapState(["recipesId", "reviewStatus", "healthyData"]),
},
methods: {
handleCollapseClick() {

View File

@ -11,8 +11,8 @@
</div>
<div class="right" v-loading="healthDataLoading">
<TemplateInfoView v-if="!!temId" :data="templateInfo" />
<HealthyView :data="healthyData" v-else-if="healthyDataType === 0" />
<BodySignView :data="healthyData" v-else />
<HealthyView :data="healthyData" v-else-if="healthyDataType === 0" dev />
<BodySignView :data="healthyData" v-else dev />
</div>
</div>
</template>