Skip to content

[syncfusion_charts] Uniform Label Display with intersect? #2357

Open
@DrNiels

Description

@DrNiels

Bug description

I have a chart with a fixed interval value. If it becomes too thin, labels of the x axis are hidden by default. That works fine, but with labels having different widths, the resulting look can sometimes become pretty chaotic. Is there a way to force a uniform pattern on the hidden labels, e.g., only showing each third, depending on the available width?

In the code sample, AxisLabelIntersectAction.hide shows, that sometimes every third and sometimes every second label. That provides a really chaotic impression and a fixed interval would be highly appreciated. Or is there already an approach to do that?

Steps to reproduce

  1. Load the code sample
  2. See all available AxisLabelIntersectActions and see that none produces the desired output
  3. See the desired output as last entry, but that's obviously optimized for the current scenario and width and won't hold on flexible width

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_charts/charts.dart';

void main() async {
  runApp(MaterialApp(home: TestChart()));
}

class TestChart extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => TestChartState();
}

class TestChartState extends State<TestChart> {
  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Center(
        child: Wrap(
          children: [
            for (AxisLabelIntersectAction intersectAction
                in AxisLabelIntersectAction.values)
              SizedBox(
                width: 400,
                child: SfCartesianChart(
                  title: ChartTitle(text: intersectAction.toString()),
                  primaryYAxis: NumericAxis(),
                  primaryXAxis: DateTimeAxis(
                    intervalType: DateTimeIntervalType.hours,
                    interval: 1,
                    labelIntersectAction: intersectAction,
                    minimum: DateTime(2025, 2, 17),
                    maximum: DateTime(2025, 2, 18),
                  ),
                ),
              ),
            SizedBox(
              width: 400,
              child: SfCartesianChart(
                title: ChartTitle(text: 'Desired'),
                primaryYAxis: NumericAxis(),
                primaryXAxis: DateTimeAxis(
                  intervalType: DateTimeIntervalType.hours,
                  interval: 3,
                  minorTicksPerInterval: 2,
                  minimum: DateTime(2025, 2, 17),
                  maximum: DateTime(2025, 2, 18),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

Image

Stack Traces

Stack Traces

Not applicable

On which target platforms have you observed this bug?

Web

Flutter Doctor output

Doctor output

I use syncfusion_flutter_charts in version 29.2.4

[√] Flutter (Channel stable, 3.32.0, on Microsoft Windows [Version 10.0.19045.5854], locale de-DE) [617ms]
    • Flutter version 3.32.0 on channel stable at C:\Users\Niels\Documents\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision be698c48a6 (4 days ago), 2025-05-19 12:59:14 -0700
    • Engine revision 1881800949
    • Dart version 3.8.0
    • DevTools version 2.45.1

[√] Windows Version (10 Education 64-bit, 22H2, 2009) [2,4s]

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc4) [3,0s]
    • Android SDK at C:\Users\Niels\AppData\Local\Android\Sdk
    • Platform android-34, build-tools 34.0.0-rc4
    • Java binary at: C:\Program Files\Android\Android Studio1\jbr\bin\java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)
    • All Android licenses accepted.

[√] Chrome - develop for the web [162ms]
    • Chrome at C:\Users\Niels\AppData\Local\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.8.6) [160ms]
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.8.34525.116
    • Windows 10 SDK version 10.0.19041.0

[!] Android Studio (version 2021.2) [26ms]
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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
    X Unable to determine bundled Java version.
    • Try updating or re-installing Android Studio.

[√] Android Studio (version 2024.1) [25ms]
    • Android Studio at C:\Program Files\Android\Android Studio1
    • 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--11852314)

[√] VS Code, 64-bit edition (version 1.96.0) [24ms]
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.110.0

[√] Connected device (3 available) [343ms]
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19045.5854]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 136.0.7103.114
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 128.0.2739.42

[√] Network resources [748ms]
    • All expected network resources are available.

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    chartsCharts componentwaiting for customer responseCannot make further progress until the customer responds.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions