Value format in the Legend...

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
shangwei
Newbie
Newbie
Posts: 5
Joined: Mon Mar 06, 2006 12:00 am
Contact:

Value format in the Legend...

Post by shangwei » Tue Jan 22, 2008 6:11 am

Hi,

I'm using TeeChart v2 in C#.Net.

I want to show the series value in the Legend in WebChart.
I have set
ch1.Legend.LegendStyle = LegendStyles.Values;
ch1.Axes.Bottom.Labels.DateTimeFormat = "yyyy-MM";
The data series are set up at run time.

But when the chart first loaded the legend is like '-- 35.2356 2.05', which actually should be like '-- 1997-01 2.05'. If perform some zoom actions, the legend will turned to currect date format.

Is there any additional settings should be made to get the currect date format in legend when it first loaded?

Thanks a lot~

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Jan 22, 2008 12:23 pm

Hi shangwei,

This works fine for me here using latest TeeChart for .NET v2 release available at the client download area (Build 2.0.2887.28039/40) and this code:

Code: Select all

	protected void Page_Load(object sender, EventArgs e)
	{
		Steema.TeeChart.Chart ch1 = WebChart1.Chart;

		Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(ch1);

		line1.XValues.DateTime = true;
		line1.YValues.DateTime = true;

		for (int i = 1; i < 13; i++)
		{
			line1.Add(DateTime.Parse("01/" + i.ToString() + "/2008"), DateTime.Parse("01/" + i.ToString() + "/2008"));
		}

		ch1.Legend.LegendStyle = Steema.TeeChart.LegendStyles.Values;
		ch1.Axes.Bottom.Labels.DateTimeFormat = "yyyy-MM"; 
	}
Could you please check if it works fine at your end?
Best Regards,
Narcís Calvet / 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

shangwei
Newbie
Newbie
Posts: 5
Joined: Mon Mar 06, 2006 12:00 am
Contact:

Post by shangwei » Wed Jan 23, 2008 6:53 am

Thanks, these code works fine.

But what I need is to show both X and Y values in the legend.

plz try if the following code is added, the date format of the first value in each legend item becomes incorrect..

ch1.Legend.TextStyle = Steema.TeeChart.LegendTextStyles.XAndValue;

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Jan 23, 2008 11:07 am

Hi shangwei,

Yes, that's true, I've added this problem to our defect list (TF02012761) to be fixed for future releases. In the meantime, as a workaround, you can use legend's GetText event as shown here:

Code: Select all

	protected void Page_Load(object sender, EventArgs e)
	{
		Steema.TeeChart.Chart ch1 = WebChart1.Chart;

		Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(ch1);

		line1.XValues.DateTime = true;
		line1.YValues.DateTime = true;

		for (int i = 1; i < 13; i++)
		{
			line1.Add(DateTime.Parse("01/" + i.ToString() + "/2008"), DateTime.Parse("01/" + i.ToString() + "/2008"));
		}

		//ch1.Legend.LegendStyle = Steema.TeeChart.LegendStyles.Values;
		ch1.Legend.TextStyle = Steema.TeeChart.LegendTextStyles.XAndValue;
		ch1.Axes.Bottom.Labels.DateTimeFormat = "yyyy-MM";

		WebChart1.GetLegendText += new Steema.TeeChart.GetLegendTextEventHandler(WebChart1_GetLegendText);
	}

	void WebChart1_GetLegendText(object sender, Steema.TeeChart.GetLegendTextEventArgs e)
	{
		string tmpStr = e.Text.Substring(0, 6); ;
		e.Text = DateTime.FromOADate(Convert.ToDouble(tmpStr)).ToShortDateString() + e.Text.Remove(0,6);
	}
Best Regards,
Narcís Calvet / 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

shangwei
Newbie
Newbie
Posts: 5
Joined: Mon Mar 06, 2006 12:00 am
Contact:

Post by shangwei » Fri Jan 25, 2008 1:05 pm

i c,

it works, thanks~ ^^

Post Reply