Bug #2030
closedImpossible to define a custom color map for a 3D chart
0%
Description
If I get this right !
The API for the color maps is preventing to define a custom color map. I'd like to define a 21-sized color map on a surface plot. Instead of the default red<->yellow.
Looking to the hierarchy I'd say for a custom color map one has to extend WStandardColorMap. Correct ?
This class has two constructors: with and without a list of colorMap (camel case ! Java classes names start an uppercase character). Problem is the class colorMap is package private. Hence the impossibility to actually use this constructor. (Unless I add my subclass in the same package.)
What I'd really like to see on this class is a constructor with just a list of colors. The class would put them equidistant over the min/max values. Or let the chart decide - because it knows the min/max values.
Files
Updated by Korneel Dumon over 11 years ago
- Status changed from New to Resolved
I removed the type colorMap and replaced it with a nested type WStandardColorMap::Pair, this type represent a color-value pair.
A custom colormap is defined most easily by giving a list of WStandardColorMap::Pair to the constructor of WStandardColorMap.
Updated by Jan Goyvaerts over 11 years ago
The constructor is accessible but the color remains white. Also for the default widget gallery - the sombrero data is only visible by putting a mesh over it. So maybe something's still wrong here.
Updated by Jan Goyvaerts over 11 years ago
Same happens for bar charts - all white.
Updated by Jan Goyvaerts over 11 years ago
Color map we're using:
public class OptimusColorMap extends WStandardColorMap {
private static final int[] REDS = {
000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 25, 50, 99, 149, 171, 193, 211, 229, 240, 251, 242, 234, 239, 244, 244, 244, 247, 251
};
private static final int[] GREENS = {
37, 37, 37, 37, 37, 61, 86, 102, 119, 137, 155, 171, 188, 205, 223, 218, 213, 204, 195, 191, 188, 191, 195, 205, 216, 223, 231, 226, 221, 226, 231, 236, 241, 246, 251, 234, 218, 200, 183, 155, 127, 88, 50
};
private static final int[] BLUES = {
137, 161, 185, 219, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 227, 200, 174, 149, 130, 111, 90, 70, 62, 55, 36, 17, 29, 42, 29, 17, 17, 17, 42, 68, 35, 2, 1, 000, 000, 000, 25, 50
};
private static final int COUNT = REDS.length;
public OptimusColorMap(final double min, final double max, final boolean continuous) {
super(min, max, generatePairs(min, max), continuous);
}
private static List generatePairs(final double min, final double max) {
final ArrayList pairs = new ArrayList(COUNT);
final double increment = (max - min) / (COUNT - 1);
double value = min;
for (int index = 0; index < COUNT; index) {
pairs.add(new Pair(value, new WColor(REDS[index], GREENS[index], BLUES[index])));
value += increment;
}
return pairs;
}
}
Updated by Jan Goyvaerts over 11 years ago
- File invalid color map.png invalid color map.png added
The ultimate proof : Showing the color map on the chart. The surface is plain white but the color map isn't.
Updated by Korneel Dumon over 11 years ago
I copy/pasted the code and it works here. Is this webGL or is it server-side rendering? Also, which browser is it?
Updated by Koen Deforche about 11 years ago
- Status changed from Resolved to Closed