Project

General

Profile

Actions

Bug #2030

closed

Impossible to define a custom color map for a 3D chart

Added by Jan Goyvaerts over 11 years ago. Updated about 11 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
-
Target version:
-
Start date:
07/15/2013
Due date:
% Done:

0%

Estimated time:

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

invalid color map.png (134 KB) invalid color map.png Jan Goyvaerts, 08/06/2013 04:28 PM
Actions #1

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.

Actions #2

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.

Actions #3

Updated by Jan Goyvaerts over 11 years ago

Same happens for bar charts - all white.

Actions #4

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;

}

}

Actions #5

Updated by Jan Goyvaerts over 11 years ago

The ultimate proof : Showing the color map on the chart. The surface is plain white but the color map isn't.

Actions #6

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?

Actions #7

Updated by Korneel Dumon over 11 years ago

  • Assignee set to Korneel Dumon
Actions #8

Updated by Koen Deforche about 11 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF