-
Notifications
You must be signed in to change notification settings - Fork 857
[syncfusion_charts] Uniform Label Display with intersect? #2357
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
Comments
Hi @DrNiels, We would like to inform you that the AxisLabelIntersectAction property is designed to manage overlapping axis labels. When using the hide option, it automatically hides the next label if it overlaps with the previous labels. This logic is applied sequentially to all axis labels. Additionally, the chart calculates an appropriate automatic interval based on the available axis size to minimize overlaps. If you prefer to control exactly which labels appear, you can disable the automatic interval by setting the interval property to a fixed value. Could you please describe your exact expectations for how overlapping labels should appear when using the hide intersect action so that we can assist you more effectively? Regards, |
My expectation or preference would be that the hiding of ticks would be uniform instead of only hiding the least required number. If you check the screenshot, you can see that the hide action displays "12AM", "3AM", "5AM", ... . As such the first step between two visible ticks is 3 while the next is 2. From 9 AM to 12 PM there's again a step of 3 ticks. That does look a bit wild on the x axis. Instead, it would be nice if the axis would determine the highest required step size, in this case 3 ticks. If that was applied to the x axis, the look would be uniform as "Show every third tick" looks clear and customers can easily understand it. Sure, you show less ticks in total, but have a good looking axis in return, as shown in the "Desired" chart of the screenshot. |
Hi @DrNiels, Thank you for your detailed explanation. We have understood your query. As mentioned previously, the AxisLabelIntersectAction property is designed to manage overlapping axis labels. When using the hide option, it automatically hides the next label if it overlaps with the previous labels. This logic is applied sequentially to all axis labels. For example, If the first label like "12 AM" has a wider width due to two digits, it may cause the next one or two labels to be hidden to avoid overlap. As a result, the next visible label might be "3 AM". Later, labels like "5 AM" (with a narrower width) may appear, leading to inconsistent spacing such as "3 AM", "5 AM", "6 AM". This behavior tries to fit as many labels as possible but may create uneven gaps. In your case, if you are looking for an alternative to using the interval property, you can use the axisLabelFormatter callback to apply custom logic to show labels at fixed intervals (e.g., every 3 hours). Also, set AxisLabelIntersectAction to none to prevent automatic hiding. Below is a code snippet showing how to display labels every 3 hours by calculating the difference between the current label and a fixed start time:
Output: UG Link: axisLabelFormatter: https://help.syncfusion.com/flutter/cartesian-charts/callbacks#axislabelformatter If you have any further queries, please get back to us. We are always happy to assist you. Regards, |
thank you for your feedback. Only displaying every second/third/... label is easy. The complicated part is to determine the required interval. If I have enough space, I want to show every label. If I don't, then every second. If there's not enough space for that either, every third, etc.. |
Hi @DrNiels, As mentioned earlier, the AxisLabelIntersectAction property is specifically designed to manage overlapping axis labels. When the hide option is enabled, it automatically hides only those labels that overlap with the previous one. This process is handled sequentially along the axis, and this is the default behavior. Please note that the axisLabelFormatter is a possible workaround and not an exact solution for managing label visibility. However, you can customize the shared code snippet further based on your specific requirements. Code snippet:
Demo: Regards, |
Thank you for the snippet. I'll try to implement it into my code. Assuming everything works fine with my current PR (#2369), would you accept a PR where I add a new AxisLabelIntersectOption like .hiddenUniform that does this? I could imagine I'm not the only one who would like their labels uniform. |
Hi @DrNiels, Thank you for your contribution and for taking the time to submit a pull request with your proposed changes. We truly appreciate your effort, and we’ll take your suggestions into consideration during our future implementation planning. Regards, |
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
Code sample
Code sample
Screenshots or Video
Screenshots / Video demonstration
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
The text was updated successfully, but these errors were encountered: