Page 1 of 1

Issue with AxisBreaksTool

Posted: Sun Apr 22, 2012 3:41 pm
by 15660231
Hi,

I'm trying to use the AxisBreaksTool to hide a particular area on the chart. i.e., particular range of values on the Y-Axis.
But the tChart1.Axes.Left.CalcPosPoint() method malfunctions after adding an AxisBreak.

Here is the sample code for your reference.

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Steema.TeeChart.Styles;
using Steema.TeeChart.Tools;

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

			tChart1.Aspect.View3D = false;
		}

		private void Form1_Load(object sender, EventArgs e)
		{
			FastLine series = new FastLine(tChart1.Chart);
			FillSampleValues(series, 100);

			tChart1.Axes.Left.SetMinMax(1, 10);
			tChart1.Zoom.Allow = false;
			axisBreaksTool1.GapSize = 0;
		}

		private void FillSampleValues(FastLine series, int count)
		{
			Random r = new Random(0);
			for (int i = 1; i <= count; i++)
			{
				series.Add(i, r.Next(100));
			}
		}

		private void tChart1_MouseDown(object sender, MouseEventArgs e)
		{
			if (e.Button == System.Windows.Forms.MouseButtons.Left)
			{
				double minimum = 1;
				double maximum = 10;

				// NOTE: This is where the problem occurs.
				double yValue = tChart1.Axes.Left.CalcPosPoint(e.Y);

				if (yValue >= maximum)
				{
					// If the user has clicked on or above the top edge of the chart, 
					// apply a break from 9-10
					minimum = 9;
				}
				else
				{
					minimum = Math.Floor(yValue);
					maximum = minimum + 1;
				}

				MessageBox.Show(minimum + " --> " + maximum);
				AxisBreak categoryBreak = new AxisBreak(axisBreaksTool1);
				categoryBreak.StartValue = minimum;
				categoryBreak.EndValue = maximum;
				categoryBreak.Style = AxisBreakStyle.None;
				categoryBreak.Enabled = true;
			}
			else if (e.Button == System.Windows.Forms.MouseButtons.Right)
			{
				axisBreaksTool1.Breaks.Clear();
			}
		}
	}
}

What I'm trying to do is:
1. Display a chart with YRange 1-10.
2. Whenever user clicks on the chart, capture the mouse position and find the corresponding Y value on the left axis using
double yValue = tChart1.Axes.Left.CalcPosPoint(e.Y)
3. Based on the yValue hide a particular region on the left axis. Say if the user has clicked on 5.5, then hide the range 5-6 in the left axis.
4. Clear the breaks on right click.

This works fine if I click on 5.5 first and then click on 4.5, then 3.5 etc.,
But tChart1.Axes.Left.CalcPosPoint() gives invalid Y Values when I do it in vice versa. i.e., first 3.5 and then 4.5.

Could you please help me out on this ?
Is there any other way through which I can achieve this functionality ?
Thanks in advance.

Re: Issue with AxisBreaksTool

Posted: Mon Apr 23, 2012 10:36 am
by narcis
Hi Arthur,

I'm afraid this is a bug, which I have added to the defect list (TF02016163) to be fixed for future releases. There's no workaround I can think of for now.

Re: Issue with AxisBreaksTool

Posted: Mon Apr 23, 2012 11:13 am
by 15660231
Hi Narcis,

Thanks for your reply. Will I be notified, in case this bug is fixed in the upcoming release ?

Re: Issue with AxisBreaksTool

Posted: Mon Apr 23, 2012 11:21 am
by narcis
Hi Arthur,

You should be aware/subscribe to any of the Steema Software communication channels (this forum, Steema's home page, Steema's RSS feed, twitter or facebook) for new release announcements and what's implemented on them at the release notes accompanying the news, for example: http://www.teechart.net/support/viewtop ... =4&t=13090.

Thanks in advance.