Skip to content

Commit c2fc310

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

11 files changed

Lines changed: 36 additions & 18 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ import DxChart, {
4545
} from 'devextreme-vue/chart';
4646
import { dataSource } from './data.ts';
4747
48-
const customizeTooltip = ({ valueText }: { valueText: string }) => ({ text: Math.abs(Number(valueText)) });
49-
const customizeLabel = ({ value }: { value: number }) => `${Math.abs(value)}%`;
48+
const customizeTooltip = ({ valueText }: any) => ({ text: Math.abs(Number(valueText)) });
49+
const customizeLabel = ({ value }: any) => `${Math.abs(value)}%`;
5050
</script>
5151
<style>
5252
#chart {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<script setup lang="ts">
3131
3232
import { type DxPieChart } from "devextreme-vue/pie-chart";
33-
import { chartPointObject } from "devextreme/viz/chart";
33+
import { type chartPointObject } from "devextreme/viz/chart";
3434
3535
type DxPieChartInstance = DxPieChart['instance'];
3636
@@ -44,14 +44,14 @@ const country = props.pieChart
4444
.getAllSeries()[0]
4545
.getVisiblePoints()[0]
4646
.data
47-
.country as String;
47+
.country as string;
4848
4949
const getImagePath = (countryName: string): string => `../../../../images/flags/${countryName.replace(/\s/, '').toLowerCase()}.svg`;
5050
const calculateTotal = (pieChart: DxPieChartInstance): string => formatNumber(
5151
pieChart
5252
.getAllSeries()[0]
5353
.getVisiblePoints()
54-
.reduce((s: number, p: chartPointObject ) => s + (p.originalValue as number), 0),
54+
.reduce((s: number, p: chartPointObject) => s + (p.originalValue as number), 0),
5555
);
5656
5757
const formatNumber = new Intl.NumberFormat('en-US', {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ import DxTreeMap, {
3636
} from 'devextreme-vue/tree-map';
3737
import { citiesPopulation } from './data.ts';
3838
39-
const drillInfo = ref([]);
39+
const drillInfo = ref<Array<{ text: string; node?: any }>>([]);
4040
4141
function nodeClick({ node }: DxTreeMapTypes.ClickEvent) {
4242
node.drillDown();
4343
}
44+
4445
function drill(e: DxTreeMapTypes.DrillEvent) {
4546
drillInfo.value = [];
4647
for (let node = e.node.getParent(); node; node = node.getParent()) {
@@ -55,7 +56,8 @@ function drill(e: DxTreeMapTypes.DrillEvent) {
5556
});
5657
}
5758
}
58-
function drillInfoClick(node) {
59+
60+
function drillInfoClick(node: any) {
5961
node?.drillDown();
6062
}
6163
</script>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ import { weatherData } from './data.ts';
8080
const customizeTooltip = (
8181
{
8282
seriesName, value, lowErrorValue, highErrorValue,
83+
}: {
84+
seriesName: string;
85+
value: number;
86+
lowErrorValue: number;
87+
highErrorValue: number;
8388
},
8489
) => (
8590
{ text: `${seriesName}: ${value} (range: ${lowErrorValue} - ${highErrorValue})` }

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,19 @@ import DxButton from 'devextreme-vue/button';
5454
import { mountains } from './data.ts';
5555
5656
const chart = ref();
57-
const customizeTooltipText = ({ argumentText, point, valueText }) => ({
57+
58+
const customizeTooltipText = ({ argumentText, point, valueText }: any) => ({
5859
text: `<span class='title'>${argumentText
5960
}</span><br />&nbsp;<br />System: ${point.data.system
6061
}<br />Height: ${valueText} m`,
6162
});
62-
const customizeLabelText = ({ value }) => `${value} m`;
63+
64+
const customizeLabelText = ({ value }: any) => `${value} m`;
65+
6366
function printChart() {
6467
chart.value.instance.print();
6568
}
69+
6670
function exportChart() {
6771
chart.value.instance.exportTo('Example', 'png');
6872
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ import Form from './Form.vue';
7676
const form = ref();
7777
const chart = ref();
7878
79-
const prepareMarkup = (chartSVG, markup) => {
79+
const prepareMarkup = (chartSVG: string, markup: string): SVGElement => {
8080
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
8181
svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
8282
svg.setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
@@ -93,7 +93,7 @@ const prepareMarkup = (chartSVG, markup) => {
9393
return svg;
9494
};
9595
96-
function onClick() {
96+
function onClick(): void {
9797
const chartSVG = chart.value.instance.svg();
9898
const formContent = form.value.getMarkup();
9999
@@ -102,10 +102,10 @@ function onClick() {
102102
height: 420,
103103
margin: 0,
104104
format: 'png',
105-
svgToCanvas(svg, canvas) {
105+
svgToCanvas(svg: SVGElement, canvas: HTMLCanvasElement) {
106106
return new Promise((resolve) => {
107107
const v = Canvg.fromString(
108-
canvas.getContext("2d"),
108+
canvas.getContext("2d")!,
109109
new XMLSerializer().serializeToString(svg)
110110
);
111111

apps/demos/Demos/Charts/ExportCustomMarkup/Vue/Form.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<script setup lang="ts">
6161
6262
defineExpose({
63-
getMarkup() {
63+
getMarkup(): string {
6464
// @ts-ignore
6565
return this.$el.innerHTML;
6666
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import service from './data.ts';
5757
5858
const dataSource = service.dataSource();
5959
60-
const customizeTooltip = ({ percentText, valueText }) => ({ text: `${percentText}`, years: `${valueText}` });
60+
const customizeTooltip = ({ percentText, valueText }: { percentText: string; valueText: string }) => ({ text: `${percentText}`, years: `${valueText}` });
6161
</script>
6262
<style>
6363
#chart {

apps/demos/Demos/Charts/LabelCustomization/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 { dataSource } from './data.ts';
4545
46-
const formatLabel = ({ valueText, percentText }) => `${valueText} (${percentText})`;
46+
const formatLabel = ({ valueText, percentText }: { valueText: string; percentText: string }) => `${valueText} (${percentText})`;
4747
</script>
4848

4949
<style>

apps/demos/Demos/Charts/LegendMarkersCustomization/Vue/data.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
function generateData(start, end, step) {
2-
const data = [];
1+
interface DataPoint {
2+
value: number;
3+
originalValue: number;
4+
argument: number;
5+
}
6+
7+
function generateData(start: number, end: number, step: number): DataPoint[] {
8+
const data: DataPoint[] = [];
39
for (let i = start; i < end; i += step) {
410
const originalValue = Math.sin(i) / i;
511
data.push({ value: originalValue + ((0.5 - Math.random()) / 10), originalValue, argument: i });

0 commit comments

Comments
 (0)