Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 1989 - Bottom Axes label & annotation is not working
Summary: Bottom Axes label & annotation is not working
Status: RESOLVED FIXED
Alias: None
Product: .NET TeeChart
Classification: Unclassified
Component: Chart (show other bugs)
Version: TeeChart for .Net 4.1.2015.12165
Hardware: PC Windows
: --- blocker
Target Milestone: ---
Assignee: Steema Issue Manager
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-13 22:49 EST by juliana
Modified: 2018-04-05 11:33 EDT (History)
1 user (show)

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version:


Attachments
version compare (65.10 KB, image/png)
2018-02-13 22:50 EST, juliana
Details

Note You need to log in before you can comment on or make changes to this bug.
Description juliana 2018-02-13 22:49:45 EST
Hi there, 
Bottom Axes label & annotation is not working after upgrade to 4.1.2017.10190 from 4.1.2015.12160.

Source code to set bottom axes label:
tChart.Series[i].Add(dValueDays, dValue, label);

Source code to set annotation:
annotation.Text = dr["class_name"].ToString() + Environment.NewLine +
dr["bond_name"].ToString() + Environment.NewLine +
"Remaining Tenure: " + dr["remaining_years"].ToString() + " year(s)" + Environment.NewLine +
"Remaining Tenure (expected maturity): " + dr["exp_remaining_years"].ToString() + Environment.NewLine +
"Eval Mid Price: " + dr["mtm_price"].ToString() + Environment.NewLine +
"Eval Mid Yield/Discount: " + dr["mtm_ytm"].ToString();

Please refer to attachment.

Both codes is working fine in version 4.1.2015.12160.
Comment 1 juliana 2018-02-13 22:50:32 EST
Created attachment 813 [details]
version compare
Comment 2 christopher ireland 2018-02-14 13:14:43 EST
The axis label defect is a regression introduced in version 4.1.2016.10260 in the code change related to http://bugs.teechart.net/show_bug.cgi?id=1606 I can reproduce the issue with the following code:

private void InitializeChart()
{
	tChart1.Legend.Visible = false;
	Line series = new Line(tChart1.Chart);
	DateTime dt = DateTime.Today;
	int year, oldYear = 0;

	for (int i = 0; i < 10000; i++)
	{
		year = dt.Year;
		string label = year != oldYear ? year.ToString() : "";
		series.Add(dt, Math.Log(i), label);
		dt = dt.AddDays(1);
		oldYear = year;
	}

	tChart1.Axes.Bottom.Labels.Angle = 90;
}


I have fixed this regression, and in the meantime the workaround is to use repeated labels e.g.

private void InitializeChart()
{
	tChart1.Legend.Visible = false;
	Line series = new Line(tChart1.Chart);
	DateTime dt = DateTime.Today;

	for (int i = 0; i < 10000; i++)
	{
		series.Add(dt, Math.Log(i), dt.Year.ToString());
		dt = dt.AddDays(1);
	}

	tChart1.Axes.Bottom.Labels.Angle = 90;
}

The annotation defect is a regression introduced in version 4.1.2017.10190 (change for Xamarin.Forms) in code related to http://bugs.teechart.net/show_bug.cgi?id=1874. I can reproduce the issue with the following code:

private void InitializeChart()
{
	Annotation tool = new Annotation(tChart1.Chart);

	tool.Position = AnnotationPositions.Center;

	StringBuilder builder = new StringBuilder();

	for (int i = 1; i < 10; i++)
	{
		builder.Append("This is text line " + i.ToString() + " of a multi-line series" + Environment.NewLine);
	}

	tool.Text = builder.ToString();
}

We are looking into a fix for this regression, and in the meantime the workaround is to derive from the Annotation tool and override the erroneous method e.g.

public class MyAnnotation : Annotation
{
	public MyAnnotation(Chart c): base(c) { }

	protected override int CalcTempWidth(Graphics3D g, string tmp, out int numLines)
	{
		int i = tmp.IndexOf(Environment.NewLine);
		int result = 0;
		numLines = 0;

		while (i > 0)
		{
			result = Utils.Round(Math.Max(result, g.TextWidth(tmp.Substring(0, i))));
			++numLines;
			tmp = tmp.Remove(0, i + Environment.NewLine.Length);
			i = tmp.IndexOf(Environment.NewLine);
		}

		if (tmp != "")
		{
			result = Utils.Round(Math.Max(result, g.TextWidth(tmp)));
			++numLines;
		}

		return result;
	}
}
	
to use:

private void InitializeChart()
{
	MyAnnotation tool = new MyAnnotation(tChart1.Chart);

	tool.Position = AnnotationPositions.Center;

	StringBuilder builder = new StringBuilder();

	for (int i = 1; i < 10; i++)
	{
		builder.Append("This is text line " + i.ToString() + " of a multi-line series" + Environment.NewLine);
	}

	tool.Text = builder.ToString();
}