Skip to content

Commit 8795518

Browse files
Update following feedback
1 parent b2d337f commit 8795518

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

Vue/src/components/HomeContent.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script setup lang="ts">
2+
import { ref } from 'vue';
3+
24
import 'devextreme/dist/css/dx.material.blue.light.compact.css';
35
import DxChart, { DxBackgroundColor, DxCommonPaneSettings, DxConstantLine, DxLabel, DxSeries, DxTooltip, DxValueAxis } from 'devextreme-vue/chart';
46
import { registerGradient } from 'devextreme-vue/common/charts';
@@ -20,15 +22,13 @@ const chartData = [
2022
];
2123
2224
function calculateAverageSpend() {
23-
let sum = 0;
24-
25-
chartData.forEach((data) => {
26-
sum += data.actualSpend;
27-
});
25+
const sum = chartData.reduce((accumulator, { actualSpend }) => accumulator + actualSpend, 0);
2826
2927
return sum / chartData.length;
3028
}
3129
30+
const averageSpend = ref(calculateAverageSpend());
31+
3232
function customizeTooltip(data: { value: number; seriesName: string }) {
3333
if (data.seriesName === 'Budget') {
3434
return { text: formatNumber(data.value, 'currency') };
@@ -48,6 +48,7 @@ const chartGradient = registerGradient('linear', {
4848
color: '#ffdeff',
4949
}],
5050
});
51+
5152
</script>
5253
<template>
5354
<div>
@@ -71,7 +72,7 @@ const chartGradient = registerGradient('linear', {
7172
/>
7273
<DxValueAxis>
7374
<DxConstantLine
74-
:value="calculateAverageSpend()"
75+
:value="averageSpend"
7576
color="#0000c7"
7677
>
7778
<DxLabel

0 commit comments

Comments
 (0)