ColorGrid

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
dotnetjunkee
Newbie
Newbie
Posts: 20
Joined: Fri Dec 05, 2003 5:00 am

ColorGrid

Post by dotnetjunkee » Tue Jun 13, 2006 11:54 am

I want to display certain values in a ColorGrid. Therefore, I wrote the following code:

colorGrid1.ClearPalette();

colorGrid1.AddPalette(1.0, Color.Red);
colorGrid1.AddPalette(1.5, Color.Blue);
colorGrid1.AddPalette(2.0, Color.Black);

this.colorGrid1.BeginUpdate();
this.colorGrid1.Clear();

double[] x = {1.0, 1.5, 1.0};
double[] y = {1.0, 1.5, 1.5};
double[] z = {1.0, 1.5, 2.0};

this.colorGrid1.Add(x, y, z);
this.colorGrid1.CheckOrder();
this.colorGrid1.EndUpdate();

As you can see, the z-value
* 1.0 should be displayed red
* 1.5 should be displayed blue
* 2.0 should be displayed black

Unfortunately my code does not work. The program crashes down to a System.IndexOutOfRangeException.

Any ideas?

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 Jun 15, 2006 11:19 am

Hi dotnetjunkee,

This is because ColorGrid series is not being properly populated. Please my reply on this topic on how to populate all series inherited from Custom3D series. For example, the examples below work fine:

Code: Select all

    private void Form1_Load(object sender, EventArgs e)
    {

      double[] x = { 1.0, 1.0, 1.0 };
      double[] y = { 1.0, 1.5, 1.5 };
      double[] z = { 1.0, 2.0, 3.0 };

      this.colorGrid1.Add(x, y, z);

      colorGrid1.UseColorRange = false;
      colorGrid1.UsePalette = true;
      colorGrid1.PaletteSteps = 3;
      colorGrid1.ClearPalette();

      colorGrid1.AddPalette(1.0, Color.Red);
      colorGrid1.AddPalette(1.5, Color.Blue);
      colorGrid1.AddPalette(2.0, Color.Black); 
    }
or

Code: Select all

    private void Form1_Load(object sender, EventArgs e)
    {
      Random rnd = new Random();
      double[] xValues = new double[36];
      double[] yValues = new double[36];
      double[] zValues = new double[36];
      int count = 0;

      for (double x = 0; x < 6; ++x)
      {
        for (double y = 0; y < 6; ++y)
        {
          xValues[count] = y;
          zValues[count] = x;
          yValues[count] = rnd.Next(3);
          ++count;
        }
      }

      colorGrid1.Add(xValues, yValues, zValues);

      colorGrid1.UseColorRange = false;
      colorGrid1.UsePalette = true;
      colorGrid1.PaletteSteps = 3;
      colorGrid1.ClearPalette();

      colorGrid1.AddPalette(1.0, Color.Red);
      colorGrid1.AddPalette(1.5, Color.Blue);
      colorGrid1.AddPalette(2.0, Color.Black); 
    }
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