Chart drawing points outside start and end position

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
LT411
Newbie
Newbie
Posts: 17
Joined: Wed Jan 30, 2008 12:00 am

Chart drawing points outside start and end position

Post by LT411 » Fri Aug 15, 2008 6:27 pm

I've run into a problem with the chart. With the horizontal axis start and end position set to 0 and 100, the chart is drawing the first and last values on top of the vertical axes so they are not visible.

I tried to work around this by setting the bottom axis start position to 5 and the end position to 95. This resulted in the chart displaying values for the previous and next page.

This problem is reproducible by adding a chart to a form, adding a fastline series to it, and adding the following code to form load:

tChart1.Axes.Bottom.Automatic = false;
tChart1.Axes.Bottom.Minimum = 10;
tChart1.Axes.Bottom.Maximum = 90;
tChart1.Axes.Bottom.StartPosition = 25;
tChart1.Axes.Bottom.EndPosition = 75;

for (int index = 0; index < 100; index++)
fastLine1.Add(index, index);


It seems to me that the chart should only display values with index 10 to 90 but it is displaying all 100 values.

Any help would be appreciated.

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Aug 18, 2008 8:32 am

Hello,

to clip the points into the ChartRect area you have to use the ClipPoints property.
If you have assigned a setminmax for an axis and want to clip the points inside the minimum and maximum axis you will have to use the ClipSeries Tool.

LT411
Newbie
Newbie
Posts: 17
Joined: Wed Jan 30, 2008 12:00 am

Post by LT411 » Mon Aug 25, 2008 3:39 pm

Hi,

It looks like I would have to add a ClipSeries tool for each series. This will add complexity and reduce the performance of the charting app.

Isn't the horizontal axis minumum and maximum supposed to control the range of series data that is displayed on the chart?

I'm scaling the vertical axes according to the range of data that should be displayed on the chart. Occasionally, the chart displays values outside that range which go off the vertical scale.

Don't you think it is a bug for the chart to display values outside the axis minimum and maximum?

Regards,
LT411

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

Post by Narcís » Tue Aug 26, 2008 7:55 am

Hi LT411,

No, we don't think it is a bug. Manually setting axes scales the chart will display data range indicated. However, if you zoom or scroll the chart data within new axes range will be displayed.

BTW: You may be interested in using this:

Code: Select all

			tChart1.Aspect.ClipPoints = true;
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

LT411
Newbie
Newbie
Posts: 17
Joined: Wed Jan 30, 2008 12:00 am

Post by LT411 » Tue Aug 26, 2008 2:18 pm

Hello,

The first problem I encountered is the chart displays values on top of the axis which makes them hard to see. The second problem I encountered is the chart occasionally displays series points outside the range defined by the horizontal axis minimum and maximum. I tried to solve the first problem by setting the horizontal axis start and end positions to 1 and 99 but that made the second problem more pronounced. I submitted sample code to reproduce this in the original post.

I tried ClipSeries as suggested.

ClipSeries clipSeries = new ClipSeries(tChart.Chart);
clipSeries.Series = volume;
clipSeries.Active = true;

This solved the first two problems but introduced a third. Adding ClipSeries to the volume series causes the candle series to not be displayed.

I'll try tChart1.Aspect.ClipPoints next.

Regards,
LT411

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

Post by Narcís » Tue Aug 26, 2008 2:33 pm

Hi LT411,
This solved the first two problems but introduced a third. Adding ClipSeries to the volume series causes the candle series to not be displayed.
Code below works fine for me here using latest TeeChart for .NET v3 build available at the client area. Which is the version you are using? If the problem persists could you please modify the code snippet below so that we can reproduce the problem here?

Code: Select all

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

		private void InitializeChart()
		{
			Steema.TeeChart.Styles.Candle candle1 = new Steema.TeeChart.Styles.Candle(tChart1.Chart);
			Steema.TeeChart.Styles.Volume volume1 = new Steema.TeeChart.Styles.Volume(tChart1.Chart);

			tChart1.Axes.Bottom.Automatic = false;
			tChart1.Axes.Bottom.Minimum = 10;
			tChart1.Axes.Bottom.Maximum = 90;
			tChart1.Axes.Bottom.StartPosition = 25;
			tChart1.Axes.Bottom.EndPosition = 75;
						

			for (int index = 0; index < 100; index++)
			{
				candle1.Add(index, 90, 100, 0, 10);
				volume1.Add(index, index);
			}

			Steema.TeeChart.Tools.ClipSeries clipVolume1= new Steema.TeeChart.Tools.ClipSeries(tChart1.Chart);

			clipVolume1.Series = volume1;
		}
Thanks in advance.
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

LT411
Newbie
Newbie
Posts: 17
Joined: Wed Jan 30, 2008 12:00 am

Post by LT411 » Tue Aug 26, 2008 2:38 pm

Hello Narcis,

Thanks for the quick reply. I was able to reproduce this problem with the code below. The key to making it fail is adding the candle series after the volume series. If I create the candle series first, it works fine. Our app lets the user add and delete series at will, so I can't create them all up front though.

private void Form1_Load(object sender, EventArgs e)
{
tChart1.Axes.Bottom.Automatic = false;
tChart1.Axes.Bottom.Minimum = 10;
tChart1.Axes.Bottom.Maximum = 90;
tChart1.Axes.Bottom.StartPosition = 25;
tChart1.Axes.Bottom.EndPosition = 75;

tChart1.Axes.Left.EndPosition = 50;

Axis volumeLeft = new Axis(false, false, tChart1.Chart);
volumeLeft.StartPosition = 55;
tChart1.Axes.Custom.Add(volumeLeft);

Volume volume = new Volume(tChart1.Chart);
volume.VertAxis = VerticalAxis.Custom;
volume.CustomVertAxis = volumeLeft;

ClipSeries clipSeries = new ClipSeries(tChart1.Chart);
clipSeries.Active = true;
clipSeries.Series = volume;

Candle candle = new Candle(tChart1.Chart);

for (int index = 0; index < 100; index++)
{
candle.Add(index, index - 5, index + 10, index - 10, index + 5);
volume.Add(index, index * 100);
}
}

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

Post by Narcís » Tue Aug 26, 2008 2:50 pm

Hi LT411,

Ok, now I see the problem. This happens when using different axes for the series and is quite logical because ClipSeries tool clips area bounded by series vertical and horizontal axis.

In that case, the only solution I can think of is using SubChart tool for separating different chart regions so that you'll have independent charts which won't interfere with each other.
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

LT411
Newbie
Newbie
Posts: 17
Joined: Wed Jan 30, 2008 12:00 am

Post by LT411 » Tue Aug 26, 2008 3:06 pm

I believe sub-charts are really just independent charts.

Wouldn't I lose things like the common horizontal axis?

I think that would force me to coordinate the sub-charts for all of the tools and behaviors such as scrolling, zooming, paging, cursors, etc.

Thanks for your help. I understand the limitations now and will need to figure something out.

LT411
Newbie
Newbie
Posts: 17
Joined: Wed Jan 30, 2008 12:00 am

Post by LT411 » Tue Aug 26, 2008 6:00 pm

Hello,

One of the programmers here solved the problem with this:

void volume_AfterDrawValues(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
tChart1.Graphics3D.ClearClipRegions();
}

Now it works without having to create sub-charts.

Could you have one of your programmers update the ClipSeries code to clear the clip regions so we don't have to?

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 Aug 27, 2008 7:17 am

Hi LT411,
One of the programmers here solved the problem with this:

void volume_AfterDrawValues(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
tChart1.Graphics3D.ClearClipRegions();
}

Now it works without having to create sub-charts.
Ok, in that case you may want to use events arguments like this:

Code: Select all

void volume_AfterDrawValues(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
g.ClearClipRegions();
}
Could you have one of your programmers update the ClipSeries code to clear the clip regions so we don't have to?
I'm not sure if this would be coherent with the design of ClipSeries tool. However, I've added your request to the wish-list to be investigated.
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

LT411
Newbie
Newbie
Posts: 17
Joined: Wed Jan 30, 2008 12:00 am

Post by LT411 » Wed Aug 27, 2008 12:18 pm

Thanks for the tip, will do. And thanks for adding it to the wish list.

Post Reply