Closed Abhijit-Revamp closed 3 weeks ago
Hi @Abhijit-Revamp,
We would like to let you know that the DateTimeAxis labels are calculated based on the provided data, ensuring that the axis displays relevant information. The appearance of the labels depends on the interval and intervalType set in the DateTimeAxis. However, if the dataSource is empty, the axis will display a default date range starting from 1970, such as labels from 'Feb 10 to May 31'. This is expected behavior.
If the dataSource is empty and you would like to display a predefined range, we recommend using the minimum and maximum properties in axis. Please refer the following code snippet.
SfCartesianChart(
primaryXAxis: const DateTimeAxis(
minimum: data.isEmpty ? DateTime(2024, 1, 1) : null;
maximum: data.isEmpty ? DateTime(2024, 6, 31) : null;
),
),
For more details, please refer to the following UG links: Date-time-intervals: https://help.syncfusion.com/flutter/cartesian-charts/axis-types#date-time-intervals Customizing axis range: https://help.syncfusion.com/flutter/cartesian-charts/axis-types#customizing-range-1
Regards, Natrayan
Thanks @natrayansf This is really simple solution. Will close
Bug description
I have a ColumnSeries with primaryXAxis as DateTimeAxis The intervalType is set to DateTimeIntervalType.days (however this has no impact)
Screen shots atached If the "dataSource" has one or more value, the Axis labels are perfect. As soon as the dataSource has empty list, the label jumps to "Feb 10 to May 31"
Steps to reproduce
Code sample
Code sample
```dart SfCartesianChart( primaryXAxis: const DateTimeAxis( title: AxisTitle(text: 'Date'), intervalType: DateTimeIntervalType.days, ), ```Screenshots or Video
Screenshots
Correct one: With just 1 element in data - still good Invalid dates with empty data set:Stack Traces
Stack Traces
```dart [Add the Stack Traces here] ```On which target platforms have you observed this bug?
Web
Flutter Doctor output
Doctor output
```console [✓] Flutter (Channel beta, 3.26.0-0.1.pre, on macOS 14.7 23H124 darwin-x64, locale en-IN) • Flutter version 3.26.0-0.1.pre on channel beta at /Volumes/Abhi-Data/FlutterDev/SDK/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision ee624bc4fd (5 weeks ago), 2024-09-10 17:41:06 -0500 • Engine revision 059e4e6d8f • Dart version 3.6.0 (build 3.6.0-216.1.beta) • DevTools version 2.39.0 ```