ColorGrid with uniformly distributed but non-integer values

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
SteveP
Advanced
Posts: 132
Joined: Sun Sep 07, 2003 4:00 am

ColorGrid with uniformly distributed but non-integer values

Post by SteveP » Mon May 09, 2005 1:56 pm

A ColorGrid (7.04) with non-integer values does not display its color grid at the correct pixels even though its values are regularily distributed.

series1.AddXYZ(1, 1, 0.5);
series1.AddXYZ(2, 2, 1.0);
series1.AddXYZ(3, 3, 1.5);

series1.AddXYZ(1, 4, 2.0);
series1.AddXYZ(2, 5, 2.5);
series1.AddXYZ(3, 6, 3.0);

Its Marks do show at the correct location. If IrregularGrid is set True, it looks even worse.

Is there a way to control the height of the individual color grids at each data value ?

Horizontal CursorTool with Snap True snaps to integer Y Vertical axis values (2.0,3.0,4.0) and not to the actual data.

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 May 09, 2005 2:26 pm

Hi Steve,
A ColorGrid (7.04) with non-integer values does not display its color grid at the correct pixels even though its values are regularily distributed.
According to TColorGridSeries definition:

The TColorGridSeries component controls access to the properties and methods of the ColorGrid Series.

It displays a grid of color cells.

Every cell is determined by a pair of XZ coordinates.
The "Y" value of the cell is used to calculate the cell's color from a color palette.

Inherits all properties from the ancestor component.
Supports series marks, zoom and scroll as any other series.

The "CenteredPoints" property controls how are "X" and "Z" values considered.


So that your code should be something like:

Code: Select all

  series1.AddXYZ(1, 1, 1);
  series1.AddXYZ(2, 2, 1);
  series1.AddXYZ(3, 3, 1);

  series1.AddXYZ(1, 4, 2);
  series1.AddXYZ(2, 5, 2);
  series1.AddXYZ(3, 6, 2);
To get what you request you should consider using another series type (i.e.: TChartShape).
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

SteveP
Advanced
Posts: 132
Joined: Sun Sep 07, 2003 4:00 am

Post by SteveP » Mon May 09, 2005 3:22 pm

Narcis,

> To get what you request you should consider using another series type (i.e.: TChartShape).

To display many (hundreds) of data points, one TChartShape series would have to be added for each daa point, rather than just adding points to one series ? I need a cursor tool with snap and follow mouse.

Steve

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 May 09, 2005 3:43 pm

Hi Steve,

Then you may use a ColorGrid series leaving transparent the cells that souldn't be displaied. To leave them transparent set it's Y value to zero.
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

SteveP
Advanced
Posts: 132
Joined: Sun Sep 07, 2003 4:00 am

Post by SteveP » Mon May 09, 2005 4:37 pm

If you mean that every cell in the ColorGrid needs to have a data value assigned, just doing :

series1.AddXYZ(1, 1, 2);
series1.AddXYZ(2, 2, 3);
series1.AddXYZ(3, 3, 6);

series1.AddXYZ(1, 5, 5);
series1.AddXYZ(2, 6, 8);
series1.AddXYZ(3, 7, 11);

produces a grid with its unassigned cells showing the back wall. Perhaps the unassigned cells by default use Y=0.

What I'm after is a 2D plot with rectangular "cells" that has integer X axis values (1,2,3...) but whose Y values are floating point. The X axis cell should be colored from one cell to the next, as the ColorGrid does. In some cases, the Y cell would only be one pixel in height, at its Y-data value. A Point series with rectangle style might work. Its Height property is actually the number of pixels above and below the data value, as (2*Height+1) pixels. To make the rectangle be one pixel tall when specifying a height of one, a Diamond style can be used. Each point's width can be calculated to span the X data range from (X-0.5) to (X+0.5)

In other cases, each Y data represents a range of values and the Y cell height should be filled in over that data range. In those cases, each Y value represents a center datavalue and its associated full-width-at-half-max. Does a series exist that can draw a band of values (on the Y axis) +/- in height from the data center over an X data range of 1 unit ? Perhaps something could be drawn over another series that is used to just plot the center data value. Maybe a Point series can be used for the data center (and cursortool associated with it), and another Point series just used to display the FWHM range.

Similar perhaps to ColorBand tool, but not spanning the entire X axis.

I could not get the SeriesBand tool to do this.

SteveP
Advanced
Posts: 132
Joined: Sun Sep 07, 2003 4:00 am

Post by SteveP » Mon May 09, 2005 6:34 pm

It looks like Bar3D can be used to display a colored range of Y values between its Y and Offset values.

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 May 10, 2005 8:14 am

Hi Steve,
If you mean that every cell in the ColorGrid needs to have a data value assigned, just doing :

series1.AddXYZ(1, 1, 2);
series1.AddXYZ(2, 2, 3);
series1.AddXYZ(3, 3, 6);

series1.AddXYZ(1, 5, 5);
series1.AddXYZ(2, 6, 8) ;
series1.AddXYZ(3, 7, 11);

produces a grid with its unassigned cells showing the back wall. Perhaps the unassigned cells by default use Y=0.
I'm afraid you didn't understood how ColorGrid series work. You need to specify a regular M*N grid where M are X values and N are Z values. You can also use float values as:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var
  i,j: Integer;
  z: double;
begin
  Series1.IrregularGrid:=true;
  Randomize;

  z:=0;
  for i:=0 to 10 do
	begin
	  for j:=0 to 10 do
      Series1.AddXYZ(j, random(100), z);

     z:=z + 0.5;
	end;
end;
You can also find ColorGrid examples at the TeeChart features demo available at the TeeChart program group.
Does a series exist that can draw a band of values (on the Y axis) +/- in height from the data center over an X data range of 1 unit ?
You can use Bubble series setting it's pointer style to square. Using AddBubble method you can specify each bubble center coordinates and it's radius. You could also use a Map series. You'll find examples of this at the features demo.
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

SteveP
Advanced
Posts: 132
Joined: Sun Sep 07, 2003 4:00 am

Post by SteveP » Tue May 10, 2005 3:03 pm

Narcis,

I meant that it is not necesary to supply data to every cell in a grid. The cells that do not have data supplied to them will be displayed as empty. You can have a grid of 100 by 100 cells, and only do series1.AddXYZ for say 4 points then those 4 will be shown on an otherwise empty grid.

Your example of floating Z data should display an 11 by 11 grid. But it only shows 6 cells on the vertical axis. 11 marks are shown vertically, every other one of them lies on a grid cell boundry.

The Bubble series would be what I need except that I actually need rectangles and not squares. I need constant X axis width (like a Bar series) but varying Y axis height. Do you know of any way to be able to specify a horizontal radius independent of the vertical radius ? The series Squared property does not appear to do what I need.

Thanks,

Steve

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 May 10, 2005 3:19 pm

Hi Steve,
I meant that it is not necesary to supply data to every cell in a grid. The cell that do not have data supplied to them will be displayed as empty. You can have a grid of 100 by 100 cells, and only do series1.AddXYZ for say 4 points and those 4 will be shown on an otherwise empty grid.
Yes, that's why I suggested to put zero in the Y value for the cells you want to be empty. This trick will make those cells transparent.
Your example of floating Z data should display an 11 by 11 grid.
No, it should display a 10 x 10 grid as you need four "corner" values to determine a cell, just try:

Code: Select all

  Series1.AddXYZ(5, random(100), 5);
  Series1.AddXYZ(6, random(100), 5);
  Series1.AddXYZ(5, random(100), 4);
  Series1.AddXYZ(6, random(100), 4);
This will draw 1 cell grid. If you just remove one of this lines no cell will be drawn.
But it only shows 6 cell on the vertical axis. 11 marks are shown vertically, every other one of them lies on a grid cell boundry.
It works fine here using latest version available which is v7.04 and the code I pasted in my previous post.
The Bubble series would be what I need except that I actually need rectangles and not squares. I need constant X axis width (like a Bar series) but varying Y axis height. Do you know of any way to be able to specify a horizontal radius independent of the vertical radius ? The series Squared property does not appear to do what I need.
Then the best option may be using Map series. You can find an example of this at the TeeChart features demo available at the TeeChart program group and searching for "Map GIS".
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

SteveP
Advanced
Posts: 132
Joined: Sun Sep 07, 2003 4:00 am

Post by SteveP » Tue May 10, 2005 4:42 pm

I'm using v7.04, recompiled after editing TeeDefs.inc for type single instead of double.

I was using CenteredPoints = true and seeing 11 cells. Using CenterPoints = false, there actually are 10 cells. But going up the vertical axis at each X value, the first and second cell have the same color, the 3rd and 4th have same color, etc. This is what make it appear to have one-half as many cells vertically. Showing Marks with X and Y style does show different Y values for the cells that are displaying with the same color.

Changing the Z increment from 0.5 to 1.0 make each cell have a different color.

Changing Z increment to 2.0 make the upper half of the grid have no colored cells.


[/quote]
No, it should display a 10 x 10 grid as you need four "corner" values to determine a cell, just try:

Code: Select all

  Series1.AddXYZ(5, random(100), 5);
  Series1.AddXYZ(6, random(100), 5);
  Series1.AddXYZ(5, random(100), 4);
  Series1.AddXYZ(6, random(100), 4);
This will draw 1 cell grid. If you just remove one of this lines no cell will be drawn.
[quote]

I see colored 4 cells. If I remove the first line, there still are 4 cells but the upper two are blank. If Marks are made visible, there is a mark on the upper right cell (which is blank) but no mark on the upper left cell (since that is the one removed).

Steve

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 May 11, 2005 8:31 am

Hi Steve,
I see colored 4 cells. If I remove the first line, there still are 4 cells but the upper two are blank. If Marks are made visible, there is a mark on the upper right cell (which is blank) but no mark on the upper left cell (since that is the one removed).
Yes, you are right. Sorry but I was wrong. If data has "grid structure" the ColorGrid series algorithms does the calculation. To know if data has "grid compliant structure" should fit in a nested for loop as I wrote you in previous replies.

As I told you previously I suggest you to try map series.
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

SteveP
Advanced
Posts: 132
Joined: Sun Sep 07, 2003 4:00 am

Post by SteveP » Wed May 11, 2005 1:02 pm

But it really is not necessary to assign a value to every cell on the grid in a loop. As I suggested previously,

series1.AddXYZ(1, 1, 2);
series1.AddXYZ(2, 2, 3);
series1.AddXYZ(3, 3, 6);

series1.AddXYZ(1, 5, 5);
series1.AddXYZ(2, 6, 7);;
series1.AddXYZ(3, 7, 11);

only fills part of the grid, but the whole grid is displayed and unassigned cells appear with the back wall color.

Map series is more trouble adding points than other series types and its cursortool does not seem to support Snap.

Post Reply