Page 1 of 2

Custom labels on Z Axis

Posted: Mon Jul 07, 2008 11:40 am
by 13047268
Hi,

How can I supply custom labels on the Z axis when using a 3D surface series?

Thanks
Andy

Posted: Mon Jul 07, 2008 1:26 pm
by narcis
Hi Andy,

You can use custom labels like this:

Code: Select all

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

		private void InitializeChart()
		{
			Steema.TeeChart.Styles.Surface surface1 = new Steema.TeeChart.Styles.Surface(tChart1.Chart);

			surface1.FillSampleValues();

			tChart1.Axes.Depth.Visible = true;
			tChart1.Axes.Depth.Labels.Items.Clear();

			for (double i = surface1.MinZValue(); i < surface1.MaxZValue(); i++)
			{
				tChart1.Axes.Depth.Labels.Items.Add(i, i.ToString());
			}
		}
Or use GetAxisLabel event:

Code: Select all

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

		private void InitializeChart()
		{
			Steema.TeeChart.Styles.Surface surface1 = new Steema.TeeChart.Styles.Surface(tChart1.Chart);

			surface1.FillSampleValues();

			tChart1.Axes.Depth.Visible = true;
			tChart1.GetAxisLabel += new Steema.TeeChart.GetAxisLabelEventHandler(tChart1_GetAxisLabel);
		}

		void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
		{
			if (sender == tChart1.Axes.Depth)
			{
				e.LabelText = "hi!";
			}
		}

Posted: Mon Jul 07, 2008 3:18 pm
by 13047268
Hi,

Thanks for that. That solves part of my problem.

I've noticed though that the GetAxisDrawLabel event doesn't seem to be fired for this axis?

I'm subscribing like so:
m_teeChart.Axes.Depth.GetAxisDrawLabel += new GetAxisDrawLabelEventHandler(Handle_GetAxisDrawLabel);

Thanks
Andy

Posted: Tue Jul 08, 2008 7:31 am
by narcis
Hi Andy,

Have you tried setting depth axis to visible like in the code snippet I used?

BTW: You can also generate the event at designtime.

Posted: Tue Jul 08, 2008 8:16 am
by 13047268
Hi,

Yep I tried setting the depth axes to visible but it had no effect. The axes is showing fine but just not firing the event which I need. it works fine for the x and y axes but not the z (depth).

Can you confirm if this is a bug or not as soon as possible?

Thanks
Andy

Posted: Tue Jul 08, 2008 8:32 am
by narcis
Hi Andy,

It worked fine for me here using latest TeeChart for .NET v3 release available at the client area and the code snippet above. Which TeeChart version are you using?

If the problem persists could you please 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.

Thanks in advance.

Posted: Tue Jul 08, 2008 9:26 am
by 13047268
Hi,

Just downloaded the latest teechart (3.5.3105.20151) and the GetAxisDrawLable event is still not fired for the depth axes.

I have uploaded a sample (TeeChartBugTest.zip) to your uploads area that demonstrates this. The sample basically consists of the following code:

Code: Select all

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

			surface1.FillSampleValues();
			tChart1.Axes.Depth.Visible = true; 
			tChart1.Axes.Depth.GetAxisDrawLabel += new Steema.TeeChart.GetAxisDrawLabelEventHandler(Depth_GetAxisDrawLabel);
			tChart1.Axes.Bottom.GetAxisDrawLabel += new Steema.TeeChart.GetAxisDrawLabelEventHandler(Bottom_GetAxisDrawLabel);
			tChart1.Axes.Left.GetAxisDrawLabel += new Steema.TeeChart.GetAxisDrawLabelEventHandler(Left_GetAxisDrawLabel);

		}

		void Left_GetAxisDrawLabel(object sender, Steema.TeeChart.GetAxisDrawLabelEventArgs e)
		{
			e.Text = "left";
		}

		void Bottom_GetAxisDrawLabel(object sender, Steema.TeeChart.GetAxisDrawLabelEventArgs e)
		{
			e.Text = "bottom";
		}

		void Depth_GetAxisDrawLabel(object sender, Steema.TeeChart.GetAxisDrawLabelEventArgs e)
		{
			e.Text = "depth";
		}
the left and bottom axes area set correct but the depth one is not.

Thanks
Andy

Posted: Tue Jul 08, 2008 10:29 am
by narcis
Hi Andy,

Thanks for the information. I could reproduce the issue here and added it (TF02013195) to the bug list to be fixed for future releases.

In the meantime you can use GetAxisLabel event instead, for example:

Code: Select all

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

		private void InitializeChart()
		{
			Steema.TeeChart.Styles.Surface surface1 = new Steema.TeeChart.Styles.Surface(tChart1.Chart);
			surface1.FillSampleValues();
			tChart1.Axes.Depth.Visible = true;
			tChart1.GetAxisLabel += new Steema.TeeChart.GetAxisLabelEventHandler(tChart1_GetAxisLabel);
		}

		void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
		{
			if (sender == tChart1.Axes.Left)
			{
				e.LabelText = "Left";
			}
			else
			{
				if (sender == tChart1.Axes.Bottom)
				{
					e.LabelText = "Bottom";
				}
				else
				{
					if (sender == tChart1.Axes.Depth)
					{
						e.LabelText = "Depth";
					}
				}
			}
		}

Posted: Tue Jul 08, 2008 10:37 am
by 13047268
But GetAxisLabel isn't called for custom labels!

The reason I was using GetAxisDrawLabel was to provide my own logic for stopping custom labels overwrite each other when drawn close together. This works pretty well for x and y in both 2D and 3D but obviously now I can't do z when in 3D.

Posted: Tue Jul 08, 2008 10:45 am
by narcis
Hi Andy,

In that case I recommend you to read this thread. Please notice this is quite a long thread (has several pages) and what you are looking for may not appear in the first posts. However, several possibilities were discussed there.

Posted: Tue Jul 08, 2008 10:53 am
by 13047268
I read that thread originally.

Most of the methods weren't suitable or gave slightly dubious results. The only method that was close was the the GetAxisDrawLabel although that needed some tweaking to give some decent results.

Can you explain why this isn't supported natively in the chart. The algorithm is quite simple and I can't imagine many occasions you would want labels to overlap at all.

1. Always draw the first label
2. If the next label will overlap the last drawn label then don't draw it
3. repeat 2 until complete.

Thats basically what I do and it works fine.

Posted: Wed Jul 09, 2008 9:45 am
by narcis
Hi Andy,

TeeChart's default labels already support anti-overlapping. Not everybody expects the same of custom labels and we have been asked for the possibility to overlap so custom labels positioning decision is left to the user.

Posted: Wed Jul 09, 2008 9:56 am
by 13047268
But don't you think it makes sense you have the option of using teeCharts built in overlapping logic on custom labels?

Seems a crazy waste of effort for any developer using teechart to basically duplicate the same code as you have especially.

Can I raise this as an official feature request please.

Also do you have an estimate of when the bug with depths getaxisdrawlabel will be fixed.

thanks
Andy

Posted: Fri Jul 11, 2008 11:33 am
by narcis
Hi westacotta,

There are no short term plans to add overlap checks on Custom Labels though it has been added as a feature request for review. GetAxisDrawLabel event support has been added to the DepthAxis to be included with the next maintenance release.

Posted: Fri Jul 11, 2008 12:35 pm
by 13047268
ok thanks.

any idea when the next maintenance release will be?