MultiLine Marks

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Dec 04, 2008 11:14 am

Hi Luke,

The only way I can think of to achieve that is using Annotation tools instead of marks like this:

Code: Select all

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

		void InitializeChart()
		{
			tChart1.Aspect.View3D = false;
			Steema.TeeChart.Styles.ColorGrid colorGrid1 = new Steema.TeeChart.Styles.ColorGrid(tChart1.Chart);
			colorGrid1.Marks.Visible = true;
			colorGrid1.FillSampleValues();

			colorGrid1.GetSeriesMark += new Steema.TeeChart.Styles.Series.GetSeriesMarkEventHandler(colorGrid1_GetSeriesMark);
			tChart1.BeforeDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_BeforeDraw);
			tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
			tChart1.Draw();
		}

		void tChart1_BeforeDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			tChart1[0].Marks.Visible = true;
			tChart1.Tools.Clear();
		}

		void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			tChart1[0].Marks.Visible = false;
		}

		void colorGrid1_GetSeriesMark(Steema.TeeChart.Styles.Series series, Steema.TeeChart.Styles.GetSeriesMarkEventArgs e)
		{
			if ((e.ValueIndex >= 0) && (e.ValueIndex < series.Marks.Positions.Count))
			{
				Steema.TeeChart.Styles.SeriesMarks.Position mp = series.Marks.Positions[e.ValueIndex];
				if (mp != null)
				{
					Steema.TeeChart.Tools.Annotation anno1 = new Steema.TeeChart.Tools.Annotation(tChart1.Chart);

					anno1.Text = e.MarkText;
					anno1.Shape.CustomPosition = true;
					anno1.Shape.Left = mp.LeftTop.X;
					anno1.Shape.Top = mp.LeftTop.Y;

					if (e.ValueIndex % 2 == 0)
					{
						anno1.Shape.Font.Color = Color.White;
						anno1.Shape.Color = Color.Black;
					}
					else
					{
						anno1.Shape.Font.Color = Color.Black;
						anno1.Shape.Color = Color.White;
					}  
				}
			}
		}
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

Luke
Newbie
Newbie
Posts: 68
Joined: Thu Oct 11, 2007 12:00 am

Post by Luke » Thu Dec 04, 2008 12:36 pm

The Marks dont dissapear even with the Afterdraw setting marks visible to false. Also resize of chart does not seem to alwys update the position of the annotations.

Thx

Luke

Luke
Newbie
Newbie
Posts: 68
Joined: Thu Oct 11, 2007 12:00 am

Post by Luke » Thu Dec 04, 2008 12:44 pm

Better to set the font color to tranparent for the marks, you dont need the redraw/draw events then.

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

Post by Narcís » Thu Dec 04, 2008 12:53 pm

Hi Luke,

So I see. In that case you can set marks to be transparent:

Code: Select all

			colorGrid1.Marks.Transparent = true;
			colorGrid1.Marks.Font.Color = Color.Transparent;
Don't forget Draw() method call at the end of the InitializeChart() method. For Annotations to refresh on chart zoom, scroll, resize, etc. You should also call Draw() in respective events. Marks need to be painted so that their new positions are calculated and then be used to set Annotation's position. Code below works fine for me here.

Code: Select all

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

		void InitializeChart()
		{
			tChart1.Dock = DockStyle.Fill;
			tChart1.Aspect.View3D = false;
			Steema.TeeChart.Styles.ColorGrid colorGrid1 = new Steema.TeeChart.Styles.ColorGrid(tChart1.Chart);
			colorGrid1.Marks.Visible = true;
			colorGrid1.Marks.Transparent = true;
			colorGrid1.Marks.Font.Color = Color.Transparent;
			colorGrid1.FillSampleValues();

			colorGrid1.GetSeriesMark += new Steema.TeeChart.Styles.Series.GetSeriesMarkEventHandler(colorGrid1_GetSeriesMark);
			tChart1.BeforeDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_BeforeDraw);
			tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
			tChart1.Zoomed += new EventHandler(tChart1_Zoomed);
			tChart1.UndoneZoom += new EventHandler(tChart1_UndoneZoom);
			tChart1.Scroll += new EventHandler(tChart1_Scroll);
			tChart1.Resize += new EventHandler(tChart1_Resize);
			tChart1.Draw();
		}

		void tChart1_Resize(object sender, EventArgs e)
		{
			tChart1.Draw();
		}

		void tChart1_Scroll(object sender, EventArgs e)
		{
			tChart1.Draw();
		}

		void tChart1_UndoneZoom(object sender, EventArgs e)
		{
			tChart1.Draw();
		}

		void tChart1_Zoomed(object sender, EventArgs e)
		{
			tChart1.Draw();
		}

		void tChart1_BeforeDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			tChart1[0].Marks.Visible = true;
			tChart1.Tools.Clear();
		}

		void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			tChart1[0].Marks.Visible = false;
		}

		void colorGrid1_GetSeriesMark(Steema.TeeChart.Styles.Series series, Steema.TeeChart.Styles.GetSeriesMarkEventArgs e)
		{
			if ((e.ValueIndex >= 0) && (e.ValueIndex < series.Marks.Positions.Count))
			{
				Steema.TeeChart.Styles.SeriesMarks.Position mp = series.Marks.Positions[e.ValueIndex];
				if (mp != null)
				{
					Steema.TeeChart.Tools.Annotation anno1 = new Steema.TeeChart.Tools.Annotation(tChart1.Chart);

					anno1.Shape.Transparent = true;
					anno1.Text = e.MarkText;
					anno1.Shape.CustomPosition = true;
					anno1.Shape.Left = mp.LeftTop.X;
					anno1.Shape.Top = mp.LeftTop.Y;

					if (e.ValueIndex % 2 == 0)
					{
						anno1.Shape.Font.Color = Color.White;
						anno1.Shape.Color = Color.Black;
					}
					else
					{
						anno1.Shape.Font.Color = Color.Black;
						anno1.Shape.Color = Color.White;
					}  
				}
			}
		}
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