danas.zuokas
danas.zuokas

Reputation: 4643

Colors in treemap

it would be great to clarify how colors are calculated when ploting treemap (I use gvisTreeMap function from R googleVis library).

  1. Documentation is not very informative. What is it meant by "The color value is first recomputed on a scale from minColorValue to maxColorValue"? Usually I use treemap to display sales (size) and sales difference (color). So ideally I would like to color rectangles so that I can distinguish positive from negative growth, which as I understand is not possible at the moment.
  2. What bothers me most right now is that "... colors are valued relative to all other nodes in the graph". Is there any way to fix colors, so that sales difference, say -25 always gets the same color.

Upvotes: 3

Views: 3057

Answers (2)

simmons
simmons

Reputation: 925

If I have understood your problem correctly, I believe the following will solve it:

Let's say your data is percentages, so can go from 0 to 100. Set minColorValue=-100 and maxColorValue=100 (Or if using a different range, just set it so that the min value is the negative of the max value so that the average is 0.)

Then, if you set the colours to, for example, minColor='red' and maxColor='green', this should solve part 1 (negative values will be displayed in red, and positive in green)

Also, it seems that setting maxColor and minColor fixes the average value the colors are calculated from, so that this also solves part 2 (that is, -25 will then always have the same color in the graph)

Upvotes: 5

asgallant
asgallant

Reputation: 26330

Color is computed as the average color value of all child nodes of a branch. A branch with no child nodes uses the color value from the DataTable. This color value is then scaled on the minColorValue to maxColorValue scale, and a color is computed between minColor and maxColor based on the scale.

Colors are not relative to other nodes on the graph - the size of the node is relative.

Upvotes: 4

Related Questions