You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using SfCartesianChart in my Flutter app to display monthly sales and cost data. The data is correctly sorted based on the month order before being passed to the chart, but the chart does not display the data correctly.
Even though debugging logs confirm that the data is sorted correctly before rendering, the chart does not reflect the correct order in the X-axis.
What I Have Tried:
✅ Sorting Data Properly:
I implemented a reusable sortByMonth function that sorts the months based on English order and then converts them back to Arabic months before displaying them.
Debugging prints confirm that the data is correctly sorted before rendering.
// English month order mappingfinalMap<String, int> monthOrder = {
'January':1,
'February':2,
'March':3,
...
};
// Arabic month conversion mappingfinalMap<int, String> arabicMonths = {
1:'يناير',
2:'فبراير',
3:'مارس',
...
};
List<DataModel> sortByMonth(List<DataModel> data) {
// Sort data based on English month order
data.sort(
(a, b) => (monthOrder[a.month] ??0).compareTo(monthOrder[b.month] ??0));
// Convert back to Arabic monthsreturn data.map((e) {
returnDataModel(
month: arabicMonths[monthOrder[e.month] ??0] ?? e.month,
value: e.value,
label: e.label,
year: e.year,
);
}).toList();
}
✅ Ensuring Sorted Data is Used:
I assigned the sorted data to the dataSource of SfCartesianChart.
✅ Disabling Internal Chart Sorting:
I explicitly set sortingOrder: SortingOrder.none.
✅ Checked State Updates:
The data is correctly set using setState() in a StatefulWidget.
month sorting is correct and the data assigned correctly
On which target platforms have you observed this bug?
Android
Flutter Doctor output
Doctor output
Doctor summary (to see all details, run flutter doctor -v):[√] Flutter (Channel stable, 3.24.5, on Microsoft Windows [Version 10.0.26100.2894], locale en-US)[√] Windows Version (Installed version of Windows is version 10 or higher)[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0-rc3)[√] Chrome - develop for the web[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.12.4)[√] Android Studio (version 2024.2)[√] Android Studio (version 2023.3)[√] IntelliJ IDEA Ultimate Edition (version 2024.2)[√] Connected device (4 available)[√] Network resources
The text was updated successfully, but these errors were encountered:
Bug description
I'm using
SfCartesianChart
in my Flutter app to display monthly sales and cost data. The data is correctly sorted based on the month order before being passed to the chart, but the chart does not display the data correctly.Even though debugging logs confirm that the data is sorted correctly before rendering, the chart does not reflect the correct order in the X-axis.
What I Have Tried:
✅ Sorting Data Properly:
✅ Ensuring Sorted Data is Used:
✅ Disabling Internal Chart Sorting:
✅ Checked State Updates:
✅ Debugging Output Confirms Correct Order:
Output confirms data is in the right order before being passed to the chart, yet the chart still displays incorrect order.
Expected Behavior:
The X-axis should display months in the correct order (Arabic months) after sorting.
Actual Behavior:
The X-axis displays months in random or incorrect order, despite sorting being correct before rendering.
Flutter & Syncfusion Versions:
Flutter:
3.24.5
syncfusion_flutter_charts:
^27.1.53
Dart:
3.5.4
Questions:
Why is the Syncfusion chart ignoring the sorted order of months?
Is there an issue with CategoryAxis forcing its order?
How can I ensure that Arabic month labels appear in the correct order?
Steps to reproduce
sortByMonth
functionCode sample
sectionCode sample
Chart 1
Chart 2
Screenshots or Video
Chart 1
Chart 2
Stack Traces
Stack Traces
i will write the month number for more declaration
month sorting is correct and the data assigned correctly
On which target platforms have you observed this bug?
Android
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: