1- import React , { useCallback , useState } from 'react' ;
1+ import React from 'react' ;
22import './App.css' ;
33
44import 'devextreme/dist/css/dx.material.blue.light.compact.css' ;
5- import { BackgroundColor , Chart , CommonPaneSettings , ConstantLine , Label , Series , Tooltip , ValueAxis , type ChartTypes } from 'devextreme-react/chart' ;
5+ import {
6+ BackgroundColor ,
7+ Chart ,
8+ CommonPaneSettings ,
9+ ConstantLine ,
10+ Label ,
11+ Series ,
12+ Tooltip ,
13+ ValueAxis ,
14+ } from 'devextreme-react/chart' ;
615import { registerGradient } from 'devextreme-react/common/charts' ;
716import { formatNumber } from 'devextreme/localization' ;
817
@@ -21,7 +30,7 @@ const chartData = [
2130 { month : 'December' , targetSpend : 25000 , actualSpend : 27000 } ,
2231] ;
2332
24- function calculateAverageSpend ( ) {
33+ function calculateAverageSpend ( ) : number {
2534 let sum = 0 ;
2635
2736 chartData . forEach ( ( data ) => {
@@ -31,7 +40,7 @@ function calculateAverageSpend() {
3140 return sum / chartData . length ;
3241}
3342
34- function customizeTooltip ( data : { value : number } ) {
43+ function customizeTooltip ( data : { value : number } ) : { text : string } {
3544 const isValueAboveAverage = data . value > calculateAverageSpend ( ) ;
3645 const aboveText = `${ formatNumber ( data . value , 'currency' ) } \n${ formatNumber ( data . value - calculateAverageSpend ( ) , 'currency' ) } above average spending.` ;
3746 const belowText = `${ formatNumber ( data . value , 'currency' ) } \n${ formatNumber ( calculateAverageSpend ( ) - data . value , 'currency' ) } below average spending.` ;
@@ -46,7 +55,7 @@ const chartGradient = registerGradient('linear', {
4655 offset : '90%' ,
4756 color : '#ffdeff' ,
4857 } ] ,
49- } )
58+ } ) ;
5059
5160function App ( ) : JSX . Element {
5261 return (
0 commit comments