How To Change Scale Labels

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

How To Change Scale Labels

Post by Dave » Thu Mar 12, 2009 4:28 pm

Hello

Im a new user of TeeChart.

My X-axis data generally consists of very small numbers ie. along the lines 0.000067 etc.

TeeChart will usually label this as 0.

I can solve the problem by simply multiplying my x-coords by 10,000. However Ive a lot of points and several lines so this is quite processor intesive.

I was wondering whether its possible to simpy change the labels that TeeChart displays. Like to instruct TeeChart to label the X-coord as X-coord * 10,000 or some other integer that I specify.

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Thu Mar 12, 2009 5:13 pm

Hi Dave,

You can force your axis labels to be shown with the real values. For example, for 0.000067, you need 6 decimals:

Code: Select all

tChart1.Axes.Left.Labels.ValueFormat = "0.######";
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

Post by Dave » Thu Mar 12, 2009 5:25 pm

Thanks Yeray.

But there is no way I can shift the decimal point, say 4 places to the right, on the label display?

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Thu Mar 12, 2009 5:56 pm

Hi Dave,

Yes, but then you should use OnGetAxisDrawLabel event and modify/format your labels as you wish. Something as this example:

Code: Select all

        Line line1;

        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;

            line1 = new Line(tChart1.Chart);

            line1.Add(0.000056);
            line1.Add(0.000086);
            line1.Add(0.000034);
            line1.Add(0.000028);
            line1.Add(0.000042);

            tChart1.Axes.Left.Labels.ValueFormat = "0.######";

            tChart1.Axes.Left.GetAxisDrawLabel += new Steema.TeeChart.GetAxisDrawLabelEventHandler(Left_GetAxisDrawLabel);
        }

        void Left_GetAxisDrawLabel(object sender, Steema.TeeChart.GetAxisDrawLabelEventArgs e)
        {
            e.Text = (float.Parse(e.Text) * 10000).ToString();
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

Post by Dave » Fri Mar 13, 2009 12:08 pm

Thanks Yeray.Thats solved it.

Post Reply