Hi there,
Is there any way to show values on ticks in a chart in scientific format? I need this option for both axis but could not figure it out using the options given. Would be great if one could make this depending on the value as well, e.g. for values larger than xxx.
Console.Write("{0:E}", 62000); => 6.200000E+004
but for axis labels ,)
Thanks,
Regards,
Robert
Formatting Numeric Axis Labels
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Robert,
Yes, there's an example of that at All Features\Welcome !\Axes\Labels\Exponent superscript in TeeChart's features demo. You'll find that demo at TeeChart's program group.
Yes, there's an example of that at All Features\Welcome !\Axes\Labels\Exponent superscript in TeeChart's features demo. You'll find that demo at TeeChart's program group.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Robert,
This is not supported by .NET's Framework as you can see [url=ms-help://MS.VSCC.2003/MS.MSDNQTR.2006JAN.1033/cpref/html/frlrfsystemdoubleclasstostringtopic3.htm]here[/url]. However, you can achieve that manually parsing labels text using the GetAxisLabel method and some code like this:
This is not supported by .NET's Framework as you can see [url=ms-help://MS.VSCC.2003/MS.MSDNQTR.2006JAN.1033/cpref/html/frlrfsystemdoubleclasstostringtopic3.htm]here[/url]. However, you can achieve that manually parsing labels text using the GetAxisLabel method and some code like this:
Code: Select all
private void Form1_Load(object sender, System.EventArgs e)
{
for (int i=0;i<=10000;i=i+10) line1.Add(i);
tChart1.Axes.Left.Labels.Exponent = true;
tChart1.Axes.Left.Labels.ValueFormat = "#.0 x10 E+0";
}
private int exponent=3;
private void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
{
if (sender==tChart1.Axes.Left)
{
if (!(e.LabelText.EndsWith("E+"+exponent.ToString())))
{
//Parsing the exponent
int ExpIndex=e.LabelText.IndexOf("E");
string CurrExpStr=e.LabelText.Substring(ExpIndex+2);
e.LabelText=e.LabelText.Replace("E+"+CurrExpStr,"E+"+exponent.ToString());
//Parsing the value
int ExpDiff=exponent-Convert.ToInt16(CurrExpStr);
int ValIndex=e.LabelText.IndexOf(" x");
string ValStr=e.LabelText.Remove(ValIndex,e.LabelText.Length-ValIndex);
double Val=Convert.ToDouble(ValStr);
Val = ExpDiff>0 ? Val/(10*ExpDiff) : Val*(10*Math.Abs(ExpDiff));
e.LabelText=e.LabelText.Replace(ValStr,Val.ToString());
}
}
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |