Colorband question

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
noaksey
Newbie
Newbie
Posts: 55
Joined: Wed May 23, 2007 12:00 am

Colorband question

Post by noaksey » Mon Nov 10, 2008 4:53 pm

Hello,

I have a quick question about the colourband tool:

Is there a way of 'knowing' if a colourband start/end has moved?! The idea behind it is I would like to display the current start/end X location of the colourband as it's being dragged (it's just set to use the vertical axis).

Regards

Chris.

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 Nov 10, 2008 5:04 pm

Hi Chris,

You could use TChart's MouseMove event for that, for example:

Code: Select all

		void tChart1_MouseMove(object sender, MouseEventArgs e)
		{
			if (colorBand1.Clicked(e.X, e.Y))
			{
				this.Text = colorBand1.Start.ToString() + ", " + colorBand1.End.ToString();
			}
		}
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

noaksey
Newbie
Newbie
Posts: 55
Joined: Wed May 23, 2007 12:00 am

Post by noaksey » Tue Nov 11, 2008 12:08 pm

Hey Narcís, thanks for the reply.

Unfortunately it doesn't seem to work - when you 'click and hold' on either the Start or End of the region and then drag it somewhere, it doesn't seem to generate a mousemove event at all.

Can this be easily fixed do you know?

Regards

Chris

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 Nov 12, 2008 11:26 am

Hi Chris,

Sorry but I missed specific drag events for each ColorBandTool lines. You can do something like this:

Code: Select all

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

		private Line series;
		private ColorBand tool;
		private void InitializeChart()
		{
			tChart1.Aspect.View3D = false;
			tChart1.Series.Add(series = new Line());
			series.FillSampleValues();

			tChart1.Tools.Add(tool = new ColorBand());
			tool.Axis = tChart1.Axes.Bottom;
			tool.Start = 2;
			tool.End = 4;
			tool.ResizeEnd = true;
			tool.EndLine.DragLine += new EventHandler(EndLine_DragLine);
		}

		void EndLine_DragLine(object sender, EventArgs e)
		{
			tChart1.Header.Text = tool.End.ToString();
		}
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

noaksey
Newbie
Newbie
Posts: 55
Joined: Wed May 23, 2007 12:00 am

Post by noaksey » Wed Nov 12, 2008 12:12 pm

Good stuff - that's perfect.

Thanks for helping me on that one.

n8soft
Newbie
Newbie
Posts: 5
Joined: Thu Apr 12, 2007 12:00 am

More on Dragging Color Bands

Post by n8soft » Wed Nov 12, 2008 2:09 pm

I have a color band that is attached to the bottom axis.

I cannot figure out how to control the cursor on the drag operation. It appears that the StartLine has some default behaviour, in that the cursor changes on hover over the Start line, but does not change on the EndLine hover or drag.

Target: WPF
This behaviour also appears in the TeeChart demo Drag Color band.

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 Nov 12, 2008 2:58 pm

Hi n8soft,

Yes, you are right. I think it's StartLine's cursor that doesn't change. I've added this to the defect list (TF02013567) to be fixed for next releases. A workaround could be doing something like this:

Code: Select all

		void tChart1_MouseMove(object sender, MouseEventArgs e)
		{
			if (tool.Clicked(e.X, e.Y))
			{
				tChart1.Cursor = Cursors.VSplit;
			}
			else
			{
				tChart1.Cursor = Cursors.Default;
			}
		}
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

noaksey
Newbie
Newbie
Posts: 55
Joined: Wed May 23, 2007 12:00 am

Post by noaksey » Mon Jan 05, 2009 12:18 pm

I think there may be a bug in the Clicked method when you have zoomed in.

Best way I can describe it is if I put 3 colourbands (all vertical) on chart, spaced fairly evenly, then zoom in on a portion of the chart which will not have a colourband in it, then click anywhere in the chart, the loop I have going (in mousedown) says that a colourband has been clicked.

