How to add color scales to ODF?

Michael Stahl mstahl at redhat.com
Fri May 11 05:53:31 PDT 2012


On 11/05/12 13:21, Eike Rathke wrote:
> Hi Markus,
> 
> On Friday, 2012-05-11 03:20:37 +0200, Markus Mohrhard wrote:
> 
>> A possible way a color scale entry would look like is:
>>
>> <colorScale range="$A$4:$D$10">
>>   <entry type="value" val="10" col="ff11ff">
>>   <entry type="max" col="ffffff">
>> </colorScale>
>> <colorScale range="$H3:$I$20">
>>   <entry type="min" col="ff11ff">
>>   <entry type="percent" val="30" col="aaaaaa">
>>   <entry type="percent" val="70" col="bbbbbb">
>>   <entry type="max" col="ffffff">
>> </colorScale>
> 
> Taking Michael's suggestion
> 
> <style:style style:name="ce1" style:family="table-cell">
>   <style:color-scale style:color-scale-minimum="CCCCCC"
> style:color-scale-minimum-value="3" style:color-scale-maximum="444444"
> style:color-scale-maximum-value="42"/>
> </style:style>
> 
> and applying your example this could be something like
> 
> <style:style style:name="ce1" style:family="table-cell">
>     <style:color-scale>
>         <style:color-scale-entry fo:background-color="#ff11ff" office:value="10"/>
>         <style:color-scale-entry style:color-scale-maximum="#ffffff"/>
>     </style:color-scale>
> </style:style>
> <style:style style:name="ce2" style:family="table-cell">
>     <style:color-scale>
>         <style:color-scale-entry style:color-scale-minimum="#ff11ff"/>
>         <style:color-scale-entry style:color-scale-percent="30" fo:background-color="#aaaaaa"/>
>         <style:color-scale-entry style:color-scale-percent="70" fo:background-color="#bbbbbb"/>
>         <style:color-scale-entry style:color-scale-maximum="#ffffff"/>
>     </style:color-scale>
> </style:style>
> 
> For type="value" above, can also strings be colored differently? Then
> we'd need to use office:value-type as well.
> 
> 
>> For color scales and data bars( that are more or less just another way
>> to represent the same information ) there are quite some differences
>> to normal conditional formatting. One important difference is that the
>> range the color scale is applied to is really important (min, max,
>> percent, percentile) don't make sense without a range.
> 
> I think that can be expressed in the specification saying that a style
> containing <style:color-scale> needs to be applied on a contiguous
> range. Not sure though. If not, then things get complicated.

i wonder if that restriction is really necessary.  of course i don't
know how Calc is implemented and whether there would be performance
advantages in doing so; also i don't know if OOXML has such a
restrictions, and if not whether it would create interop problems.

but another problem: is it possible that users want to use the same
color scale on a bunch of cells, but otherwise style them differently?

if so i guess this could be dealt with via some kind of style
inheritance (which is already possible AFAIK), i.e. put the color scale
into a base style; or perhaps it would be better to have color scales as
top-level elements, and then reference them from styles (similar to e.g.
fonts), like so:

<style:color-scale style:name="foo" style:color-scale-minimum="CCCCCC"
style:color-scale-minimum-value="3" style:color-scale-maximum="444444"
style:color-scale-maximum-value="42"/>

<style:style style:name="ce1" style:family="table-cell">
  <style:use-color-scale style:name"foo"/>
</style:style>

<style:style style:name="ce2" style:family="table-cell">
  <style:use-color-scale style:name"foo"/>
</style:style>

with the idea that all cells that reference via their styles the same
color scales participate in the minimum/maximum etc. setting.



More information about the LibreOffice mailing list