Skip to content

Commit 872bf5c

Browse files
Merge pull request #3 from PavithraNandhiniRamachandran/master
Axislabelformat event moved inside the axis
2 parents b794a1a + 9c01afe commit 872bf5c

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

lib/main.dart

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,10 @@ class _MyHomePageState extends State<MyHomePage> {
3838
height: 500,
3939
child: SfCartesianChart(
4040
borderWidth: 10,
41-
primaryXAxis: CategoryAxis(),
42-
primaryYAxis: NumericAxis(minimum: 20),
43-
backgroundColor: Colors.white,
44-
axisLabelFormatter: (AxisLabelRenderDetails args) {
45-
late String text;
46-
late TextStyle textStyle;
47-
if (args.axisName == 'primaryXAxis') {
41+
primaryXAxis: CategoryAxis(
42+
axisLabelFormatter: (AxisLabelRenderDetails args) {
43+
late String text;
44+
late TextStyle textStyle;
4845
text = '${args.text}st\nMonth';
4946
if (args.text == 'Jan')
5047
textStyle =
@@ -59,12 +56,11 @@ class _MyHomePageState extends State<MyHomePage> {
5956
if (args.text == 'May')
6057
textStyle =
6158
args.textStyle.copyWith(fontWeight: FontWeight.bold);
62-
} else {
63-
text = args.text;
64-
textStyle = args.textStyle;
65-
}
66-
return ChartAxisLabel(text, textStyle);
67-
},
59+
return ChartAxisLabel(text, textStyle);
60+
},
61+
),
62+
primaryYAxis: NumericAxis(minimum: 20),
63+
backgroundColor: Colors.white,
6864
series: <ChartSeries<SalesData, String>>[
6965
LineSeries<SalesData, String>(
7066
dataSource: <SalesData>[

0 commit comments

Comments
 (0)