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.
Unfortunately, activation email could not send to your email. Please try again.

Hide/Remove labels NumericalAxis

Thread ID:

Created:

Updated:

Platform:

Replies:

119051 May 6,2015 10:00 AM May 8,2015 12:21 AM WPF 3
loading
Tags: SfChart
Herbert Moroni Cavallari de Costa Gois
Asked On May 6, 2015 10:00 AM

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

Sumathi Jayaraj [Syncfusion]
Replied On May 7, 2015 05:59 AM

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


Herbert Moroni Cavallari de Costa Gois
Replied On May 7, 2015 02:04 PM

Thank you !!

it was easy! my apologies

Sumathi Jayaraj [Syncfusion]
Replied On May 8, 2015 12:21 AM

Hi Herbert,

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

Regards,
Sumathi J

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;