Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not correct Datetime values, when daylight time changed #2154

Open
ElvinMammadov opened this issue Oct 29, 2024 · 2 comments
Open

Not correct Datetime values, when daylight time changed #2154

ElvinMammadov opened this issue Oct 29, 2024 · 2 comments
Labels
charts Charts component feature New feature uncertain Uncertain feature

Comments

@ElvinMammadov
Copy link

Bug description

We are using Bar Chart in our App from syncfusion_flutter_charts and problem occured when time changed In Germany. After 27th of October AxisLabelRenderDetails details.value became strange. We receive Datetime value for 27th of October twice. For example below is values for one week.
1 day duration becomes 23 hours.

I/flutter (20731): graphDate: 2024-10-23 00:00:00.000
I/flutter (20731): graphDate: 2024-10-24 00:00:00.000
I/flutter (20731): graphDate: 2024-10-25 00:00:00.000
I/flutter (20731): graphDate: 2024-10-26 00:00:00.000
I/flutter (20731): graphDate: 2024-10-27 00:00:00.000
I/flutter (20731): graphDate: 2024-10-27 23:00:00.000
I/flutter (20731): graphDate: 2024-10-28 23:00:00.000

Steps to reproduce

  1. Date values for last 7 days
  2. 1 day Duration becomes from 23:00 previous day to 23:00 current day

Code sample

Code sample
          SfCartesianChart(
            backgroundColor: theme.own().colors.backgroundBlankLight,
            plotAreaBorderWidth: 0,
            series: widget.series,
            primaryXAxis: DateTimeAxis(
              majorTickLines: MajorTickLines(
                color: theme.own().colors.dividerLight,
              ),
              axisLine: AxisLine(
                color: theme.own().colors.dividerLight,
              ),
              majorGridLines: const MajorGridLines(width: 0),
              intervalType: DateTimeIntervalType.days,
              maximumLabels: week,
              dateFormat: DateFormat("E"),
              labelStyle: theme.own().textStyle.bodyExtraSmall.copyWith(
                    color: theme.own().colors.textSecondary,
                  ),
              initialVisibleMaximum: visibleMaximum,
              initialVisibleMinimum: visibleMinimum,
              interval: 1,
              axisLabelFormatter: (AxisLabelRenderDetails details) =>
                  _axisLabelFormatter(
                details: details,
                theme: theme,
              ),
              onRendererCreated: (DateTimeAxisController controller) {
                chartController = controller;
              },
            ),
            primaryYAxis: NumericAxis(
              axisLine: AxisLine(color: theme.own().colors.dividerLight),
              majorGridLines: const MajorGridLines(width: 0),
              majorTickLines: const MajorTickLines(width: 0),
              numberFormat: NumberFormat.decimalPattern(widget.locale),
              labelStyle: theme.own().textStyle.bodyExtraSmall.copyWith(
                    color: theme.own().colors.textSecondary,
                  ),
              opposedPosition: true,
            ),
            onPlotAreaSwipe: (ChartSwipeDirection direction) {
              if (direction == ChartSwipeDirection.end) {
                maxVisibleIndex =
                    min(maxVisibleIndex + week, dataSource.length - 1);
              } else {
                maxVisibleIndex = max(maxVisibleIndex - week, week - 1);
              }
              _setVisibleWeak();
            },
            onSelectionChanged: (SelectionArgs selection) {
              if (currentIndex != selection.pointIndex) {
                setState(() {
                  currentIndex = selection.pointIndex;
                  maxVisibleIndex = max(currentIndex + week ~/ 2, week - 1);
                  _selectBar();
                  _setVisibleWeak();
                });
              }
            },
          ),

  ChartAxisLabel _axisLabelFormatter({
    required AxisLabelRenderDetails details,
    required ThemeData theme,
  }) {
    String label = details.text.toUpperCase();
    TextStyle textStyle = details.textStyle;

    final DateTime graphDate =
        DateTime.fromMillisecondsSinceEpoch(details.value.toInt());
    final DateTime? visibleMinimum = this.visibleMinimum?.add(
          const Duration(hours: midday),
        );
    print('graphDate: $graphDate');
    if (dataSource[currentIndex].dateTime.isSameDate(graphDate)) {
      final String date = du.DateUtils.formatMonthDayMonth(graphDate);
      label += "\n $date";
      textStyle = textStyle.copyWith(
        color: theme.own().colors.textPrimary,
      );
    } else if (visibleMinimum != null && visibleMinimum.isSameDate(graphDate)) {
      final String date = du.DateUtils.formatMonthDayMonth(visibleMinimum);
      label += "\n $date";
    } else if (visibleMaximum != null &&
        visibleMaximum!.isSameDate(graphDate)) {
      final String date = du.DateUtils.formatMonthDayMonth(visibleMaximum!);
      label += "\n $date";
    } else {
      label += "\n";
    }
    return ChartAxisLabel(
      label,
      textStyle,
    );
  }

Screenshots or Video

Screenshots / Video demonstration ![Screenshot 2024-10-29 at 20 43 50](https://github.com/user-attachments/assets/2eff4f4e-4d1d-4cd2-ba2e-4a66b7658533)

Stack Traces

Stack Traces
It is not strack trace

On which target platforms have you observed this bug?

Android

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.22.1, on macOS 15.0.1 24A348 darwin-arm64, locale en-DE)
    • Flutter version 3.22.1 on channel stable at /Users/elvinmammadov/Downloads/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a14f74ff3a (5 months ago), 2024-05-22 11:08:21 -0500
    • Engine revision 55eae6864b
    • Dart version 3.4.1
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0-rc4)
    • Android SDK at /Users/elvinmammadov/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0-rc4
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16A242d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] Connected device (4 available)
    • sdk gphone64 arm64 (mobile)     • emulator-5554         • android-arm64  • Android 14 (API 34) (emulator)
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 15.0.1 24A348 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 15.0.1 24A348 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome 130.0.6723.70

[✓] Network resources
    • All expected network resources are available.

• No issues found!
@ElvinMammadov ElvinMammadov changed the title Not correct Datetime values, when time changes Not correct Datetime values, when time changed Oct 29, 2024
@ElvinMammadov ElvinMammadov changed the title Not correct Datetime values, when time changed Not correct Datetime values, when daylight time changed Oct 30, 2024
@VijayakumarMariappan VijayakumarMariappan added charts Charts component open Open labels Nov 1, 2024
@Abhijit-Revamp
Copy link

Wow, I noticed exactly same issues today when daylight savings time changed
Thanks for reporting.

@Baranibharathip
Copy link

Hi @ElvinMammadov,

We would like to let you know that currently we don’t have support for time zone in SfCartesianChart. However, we have considered your requirement as a new feature and logged feature request for it in our feedback portal.

We will prioritize the features of every release based on demand and priority. So, this feature will be available in any of our upcoming releases. You can also track the status of the feature with the feedback below.

Feedback: https://www.syncfusion.com/feedback/62812

Regards,
Baranibharathi P.

@LavanyaGowtham2021 LavanyaGowtham2021 added fixed Fixed and delivered update feature New feature uncertain Uncertain feature and removed open Open fixed Fixed and delivered update labels Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
charts Charts component feature New feature uncertain Uncertain feature
Projects
None yet
Development

No branches or pull requests

5 participants