Fixed Point on a chart and Points Sereies

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Luke
Newbie
Newbie
Posts: 68
Joined: Thu Oct 11, 2007 12:00 am

Fixed Point on a chart and Points Sereies

Post by Luke » Fri Oct 24, 2008 6:53 am

Q1) I want to add a point to a Line Series chart. I have tried adding a annotation. But on reize when trying to move it with the line it fails.

m_seltool.Callout.XPosition = tChart.Series[0].CalcXPos(AIndex);
m_seltool.Callout.YPosition = tChart.Series[0].CalcYPos(AIndex);

I store AIndex which I assume to be index of value in series. have tried after redraw and resize but annotation is not moved correctly.

Even if I click on the line after resize at a similar position so AIndex is the same there is no update on the CalcXpos value. I have to click on different position so AIndex changes. I assume this is a bug

Q2) Point Series

Which property to I use to change the shape of the points from the default square?

Thx

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 Oct 24, 2008 8:38 am

Hi Luke,

1. For annotation's being updated you need to do something like this:

Code: Select all

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

		private Steema.TeeChart.Tools.Annotation annotation1;
		private int ValueIndex = 5;

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

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

			annotation1 = new Steema.TeeChart.Tools.Annotation(tChart1.Chart);
			annotation1.Text = "hello!";
			annotation1.Callout.Visible = true;

			tChart1.Dock = DockStyle.Fill;			

			tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
			tChart1.Zoomed += new EventHandler(tChart1_Zoomed);
			tChart1.Scroll += new EventHandler(tChart1_Scroll);
			tChart1.UndoneZoom += new EventHandler(tChart1_UndoneZoom);
			tChart1.Resize += new EventHandler(tChart1_Resize);

			ChartInternalRepaint();
		}

		private void ChartInternalRepaint()
		{
			Bitmap bmp = tChart1.Bitmap;
		}

		void tChart1_Resize(object sender, EventArgs e)
		{
			ChartInternalRepaint();
		}

		void tChart1_UndoneZoom(object sender, EventArgs e)
		{
			ChartInternalRepaint();
		}

		void tChart1_Scroll(object sender, EventArgs e)
		{
			ChartInternalRepaint();
		}

		void tChart1_Zoomed(object sender, EventArgs e)
		{
			ChartInternalRepaint();
		}

		void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			annotation1.Callout.XPosition = tChart1[0].CalcXPos(ValueIndex);
			annotation1.Callout.YPosition = tChart1[0].CalcYPos(ValueIndex);
		}
2. You need to use Pointer.Style:

Code: Select all

			points1.Pointer.Style = Steema.TeeChart.Styles.PointerStyles.Circle;
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 » Fri Oct 24, 2008 8:48 am

ChartInternalRepaint(); what is this? dont see it on chart object.

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 Oct 24, 2008 8:51 am

Hi Luke,

It doesn't exist in TeeChart. It actually is:

Code: Select all

         Bitmap bmp = tChart1.Bitmap;
Since I needed to use it at several places in my example I implemented this:

Code: Select all

      private void ChartInternalRepaint()
      {
         Bitmap bmp = tChart1.Bitmap;
      }
Calling Bitmap method forces the chart being repainted internally and therefore all chart objects are repositioned.
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 » Fri Oct 24, 2008 8:53 am

Considering doing these points as 1 point series instead. As annotations dont move on a resize, makes them quite painfull to use.

But shoundnt the afterredraw be enough alone, you would think after a resize, the calcX,Calcy should work ok.

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 Oct 24, 2008 10:45 am

Hi Luke,

Actually you can use Draw() method instead of Bitmap:

Code: Select all

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

		private Steema.TeeChart.Tools.Annotation annotation1;
		private int ValueIndex = 5;

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

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

			annotation1 = new Steema.TeeChart.Tools.Annotation(tChart1.Chart);
			annotation1.Text = "hello!";
			annotation1.Callout.Visible = true;

			tChart1.Dock = DockStyle.Fill;

			tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
			tChart1.Zoomed += new EventHandler(tChart1_Zoomed);
			tChart1.Scroll += new EventHandler(tChart1_Scroll);
			tChart1.UndoneZoom += new EventHandler(tChart1_UndoneZoom);
			tChart1.Resize += new EventHandler(tChart1_Resize);

			tChart1.Draw();
		}

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

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

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

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

		void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			annotation1.Callout.XPosition = tChart1[0].CalcXPos(ValueIndex);
			annotation1.Callout.YPosition = tChart1[0].CalcYPos(ValueIndex);
		}
Calling Draw() method is necessary for resetting internal variables when the size of the chart is changed. The only way to do this is to draw the chart first to reset them correctly.
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 » Fri Oct 24, 2008 12:45 pm

Hi Narcis

I changed all to Point series with 1 point, then I dont have to worry about moving them manually. Thx

Post Reply