Skip to content

Commit 547e6c7

Browse files
fix ts in vue demos
1 parent 5f2dfa7 commit 547e6c7

10 files changed

Lines changed: 33 additions & 19 deletions

File tree

apps/demos/Demos/Charts/Candlestick/Vue/App.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ import { dataSource } from './data.ts';
5656
5757
const customizeTooltip = ({
5858
openValue, closeValue, highValue, lowValue,
59+
}: {
60+
openValue: number;
61+
closeValue: number;
62+
highValue: number;
63+
lowValue: number;
5964
}) => ({
6065
text: `Open: $${openValue}<br/>
6166
Close: $${closeValue}<br/>

apps/demos/Demos/Charts/CenterLabelCustomization/Vue/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ import { data } from './data.ts';
4242
import CenterTemplate from './CenterTemplate.vue';
4343
4444
const countries = Array.from(new Set(data.map(({ country }) => country)));
45-
const customizeLabel = ({ argumentText, valueText }) => `${argumentText}\n${valueText}`;
46-
const getData = (country) => data.filter((i) => i.country === country);
45+
const customizeLabel = ({ argumentText, valueText }: { argumentText: string; valueText: string }) => `${argumentText}\n${valueText}`;
46+
const getData = (country: string) => data.filter((i) => i.country === country);
4747
</script>
4848
<style scoped>
4949
.pies-container {

apps/demos/Demos/Charts/CenterLabelCustomization/Vue/CenterTemplate.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,29 @@
2929
</template>
3030
<script setup lang="ts">
3131
32+
import { type DxPieChart } from "devextreme-vue/pie-chart";
33+
import { chartPointObject } from "devextreme/viz/chart";
34+
35+
type DxPieChartInstance = DxPieChart['instance'];
36+
3237
const props = withDefaults(defineProps<{
33-
pieChart?: Record<string, any>
38+
pieChart?: DxPieChartInstance
3439
}>(), {
35-
pieChart: () => ({} as Record<string, any>),
40+
pieChart: () => ({} as DxPieChartInstance),
3641
});
3742
3843
const country = props.pieChart
3944
.getAllSeries()[0]
4045
.getVisiblePoints()[0]
4146
.data
42-
.country;
47+
.country as String;
4348
44-
const getImagePath = (countryName) => `../../../../images/flags/${countryName.replace(/\s/, '').toLowerCase()}.svg`;
45-
const calculateTotal = (pieChart) => formatNumber(
49+
const getImagePath = (countryName: string): string => `../../../../images/flags/${countryName.replace(/\s/, '').toLowerCase()}.svg`;
50+
const calculateTotal = (pieChart: DxPieChartInstance): string => formatNumber(
4651
pieChart
4752
.getAllSeries()[0]
4853
.getVisiblePoints()
49-
.reduce((s, p) => s + p.originalValue, 0),
54+
.reduce((s: number, p: chartPointObject ) => s + (p.originalValue as number), 0),
5055
);
5156
5257
const formatNumber = new Intl.NumberFormat('en-US', {

apps/demos/Demos/Charts/ClientSideDataProcessing/Vue/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const monthWeather = new DataSource({
6262
paginate: false,
6363
});
6464
65-
const customizeLabelText = ({ valueText }) => `${valueText}${'&#176C'}`;
65+
const customizeLabelText = ({ valueText }: { valueText: string }) => `${valueText}${'&#176C'}`;
6666
6767
function changeTemperature({ value }: DxSelectBoxTypes.ValueChangedEvent) {
6868
monthWeather.filter(['t', '>', value]);

apps/demos/Demos/Charts/CustomFillStyles/Vue/App.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import {
3434
} from './utils.js';
3535
import { data } from './data.ts';
3636
37-
function customizePoint(point) {
37+
function customizePoint(point: any) {
3838
const color = point.series.getPointsByArg(point.argument)[0].getColor();
3939
let fillId;
4040
switch (point.argument) {
@@ -59,7 +59,8 @@ function customizePoint(point) {
5959
6060
return { color: { fillId } };
6161
}
62-
const customizeText = ({ argument }) => argument;
62+
63+
const customizeText = ({ argument }: { argument: string }) => argument;
6364
</script>
6465

6566
<style>

apps/demos/Demos/Charts/CustomizePointsAndLabels/Vue/App.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,20 @@ import { temperaturesData } from './data.ts';
5353
const highAverage = 77;
5454
const lowAverage = 58;
5555
const dataSource = temperaturesData;
56-
const customizeText = ({ valueText }) => `${valueText}&#176F`;
57-
const customizePoint = ({ value }) => {
56+
57+
const customizeText = ({ valueText }: { valueText: string }) => `${valueText}&#176F`;
58+
59+
const customizePoint = ({ value }: { value: number }) => {
5860
if (value > highAverage) {
5961
return { color: '#ff7c7c', hoverStyle: { color: '#ff7c7c' } };
6062
}
6163
return (value < lowAverage) ? { color: '#8c8cff', hoverStyle: { color: '#8c8cff' } } : null;
6264
};
63-
const customizeLabel = ({ value }) => ((value > highAverage) ? {
65+
66+
const customizeLabel = ({ value }: { value: number }) => ((value > highAverage) ? {
6467
visible: true,
6568
backgroundColor: '#ff7c7c',
66-
customizeText: ({ valueText }) => `${valueText}&#176F`,
69+
customizeText: ({ valueText }: { valueText: string }) => `${valueText}&#176F`,
6770
} : null);
6871
</script>
6972
<style>

apps/demos/Demos/Charts/DiscreteAxisZoomingAndScrolling/Vue/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ const series = [{
110110
valueField: 'Na',
111111
}];
112112
113-
const customizeText = ({ valueText }) => `${valueText}%`;
113+
const customizeText = ({ valueText }: { valueText: string }) => `${valueText}%`;
114114
</script>
115115
<style scoped>
116116
#zoomedChart {

apps/demos/Demos/Charts/Doughnut/Vue/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import DxPieChart, {
4242
} from 'devextreme-vue/pie-chart';
4343
import { populationByRegions } from './data.ts';
4444
45-
const customizeTooltip = ({ valueText, percent }) => ({
45+
const customizeTooltip = ({ valueText, percent }: { valueText: string; percent: number }) => ({
4646
text: `${valueText} - ${(percent * 100).toFixed(2)}%`,
4747
});
4848
</script>

apps/demos/Demos/Charts/DoughnutSelection/Vue/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import DxPieChart, {
3030
} from 'devextreme-vue/pie-chart';
3131
import { olympicMedals } from './data.ts';
3232
33-
function pointClickHandler({ target }) {
33+
function pointClickHandler({ target }: { target: { select: () => void } }): void {
3434
target.select();
3535
}
3636
</script>

apps/demos/Demos/Charts/DoughnutWithTopNSeries/Vue/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import DxPieChart, {
4343
} from 'devextreme-vue/pie-chart';
4444
import { internetLanguages } from './data.ts';
4545
46-
const customizeLabel = ({ argumentText, valueText }) => `${argumentText}: ${valueText}%`;
46+
const customizeLabel = ({ argumentText, valueText }: { argumentText: string; valueText: string }) => `${argumentText}: ${valueText}%`;
4747
</script>
4848
<style>
4949
#pie {

0 commit comments

Comments
 (0)