Profile Picture

NMeshSurfaceSeries: How to show surface chart with Rainbow Color Map Scale

Posted By Niranjan Singh 12 Years Ago

NMeshSurfaceSeries: How to show surface chart with Rainbow Color Map...

Author
Message
Niranjan Singh
Posted 12 Years Ago
View Quick Profile
Forum Member

Forum Member (41 reputation)Forum Member (41 reputation)Forum Member (41 reputation)Forum Member (41 reputation)Forum Member (41 reputation)Forum Member (41 reputation)Forum Member (41 reputation)Forum Member (41 reputation)Forum Member (41 reputation)

Group: Forum Members
Last Active: 4 Years Ago
Posts: 49, Visits: 179
Current i am adding custom palette to my surface chart as:

surfaceSeries.AutomaticPalette = false;
surfaceSeries.Palette.Clear();
Color[] FillColors = { Color.DarkBlue, Color.Blue, Color.MediumBlue,
Color.Cyan, Color.LimeGreen,
Color.LightGreen, Color.Yellow,
Color.Orange,Color.OrangeRed,
Color.Red, Color.PaleVioletRed, Color.DarkRed};

int N = 10;

double increment = (max - min) / N;

surfaceSeries.Palette.Add(min, FillColors[0]);
for (int i = 1; i <= N; i++)
{
double value = min + ((double)i * increment);
surfaceSeries.Palette.Add(value, FillColors[i]);
}

It's showing lots of legend in the chart and not the correct drawing as the attached document.

I have tried to get colors of the scale and succeed by the following lines of code:

Color[] allScaleColors = GetRainbowColorMapScaleColors();

private Color[] GetRainbowColorMapScaleColors()
{
try
{
Color[] color = new Color[300];
int wid = 300;
for (int x = 0; x < wid; x++)
{
color[x] = MapRainbowColor(x, wid, 0);
}
return color;
}
catch (Exception ex)
{
throw ex;
}
}

// Map a value to a rainbow color.
private Color MapRainbowColor(float value, float red_value, float blue_value)
{
// Convert into a value between 0 and 1023.
int int_value = (int)(1023 * (value - red_value) / (blue_value - red_value));

// Map different color bands.
if (int_value < 256)
{
// Red to yellow. (255, 0, 0) to (255, 255, 0).
return Color.FromArgb(255, int_value, 0);
}
else if (int_value < 512)
{
// Yellow to green. (255, 255, 0) to (0, 255, 0).
int_value -= 256;
return Color.FromArgb(255 - int_value, 255, 0);
}
else if (int_value < 768)
{
// Green to aqua. (0, 255, 0) to (0, 255, 255).
int_value -= 512;
return Color.FromArgb(0, 255, int_value);
}
else
{
// Aqua to blue. (0, 255, 255) to (0, 0, 255).
int_value -= 768;
return Color.FromArgb(0, 255 - int_value, 255);
}
}


I need help to map the Scale with the rainbow color map.

Does anyone have any idea and solution for this implementation.



Thanks in advance.





Attachments
Rainbow color map scale.gif (98 views, 26.00 KB)



Similar Topics


Reading This Topic