We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Hide/Remove labels NumericalAxis

Hi!

I use NumericalAxis with custom labels defining positions
Ex.

"Peter" "John" "Anna"

It works great!

But when I use the zoom scroll bar labels appear like this:

"Peter" 1.2 1.4 1.6 1.8 "John" 2.2 2.4 2.6 28 "Anna"

i tried this:

OnZoomChanged(object sender, ZoomChangedEventArgs e)
        {
            ((SfChart)sender).PrimaryAxis.CustomLabels.ForEach(x =>
            {
                int integer;
                Int32.TryParse(Math.Round(x.Position).ToString(), out integer);
                if (integer == 0)
                {
                    x.Position = 0;
                    x.LabelContent = "";
                }
                else
                {
                    x.Position = x.Position;
                    x.LabelContent = x.LabelContent;
                }
            });


AND


OnZoomChanged(object sender, ZoomChangedEventArgs e)
        {
            ((SfChart)sender).PrimaryAxis.VisibleLabels.ForEach(x =>
            {
                int integer;
                Int32.TryParse(Math.Round(x.Position).ToString(), out integer);
                if (integer == 0)
                {
                    x.Position = 0;
                    x.LabelContent = "";
                }
                else
                {
                    x.Position = x.Position;
                    x.LabelContent = x.LabelContent;
                }
            });

But it works more or less

3 Replies

SJ Sumathi Jayaraj Syncfusion Team May 7, 2015 09:59 AM UTC

Hi Herbert,

Thanks for contacting Syncfusion support.

When we zoom the chart, the axis interval will be changed based on the zoomed chart area. In order to control the auto interval calculation on zooming, we have to set EnableAutoIntervalOnZooming property of chart axis as “False” as shown in the below code snippet.


Code snippet [XAML]:


<chart:SfChart.PrimaryAxis>

<chart:NumericalAxisInterval="1" EnableScrollBar="True"EnableAutoIntervalOnZooming="False">

<chart:NumericalAxis.CustomLabels>

<chart:ChartAxisLabelPosition="1"LabelContent="Peter"/>

<chart:ChartAxisLabelPosition="2"LabelContent="John"/>

<chart:ChartAxisLabelPosition="3"LabelContent="Anna"/>

chart:NumericalAxis.CustomLabels>

chart:NumericalAxis>

chart:SfChart.PrimaryAxis>



Snapshot of initial loaded chart:



Snapshot after zooming:



Please let us know if you require further assistance on this.

Regards,
Sumathi J



HM Herbert Moroni Cavallari de Costa Gois May 7, 2015 06:04 PM UTC

Thank you !!

it was easy! my apologies


SJ Sumathi Jayaraj Syncfusion Team May 8, 2015 04:21 AM UTC

Hi Herbert,

Thanks for the update. Please let us know if you need any further assistance on this.

Regards,
Sumathi J

Loader.
Live Chat Icon For mobile
Up arrow icon