This is a migrated thread and some comments may be shown as answers.

RadChart zoom axis labels

5 Answers 138 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
fredn
Top achievements
Rank 1
fredn asked on 24 Oct 2008, 08:47 AM
Hello,

I have a problem with the axis label and zooming functionnality.
Indeed, just consider that I have a chart with a curve ( type = Line ) and the axis bounds are :
X : 50 to 100 with a step of 5
Y: 0 to 2.8 with a step of 0.28

If I zoom, the problem is that the chart doesn't compute new steps and my axis label  are not signifiants.
My goal would be, when I zoom, to re-compute the steps using XScale and YScale. For this, I tried to do this computing inside the OnBeforeLayout event like this :

RadChart1.PlotArea.XAxis.Step = m_originalStepX / RadChart1.ClientSettings.XScale; 
RadChart1.PlotArea.YAxis.Step = m_originalStepY / RadChart1.ClientSettings.YScale; 

But, the problem is that the axis labels are no more aligned with the curve. There is a shift in X and Y.

How can I achieve this ? Is there a simpliest way to change the axis step, and this new step matches the curves ?

Thanks in advance.

5 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 27 Oct 2008, 05:44 PM
Hi bronv,

Please, use an event which is fired earlier in the control lifecycle. This could be Load or PreRender. At the time BeforeLayout is fired, the calculations in the chart have already been made, so you can change the text of the labels, but not their values.

Hope this helps.

Greetings,
Ves
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
fredn
Top achievements
Rank 1
answered on 29 Oct 2008, 04:16 PM

Hi,

The PreRender event did the job, it has fixed the shifting.

But now I have a strange behavior, only for the X axis. When I zoom, quite deep, the X axis becomes "noisy". It looks like this :

291.325  291.48  291.635  291.9999999999999999999999999999999

I have simulate by "99999999999..." the fact that every characters are overlapping, and it is unreadable. It looks like at a level of zoom it cannot manage to display the values...

I have an XScale of 20.0 and a step of 0.155.

Could you help me please ?

Thanks.

0
Ves
Telerik team
answered on 31 Oct 2008, 07:29 AM
Hello bronv,

Indeed, this might happen as the axis item values are with double precision. Still, you can utilize the CustomFormat property and set it to any Standard Numeric Format String, here is an example:

RadChart1.PlotArea.XAxis.Appearance.CustomFormat = "F2";

Best regards,
Ves
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
fredn
Top achievements
Rank 1
answered on 04 Nov 2008, 09:03 AM

Hi,

As usual your answer was correct, it fixed the overlapping.

Last question ( I think ), concerning the Axis label textblock, when I zoom the text disappears because it follows the zoom factor. How can I set a text ( to display the unit of the axis for example ) that is not dependent on the zoom factor ?

Thanks in advance.

0
Ves
Telerik team
answered on 07 Nov 2008, 07:30 AM
Hello,

Indeed, the chart label will scroll along with the axis, so it may be hidden, this depends on the axis position. A possible workaround is to wire BeforeLayout event and modify each ChartAxisItem text:

protected void RadChart1_BeforeLayout(object sender, EventArgs e) 
    { 
        foreach (ChartAxisItem item in RadChart1.PlotArea.XAxis.Items) 
        { 
            item.TextBlock.Text += "unit"; 
        } 
    } 

I hope this is applicable.

All the best,
Ves
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Chart (Obsolete)
Asked by
fredn
Top achievements
Rank 1
Answers by
Ves
Telerik team
fredn
Top achievements
Rank 1
Share this question
or