Page 1 of 1
ColorGrid with Rectangle Tool
Posted: Wed Sep 05, 2007 9:26 am
by 13045625
Dear All
I am using a Rectangle tool with a ColorGrid (displaying 50x2048 points). Chart updating does seem faster with the new version (from 28th Aug). However moving and resizing a Rectangle tool on the ColorGrid chart is not very responsive. The hand cursor for moving the tool, and arrow cursor for resizing the tool do not seem to appear unless the left mouse button is depressed and the rectangle is not updated until the left mouse button is raised again.
Also I would like to restrict the Rectangle tool just to the boundaries of the ColorGrid.
If there is a better way to draw a rectangle on the chart please let me know. I would like something like the zoom in rectangle but with the ability to move and resize interactively if possible.
Thanks
jenb
Posted: Wed Sep 05, 2007 1:31 pm
by narcis
Hi jenb,
I am using a Rectangle tool with a ColorGrid (displaying 50x2048 points). Chart updating does seem faster with the new version (from 28th Aug). However moving and resizing a Rectangle tool on the ColorGrid chart is not very responsive. The hand cursor for moving the tool, and arrow cursor for resizing the tool do not seem to appear unless the left mouse button is depressed and the rectangle is not updated until the left mouse button is raised again.
This is because of the size of the ColorGrid series. Using the code below it takes aroung 2500 milliseconds to draw the chart at my machine (Pentium IV 3.2 GHZ, 2 GB RAM and 256 MB Nvidia GeForce FX 5700). Could you please try running it at your end and let us know how it goes?
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
Random y = new Random();
for (int x = 0; x < 50; x++)
{
for (int z = 0; z < 2048; z++)
{
colorGrid1.Add(x, y.Next(), z);
}
}
//colorGrid1.FillSampleValues();
Bitmap bmp = tChart1.Bitmap;
Rectangle Rect = tChart1.Chart.ChartRect;
rectangleTool1.Shape.CustomPosition = true;
rectangleTool1.Left = Rect.Left;
rectangleTool1.Top = Rect.Top;
}
private void rectangleTool1_Dragging(object sender, EventArgs e)
{
Rectangle Rect = tChart1.Chart.ChartRect;
if (rectangleTool1.Left < Rect.Left)
{
rectangleTool1.Left = Rect.Left;
}
if (rectangleTool1.Top < Rect.Top)
{
rectangleTool1.Top = Rect.Top;
}
if (rectangleTool1.Left + rectangleTool1.Width > Rect.Right)
{
rectangleTool1.Left = Rect.Right - rectangleTool1.Width;
}
if (rectangleTool1.Top + rectangleTool1.Height > Rect.Bottom)
{
rectangleTool1.Top = Rect.Bottom - rectangleTool1.Height;
}
}
private void rectangleTool1_Resizing(object sender, EventArgs e)
{
Rectangle Rect = tChart1.Chart.ChartRect;
if (rectangleTool1.Left < Rect.Left)
{
rectangleTool1.Left = Rect.Left;
}
if (rectangleTool1.Top < Rect.Top)
{
rectangleTool1.Top = Rect.Top;
}
if (rectangleTool1.Left + rectangleTool1.Width > Rect.Right)
{
rectangleTool1.Width = Rect.Right - rectangleTool1.Left;
}
if (rectangleTool1.Top + rectangleTool1.Height > Rect.Bottom)
{
rectangleTool1.Height = Rect.Bottom - rectangleTool1.Top;
}
}
private long startTime, now;
private void tChart1_BeforeDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
startTime = DateTime.Now.Ticks;
}
private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
//calculate elapsed time
now = DateTime.Now.Ticks;
TimeSpan elapsedTime = new TimeSpan(now - startTime);
label1.Text = "Elapsed time: " + elapsedTime.TotalMilliseconds.ToString() + " ms";
}
Also I would like to restrict the Rectangle tool just to the boundaries of the ColorGrid.
I also implemented this in Rectangle's Dragging and Resizing events in the code above.
If there is a better way to draw a rectangle on the chart please let me know. I would like something like the zoom in rectangle but with the ability to move and resize interactively if possible.
Some kind of custom drawing could be quicker as it doesn't repaint the chart. I'll try to arrange an example for you.
Posted: Thu Sep 06, 2007 8:15 am
by 13045625
Hi Narcis
My system is 2.8 GHz, 2 GB RAM, with Pentium R(D). With your example I found that not running through the IDE update time is around 109 ms, though the visual studio IDE (debug mode) update time is around 2821 ms. Behaviour of the cursor with the rectangle tool was fine in both cases
However I found something interesting with your example. If I change the x axis grid to 2048 points, and the z axis grid to 50 points (i.e. swapped the axes) then update times are slower (generally around 600 ms outside VS IDE and over 4000 ms inside). Would it be possible to make this the same speed as with the axes in the original?
I think that some of the problems with my code (e.g. cursor not displaying properly) is that the TeeChart control is part of a Windows User Control that is then inside a form - is this correct? If so then I will change it.
A custom drawing example would be good if possible.
Thanks
jenb
Posted: Thu Sep 06, 2007 11:04 am
by narcis
Hi jenb,
My system is 2.8 GHz, 2 GB RAM, with Pentium R(D). With your example I found that not running through the IDE update time is around 109 ms, though the visual studio IDE (debug mode) update time is around 2821 ms. Behaviour of the cursor with the rectangle tool was fine in both cases
Yes, as you have experienced, running the applications from the IDE slows them significantly. Also, if you build your application in Release mode you'll gain some performance as well.
However I found something interesting with your example. If I change the x axis grid to 2048 points, and the z axis grid to 50 points (i.e. swapped the axes) then update times are slower (generally around 600 ms outside VS IDE and over 4000 ms inside). Would it be possible to make this the same speed as with the axes in the original?
I've been able to reproduce this here and added this issue to our wish-list to be enhanced for future releases. There's no way to improve this that I can think of.
I think that some of the problems with my code (e.g. cursor not displaying properly) is that the TeeChart control is part of a Windows User Control that is then inside a form - is this correct? If so then I will change it.
It shouldn't be a problem. However, drawing the chart in a different container may improve its performance a little bit. You could try doing this test at your end.
A custom drawing example would be good if possible.
Sorry but we tried to do something as FastCursor property in CursorTool but this is much more complicated than what we expected. Anyway, I've added a request to our wish-list to implement such property for Rectangle tool too.