Can you reproduce this at all?

Regards
Chris.

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 Jan 05, 2009 12:36 pm

Hi Chris,

Yes, I could reproduce the issue here using code below and added it to the list (TF02013677) to be investigated for next releases.

Code: Select all

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

		private Steema.TeeChart.Tools.ColorBand colorBand1;
		private Steema.TeeChart.Tools.ColorBand colorBand2;
		private Steema.TeeChart.Tools.ColorBand colorBand3;

		private void InitializeChart()
		{
			tChart1.Aspect.View3D = false;

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

			colorBand1 = new Steema.TeeChart.Tools.ColorBand(tChart1.Chart);
			colorBand1.Axis = tChart1.Axes.Bottom;
			colorBand1.Start = 5;
			colorBand1.End = 15;

			colorBand2 = new Steema.TeeChart.Tools.ColorBand(tChart1.Chart);
			colorBand2.Axis = tChart1.Axes.Bottom;
			colorBand2.Start = 45;
			colorBand2.End = 55;

			colorBand3 = new Steema.TeeChart.Tools.ColorBand(tChart1.Chart);
			colorBand3.Axis = tChart1.Axes.Bottom;
			colorBand3.Start = 85;
			colorBand3.End = 95;

			tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
		}

		void tChart1_MouseMove(object sender, MouseEventArgs e)
		{
			tChart1.Cursor = colorBand1.Clicked(e.X, e.Y) ? Cursors.VSplit : Cursors.Default;
		}
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

noaksey
Newbie
Newbie
Posts: 55
Joined: Wed May 23, 2007 12:00 am

Post by noaksey » Mon Jan 05, 2009 12:47 pm

Thanks Narcís.

noaksey
Newbie
Newbie
Posts: 55
Joined: Wed May 23, 2007 12:00 am

Post by noaksey » Mon Jan 05, 2009 4:59 pm

Infact, another question for you Narcís,

is it at all possible to get, from a region's DragStart (and DragEnd) events, the region that sent it? I noticed it's a colourline for the sender; if somehow I could fetch the region that the colourline is a part of I wouldn't have to worry too much about the bug above, you see.

Cheers,
Chris.


EDIT:
Don't worry, i've done it:

Code: Select all

FieldInfo[] fi = sender.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
Delegate endDragLineDelegate;
GraphRegion gr;
FieldInfo delegateField = (from theEvent in fi where ((FieldInfo)theEvent).Name == "EndDragLine" select theEvent).SingleOrDefault();

if (delegateField != null)
{
       endDragLineDelegate = (Delegate)delegateField.GetValue(sender);
       gr = endDragLineDelegate.Target as GraphRegion;
       //gr will be the reference in this.Tools
}

noaksey
Newbie
Newbie
Posts: 55
Joined: Wed May 23, 2007 12:00 am

Post by noaksey » Thu Feb 05, 2009 4:20 pm

yet another colorband question (I seem to be making heavy use of them...)

When you move the drag the sides of a [vertical] colourband, could you make it so it triggers a MouseMove event??

On an unrelated note, can I be the first person to ask for GetNearestPoint to be public?!

Regards
Chris.

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

Post by Narcís » Fri Feb 06, 2009 10:11 am

Hi Chris,
yet another colorband question (I seem to be making heavy use of them...)
No problem but would you mind starting a new thread for each new question? Otherwise threads go off the original topic and becomes difficult to follow them.
When you move the drag the sides of a [vertical] colourband, could you make it so it triggers a MouseMove event??
There's StartLine's and EndLine's DragLine event already. You could try enabling a boolean flag there which is checked in MouseMove event and its code only being executed if the flag is true.
On an unrelated note, can I be the first person to ask for GetNearestPoint to be public?!
Well, somehow it was asked in the thread you pointed :wink:. Anyway, we made it public for the next release which will be published imminently.
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