Page 1 of 1

Value format in the Legend...

Posted: Tue Jan 22, 2008 6:11 am
by 9640538
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~

Posted: Tue Jan 22, 2008 12:23 pm
by narcis
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?

Posted: Wed Jan 23, 2008 6:53 am
by 9640538
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;

Posted: Wed Jan 23, 2008 11:07 am
by narcis
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);
	}

Posted: Fri Jan 25, 2008 1:05 pm
by 9640538
i c,

it works, thanks~ ^^