Problem with Axis Title Position

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Mahadevan
Newbie
Newbie
Posts: 25
Joined: Thu Mar 12, 2009 12:00 am

Problem with Axis Title Position

Post by Mahadevan » Mon Mar 16, 2009 8:30 am

Hi,

There seems to be a problem with the positioning of the Title of the Axis if we use event handler Chart.GetAxisLabel.

We have a really long axes labels, so what we do is we have an event handler for GetAxisLabel and in that if the label is longer than a certain value, we clip it to a fixed lenght.

Even after clipping what we noticed is that the Axis titles is positioned based on the actual length of the data but not based on the new values.

Please let me know how to get the axis titles positioned properly at the right place.

The following code can be used to reproduce the problem:

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

public DataTable GetDataTable()
{
DataTable dt = new DataTable("SampleData");

dt.Columns.Add("LABEL", typeof(string));
dt.Columns.Add("COUNT", typeof(int));
dt.Columns.Add("RADIUS", typeof(int));

dt.Rows.Add("Pears", 2, 10);
dt.Rows.Add("Apples", 25, 11);
dt.Rows.Add("Oranges", 3, 0);
dt.Rows.Add("Test", 8, 1);
dt.Rows.Add("Really Long text used as an axis label which would be clipped", 13, 1);
dt.AcceptChanges();
return dt;
}

private void Form1_Load(object sender, EventArgs e)
{
DataTable dt = GetDataTable();
foreach (DataRow r in dt.Rows)
{
bar1.Add((int)r["COUNT"], r["LABEL"].ToString());
}
tChart1.GetAxisLabel += new Steema.TeeChart.GetAxisLabelEventHandler(tChart1_GetAxisLabel);
tChart1.Axes.Bottom.Title.Text = "Some title";
}

void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
{
string LsLabelText = e.LabelText;

string LsExtnString = "...";
int LiLabelLength = 30;

// If the label length is greater than the configured value
if (LsLabelText.Length > LiLabelLength)
{
LsLabelText = LsLabelText.Substring(0, LiLabelLength - LsExtnString.Length);
LsLabelText += LsExtnString;
e.LabelText = LsLabelText;
}
}

}

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

Post by Yeray » Mon Mar 16, 2009 12:05 pm

Hi Mahadevan,

Could you tell us what TeeChart build are you using? Here, with actual sources it seems to work fine.

Maybe there are some special characteristics that you skipped to explain (form fill, chart fill,...) and maybe that's why we can't reproduce it here. So it would be better if you could send us a simple example project we can run "as-is" to reproduce the problem here?
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
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

Mahadevan
Newbie
Newbie
Posts: 25
Joined: Thu Mar 12, 2009 12:00 am

Post by Mahadevan » Tue Mar 17, 2009 10:43 am

I have uploaded the file to http://www.steema.net/upload/Default.aspx, name of the file is TeeChartAxes.zip I am using version 3.5.3330.21114 of the TeeChart.

Let me know if you need some more information.

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

Post by Yeray » Tue Mar 17, 2009 12:08 pm

Hi Mahadevan,

Yes, the problem appears because you are trying to draw your bottom axis labels rotated. And then, when the axis label is updated, the chart margin isn't recalculated but it should. That's a known bug already in the wish list (TF02013509). It's discussed here.
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

Mahadevan
Newbie
Newbie
Posts: 25
Joined: Thu Mar 12, 2009 12:00 am

Post by Mahadevan » Tue Mar 17, 2009 12:14 pm

Can you suggest a work around for this, so that the axes titles appear correctly?

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

Post by Yeray » Tue Mar 17, 2009 12:48 pm

Hi Mahadevan,

Maybe you could add the filter after adding your points instead of on GetAxisLabel event:

Code: Select all

string LsLabelText;
string LsExtnString = "...";
int LiLabelLength = 30;

for (int i = 0; i < bar1.Labels.Count; i++)
{
    LsLabelText = bar1.Labels[i];

    if (bar1.Labels[i].Length > LiLabelLength)
    {
        LsLabelText = LsLabelText.Substring(0, LiLabelLength - LsExtnString.Length);
        LsLabelText += LsExtnString;
        bar1.Labels[i] = LsLabelText;
    }    
}
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

Mahadevan
Newbie
Newbie
Posts: 25
Joined: Thu Mar 12, 2009 12:00 am

Post by Mahadevan » Mon May 18, 2009 7:50 am

Can you please let me know when a fix for this would be available?

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

Post by Narcís » Mon May 18, 2009 9:30 am

Hi Mahadevan,

This has already been fixed for next v3 maintenance release due to be published very soon.
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

Mahadevan
Newbie
Newbie
Posts: 25
Joined: Thu Mar 12, 2009 12:00 am

Post by Mahadevan » Wed May 20, 2009 12:05 pm

Hi,

Seems like the problem is not fixed in the release 3.5.3425.20245.
(Issue is not mentioned in the release notes and also when tried with the above mentioned release, problem persists)
Can you let me know the time line by the fix would be available?

Thanks And Regards,
Mahadevan

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 May 20, 2009 2:05 pm

Hi Mahadevan,

