Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!-- default badges list -->
![](https://img.shields.io/endpoint?url=https://codecentral.devexpress.com/api/v1/VersionRange/1015331587/25.1.3%2B)
[![](https://img.shields.io/badge/Open_in_DevExpress_Support_Center-FF7200?style=flat-square&logo=DevExpress&logoColor=white)](https://supportcenter.devexpress.com/ticket/details/T1298736)
[![](https://img.shields.io/badge/📖_How_to_use_DevExpress_Examples-e9f6fc?style=flat-square)](https://docs.devexpress.com/GeneralInformation/403183)
[![](https://img.shields.io/badge/💬_Leave_Feedback-feecdd?style=flat-square)](#does-this-example-address-your-development-requirementsobjectives)
Expand Down
142 changes: 79 additions & 63 deletions Vue/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
},
"dependencies": {
"devextreme": "24.2.3",
"devextreme-vue": "24.2.3",
"devextreme": "25.1.3",
"devextreme-vue": "25.1.3",
"vue": "^3.2.45",
"vue-router": "^4.1.6"
},
Expand Down
101 changes: 85 additions & 16 deletions Vue/src/components/HomeContent.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,94 @@
<script setup lang="ts">
import { computed, ref } from 'vue';

import 'devextreme/dist/css/dx.material.blue.light.compact.css';
import DxButton from 'devextreme-vue/button';
import DxChart, { DxBackgroundColor, DxCommonPaneSettings, DxConstantLine, DxLabel, DxSeries, DxTooltip, DxValueAxis } from 'devextreme-vue/chart';
import { registerGradient } from 'devextreme-vue/common/charts';
import { formatNumber } from 'devextreme/localization';

const props = defineProps({
text: String,
});
const count = ref(0);
const buttonText = computed<string>(
() => `Click ${props.text}: ${count.value}`
);
function clickHandler() {
count.value += 1;
const chartData = [
{ month: 'January', targetSpend: 12000, actualSpend: 9500 },
{ month: 'February', targetSpend: 15500, actualSpend: 16500 },
{ month: 'March', targetSpend: 13500, actualSpend: 12000 },
{ month: 'April', targetSpend: 16000, actualSpend: 14000 },
{ month: 'May', targetSpend: 17000, actualSpend: 18500 },
{ month: 'June', targetSpend: 20000, actualSpend: 17500 },
{ month: 'July', targetSpend: 14500, actualSpend: 11000 },
{ month: 'August', targetSpend: 21000, actualSpend: 22500 },
{ month: 'September', targetSpend: 19000, actualSpend: 18000 },
{ month: 'October', targetSpend: 22000, actualSpend: 25000 },
{ month: 'November', targetSpend: 16000, actualSpend: 14500 },
{ month: 'December', targetSpend: 25000, actualSpend: 27000 },
];

function calculateAverageSpend() {
Comment thread
arman-boyakhchyan marked this conversation as resolved.
let sum = 0;

chartData.forEach((data) => {
sum += data.actualSpend;
});

return sum / chartData.length;
}

function customizeTooltip(data: { value: number; seriesName: string }) {
if (data.seriesName === 'Budget') {
return { text: formatNumber(data.value, 'currency') };
}
const isValueAboveAverage = data.value > calculateAverageSpend();
const aboveText = `${formatNumber(data.value, 'currency')}\n${formatNumber(data.value - calculateAverageSpend(), 'currency')} above average spending.`;
const belowText = `${formatNumber(data.value, 'currency')}\n${formatNumber(calculateAverageSpend() - data.value, 'currency')} below average spending.`;
return { text: isValueAboveAverage ? aboveText : belowText };
}

const chartGradient = registerGradient('linear', {
colors: [{
offset: '20%',
color: '#dee4ff',
}, {
offset: '90%',
color: '#ffdeff',
}],
});
</script>
<template>
<div>
<DxButton
:text="buttonText"
@click="clickHandler"
/>
<DxChart
title="Target vs Actual Spending 2024"
:data-source="chartData"
>
<DxSeries
type="bar"
argument-field="month"
value-field="targetSpend"
name="Budget"
color="#5996ff"
/>
<DxSeries
type="spline"
argument-field="month"
value-field="actualSpend"
name="Amount Spent"
color="#cb4bfa"
/>
<DxValueAxis>
<DxConstantLine
:value="calculateAverageSpend()"
Comment thread
arman-boyakhchyan marked this conversation as resolved.
Outdated
color="#0000c7"
>
<DxLabel
text="Yearly Spend Average"
/>
</DxConstantLine>
</DxValueAxis>
<DxTooltip
:enabled="true"
:customize-tooltip="customizeTooltip"
/>
<DxCommonPaneSettings>
<DxBackgroundColor
base="#ffffff"
:fill-id="chartGradient"
/>
</DxCommonPaneSettings>
</DxChart>
</div>
</template>
Loading