Page 1 of 1

How To Change Scale Labels

Posted: Thu Mar 12, 2009 4:28 pm
by 13050364
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.

Posted: Thu Mar 12, 2009 5:13 pm
by yeray
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.######";

Posted: Thu Mar 12, 2009 5:25 pm
by 13050364
Thanks Yeray.

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

Posted: Thu Mar 12, 2009 5:56 pm
by yeray
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();
        }

Posted: Fri Mar 13, 2009 12:08 pm
by 13050364
Thanks Yeray.Thats solved it.