Code below works fine for me here using build 3.5.3425.20245. Can you please check if the TeeChart.dll reference in your project was updated correctly and if code below works fine?

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}

		private void InitializeChart()
		{
			tChart1.Legend.Visible = false;

			Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);

			string label = "this is a very long label for testing";

			line1.Add(3, label);
			line1.Add(5, label);
			line1.Add(7, label);
			line1.Add(2, label);

			tChart1.GetAxisLabel +=new Steema.TeeChart.GetAxisLabelEventHandler(tChart1_GetAxisLabel);
			tChart1.Axes.Bottom.Labels.Angle = 90;
		}

		void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
		{
			if (sender.Equals(tChart1.Axes.Bottom))
			{
				if (e.LabelText.Length > 15)
				{
					e.LabelText = string.Format("{0}{1}", e.LabelText.Substring(0, 15), "...");
				}
			}
		}
Thanks in advance.
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

Mahadevan
Newbie
Newbie
Posts: 25
Joined: Thu Mar 12, 2009 12:00 am

Post by Mahadevan » Fri May 22, 2009 1:04 pm

Hi,
Looks like the problem is not solved completely.
If the default chart size is used then only it seems to be working.

If the chart size is set using the properties of Chart, then the labels are missing again.

Ex:
WebChart3.Width = 800;
WebChart3.Height = 600;

To reproduce the problem, use the file TeeChartAxes.zip uploaded to location http://www.steema.net/upload/Default.aspx

Thanks And Regards,
Mahadevan

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

Post by Yeray » Fri May 22, 2009 4:04 pm

Hi Mahadevan,

I've tested your project with the latest TeeChart NET v3 sources (that still have no changes since the last release was published) and the result seems to be satisfactory:

Image

Is that the same result you are getting? And, isn't it the desired result?
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

Mahadevan
Newbie
Newbie
Posts: 25
Joined: Thu Mar 12, 2009 12:00 am

Re: Problem with Axis Title Position

Post by Mahadevan » Thu Jul 23, 2009 9:05 pm

Hello Yeray,
That is not the expected behaviour.

As you can see from the graph, Axis Titles are rotated to 90 degrees so that the length of the label
doesnt affect the adjacent label.

Even though there is enough space available for all the labels, only alternate labels are visible,
I would expect all the labels to be visible in this case.

Thanks And regards,
Mahadevan

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

Re: Problem with Axis Title Position

Post by Narcís » Fri Jul 24, 2009 3:11 pm

Hi Mahadevan,

Yes, this is a known issue (TF02013544). In that case you should use custom labels as shown here:

Code: Select all

    protected void Page_Load(object sender, EventArgs e)
    {
		
			// Third Chart
			WebChart3.GetAxisLabel += new Steema.TeeChart.GetAxisLabelEventHandler(tChart1_GetAxisLabel);
			
			DataTable dt = GetSignOffData();
			WebChart3.Chart.Axes.Bottom.Labels.Angle = 90;
			WebChart3.Chart.Legend.Visible = false;
			Bar signoffSeries = new Bar();
			signoffSeries.Title = "Completed";
			signoffSeries.Marks.Visible = false;
			WebChart3.Chart.Series.Clear();
			WebChart3.Chart.Series.Add(signoffSeries);
			signoffSeries.ColorEach = true;
			signoffSeries.BarStyle = BarStyles.RectGradient;
			foreach (DataRow row in dt.Rows)
			{
				string label = (string)row["Name"];
				signoffSeries.Add((int)row["Completed"], label);
			}

			// Comment this and the Axis Labels are fine
			WebChart3.Width = 800;
			WebChart3.Height = 600;

			WebChart3.Chart.Axes.Bottom.Labels.Items.Clear();

			for (int i = 0; i < signoffSeries.Count; i++)
			{
				WebChart3.Chart.Axes.Bottom.Labels.Items.Add(signoffSeries.XValues[i], ProcessLabel(signoffSeries.Labels[i]));
			}
		
    }


	private DataTable GetSignOffData()
	{
		DataTable dt = new DataTable("SignoffData");

		dt.Columns.Add("Name", typeof(string));
		dt.Columns.Add("Completed", typeof(int));
		dt.Columns.Add("NotCompleted", typeof(int));
		dt.Columns.Add("Total", typeof(int));

		dt.Rows.Add("Disciplinary actions send a message that violations of expected behavior will not be tolerated", 1, 0, 1);
		dt.Rows.Add("An ongoing education process enables people to deal effectively with the evolving business environments.*", 1, 0, 1);
		dt.Rows.Add("The company establishes and enforces standards for hiring the most qualified individuals, with emphasis on educational background, prior work experience, past accomplishments and evidence of integrity and ethical behavior.", 0, 4, 4);
		dt.Rows.Add("Recruiting practices which include formal, in-depth employment interviews and informative insightful presentations on an entity's history, culture and operating style demonstrate the entity's commitment to its employees and its attitude toward a sound control environment.", 1, 0, 1);
		dt.Rows.Add("Training policies communicate prospective roles and responsibilities and illustrate expected levels of performance and behavior.", 0, 3, 3);
		dt.Rows.Add("Rotation of personnel and promotions driven by periodic performance appraisals demonstrate the entity's commitment to the advancement of qualified personnel to higher levels of responsibility.", 0, 4, 4);
		dt.AcceptChanges();
		return dt;
	}	

	void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
	{
		//ProcessLabel(e.LabelText);
	}

	private static string ProcessLabel(string label)
	{
		string LsLabelText = label;

		string LsExtnString = "...";
		int LiLabelLength = 30;

		// If the label length is greater than the configured value
		if (LsLabelText.Length > LiLabelLength)
		{
			LsLabelText = LsLabelText.Substring(0, LiLabelLength - LsExtnString.Length);
			LsLabelText += LsExtnString;
		}

		return LsLabelText;
	}
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

Post Reply