[#2738] - Allow assignment of chart colors to specific values

Category:
Feature request
Priority:
High
Status:
Acknowledged
Project: Severity:
Major
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:

Provide control over which series values get assigned to colors in the Series Color <seriesColor />. Users want to see chart colors consistently assigned to the same property being reported. If colors are assigned based on the query result then the colors can change from one run to another.

wbizzare's picture
Joined: Aug 7 2006 - 4:30am
Last seen: 16 years 7 months ago

6 Comments:

#1

Hi,

Can you give more details about the problem?
Why is it that the seriesOrder attribute is not enough to achieve what you want?

Thank you,
Teodor

#2

Hi Teodor,

The seriesOrder attribute controls the order of the colors but the colors get assigned to data based on the query results.

For example, if I want a value from the PRIORITY column to be my series expression

<seriesExpression><![CDATA["Priority "+$F{PRIORITY}]]></seriesExpression>

The problem is that the data is not ordered by priority but rather ordered by date so that priority gets assigned randomly.

I would like to say that something like
<seriesColor seriesOrder="0" color="#CC0033" value="1B"/>

and
<seriesColor seriesOrder="1" color="#FFFF00" value="1A"/>

so that the colors are preassigned rather than being assigned from the query results.

When users look at these charts they want to see consistency in the assignment of the colors from month to month. For example, red might be the high priority, yellow the next and green the lowest for values 1,2,3.

Thanks again,
Walt

#3

One additional requirement: I think it is necessary to indicate the field in the query that is setting the color as well as the values. For example:

<seriesColor seriesOrder="0" color="#CC0033" field=$F{PRIORITY} value="1B"/>

This is because colors seem to be assigned differently for each chart type. For example, the pie chart sets the color based on the value expression (not the key expression that I would have expected) whereas the bar3DPlot sets the color based on the series expression.

#4

In our case a chart is built from a custom data source. As a result, some series can have no data at all. In this case colors can turn to be misleading. For instance:

Case 1:

Base: 10 20 30 <-- assigned color: yellow
Margin: 3 5 8 <-- assigned color: green
Total: 13 25 38 <-- assigned color: blue

Case 2:

Base: 10 20 30 <-- assigned color: yellow
Margin: [none] <-- no data, no color assigned
Total: 10 20 30 <-- assigned color: green

So, green line in the same chart can mean different things depending on incoming data.

#5

This feature is highly desirable for us. For Category datasets, I would suggest two ways of assigning a chart series color from a field:

1. Specify a field whose value is the actual color to be used when plotting the chart category, e.g.:

<categorySeries>
<seriesExpression>"My series"</seriesExpression>
<categoryExpression>$F{myCategory}</categoryExpression>
<valueExpression>$F{myValue}</valueExpression>
<colorExpression>$F{myCategoryColor}</colorExpression>
</categorySeries>

... $F{myCategoryColor} would contain an HTML color string (e.g. "#FF0000") to use as the category color.

2. Specify a field whose value is an index to pick a specific color bucket from the series color, e.g.:

<categorySeries>
<seriesExpression>"My series"</seriesExpression>
<categoryExpression>$F{myCategory}</categoryExpression>
<valueExpression>$F{myValue}</valueExpression>
<colorIndexExpression>$F{myCategoryColorIndex}</colorIndexExpression>
</categorySeries>
...
<plot orientation="Horizontal" labelRotation="0.0">
<seriesColor seriesOrder="0" color="#FF0000"/>
<seriesColor seriesOrder="1" color="#00FF00"/>
<seriesColor seriesOrder="2" color="#0000FF"/>
</plot>

... $F{myCategoryColorIndex} would contain an index to pick a color from the series color. e.g. if it has the value "1", the color of the bar would be green. This way, we would still be able to use chart themes to specify the colors, while ensuring that the colors used for each category are consistent from one chart to another regardless of the order and number of items.

I am not sure if this feature would make sense for other types of chart datasets, besides Category datasets.

#6

I think it's a good feature request.
Note that until this feature is added, it's possible to achieve this in a chart customizer or a chart theme. I posted sample code that shows one way to set the pie chart colors explicitly:
http://mdahlman.wordpress.com/2011/04/17/chart-customizers-2/

Feedback
randomness