Custom Axis label format

TeeChart for ActiveX, COM and ASP
Post Reply
Angelo
Newbie
Newbie
Posts: 14
Joined: Wed Mar 04, 2009 12:00 am

Custom Axis label format

Post by Angelo » Mon Feb 28, 2011 4:23 pm

Hi everybody.


I am trying to work with axis labels and I would like to have the values formatted as scientific notation like as:

1.3x10-2 (-2 in superscript) instead of 1.3E-2.

Is there an easy way to do that ?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Custom Axis label format

Post by Sandra » Tue Mar 01, 2011 11:12 am

Hello Angelo,

I recommend take a look to TeeChart Activex Demo project concretely to All Features\Axes\Labels\Exponent super-script. If you have any problem, please let me know.

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Angelo
Newbie
Newbie
Posts: 14
Joined: Wed Mar 04, 2009 12:00 am

Re: Custom Axis label format

Post by Angelo » Tue Mar 01, 2011 11:49 am

Hi Sandra. I checked that example and tried it, but it does not work accordingly.

Suppose I have the following data (X,Y)


(11,0.0005324)
(37,0.0007876)
(40,0.0010203)

if formatted as: "0.000E+0" the Y axis labels should be displayed as:

5.324x10(-4)
7.876x10(-4)
1.020x10(-3)

where (-4) and (-3) are the superscripts. The axis labels should be as written as above, but I it is not displayed because the format string "E-0" is not converted to "x10(-n)" where n is the superscript.

A "ugly" workaround for this I did setting the formatvalue="0.000x1OE-0" where I changed a "0" by "O" so I get:

5.324x1O(-4)
7.876x1O(-4)
1.020x1O(-3)

Angelo
Newbie
Newbie
Posts: 14
Joined: Wed Mar 04, 2009 12:00 am

Re: Custom Axis label format

Post by Angelo » Tue Mar 01, 2011 6:23 pm

Hi Sandra I just noticed that the problem also occurs with the demo !!!

See the legend and the vertical axis labels !

Image

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

Re: Custom Axis label format

Post by Yeray » Wed Mar 02, 2011 10:09 am

Hi Angelo,

The following code seems to work fine for me here:

Code: Select all

Private Sub Form_Load()  
  TChart1.Aspect.View3D = False
  
  TChart1.AddSeries scPoint
  TChart1.Series(0).AddXY 11, 0.0005324, "", clTeeColor
  TChart1.Series(0).AddXY 37, 0.0007876, "", clTeeColor
  TChart1.Series(0).AddXY 40, 0.0010203, "", clTeeColor
  
  TChart1.Axis.Left.Labels.ValueFormat = "#.000 ""x10"" E+0"
  TChart1.Axis.Left.Labels.Exponent = True
End Sub

Private Sub TChart1_OnGetLegendText(ByVal LegendStyle As Long, ByVal ValueIndex As Long, LegendText As String)
  If LegendStyle = lsValues Then
    LegendText = Format$(TChart1.Series(0).YValues.Value(ValueIndex), "#.000 ""x10"" E+0")
  End If
End Sub
In TeeChart v2010 there is an AxisStyle named PointValue, only available at designtime for now. With it and the code above, the chart looks as follows:
Chart.png
Chart.png (7.78 KiB) Viewed 12053 times
In v7, the same code produces the following result:
Chart2.png
Chart2.png (8.73 KiB) Viewed 12047 times
And zooming around the second point, it looks as follows:
Chart3.png
Chart3.png (8.52 KiB) Viewed 12045 times
Isn't it what you are trying to achieve?
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

Post Reply