@@ -19,7 +19,7 @@ class ChartApp extends StatelessWidget {
1919
2020class MyHomePage extends StatefulWidget {
2121 // ignore: prefer_const_constructors_in_immutables
22- MyHomePage ({Key key}) : super (key: key);
22+ MyHomePage ({Key ? key}) : super (key: key);
2323
2424 @override
2525 _MyHomePageState createState () => _MyHomePageState ();
@@ -45,32 +45,29 @@ class _MyHomePageState extends State<MyHomePage> {
4545 height: 500 ,
4646 width: 320 ,
4747 child: SfCartesianChart (
48- backgroundColor: Colors .white,
49- plotAreaBackgroundColor: Colors .white,
50- onTooltipRender: (TooltipArgs args) {
51- if (args.pointIndex == 0 ) {
52- //Tooltip without header
53- args.header = '' ;
54- }
55- if (args.pointIndex == 1 ) {
56- //Tooltip with customized header
57- args.header = 'Sold' ;
58- }
59- if (args.pointIndex == 2 ) {
60- //Tooltip with X and Y positions of data points
61- args.header = 'x : y' ;
62- args.text =
63- '${args .locationX .floor ()} : ${args .locationY .floor ()}' ;
64- }
65- if (args.pointIndex == 3 ) {
66- //Tooltip with formatted DateTime values
67- List <CartesianChartPoint <dynamic >> chartdata =
68- args.dataPoints;
69- args.header =
70- DateFormat ('d MMM yyyy' ).format (chartdata[3 ].x);
71- args.text = '${chartdata [3 ].y }' ;
72- }
73- },
48+ backgroundColor: Colors .white,
49+ plotAreaBackgroundColor: Colors .white,
50+ onTooltipRender: (TooltipArgs args) {
51+ if (args.pointIndex == 0 ) {
52+ //Tooltip without header
53+ args.header = '' ;
54+ }
55+ if (args.pointIndex == 1 ) {
56+ //Tooltip with customized header
57+ args.header = 'Sold' ;
58+ }
59+ if (args.pointIndex == 2 ) {
60+ //Tooltip with X and Y positions of data points
61+ args.header = 'x : y' ;
62+ args.text = '${args .locationX !.floor ()} : ${args .locationY !.floor ()}' ;
63+ }
64+ if (args.pointIndex == 3 ) {
65+ //Tooltip with formatted DateTime values
66+ List <dynamic >? chartdata = args.dataPoints;
67+ args.header = DateFormat ('d MMM yyyy' ).format (chartdata! [3 ].x);
68+ args.text = '${chartdata [3 ].y }' ;
69+ }
70+ },
7471 primaryXAxis: DateTimeAxis (
7572 interval: 30 , intervalType: DateTimeIntervalType .days),
7673 // Enable tooltip
0 commit comments