I had a requirement for a different type of IColorAxis
implementation that didn't currently exist.
The new IColorAxis
implementation, named StopColorAxis
, allows you to create a colour scale with specific colors at specific values (stops). Colours for values not at specific stops are interpolated from the nearest stops (upper and lower).
For example, suppose you have a StopColorAxis
with a stop of Red (RGB[255, 0, 0]) at 0 and a stop of Green (RGB[0, 255, 0]) at 1. The colour returned for 0.5 would be halfway between red and green i.e. RGB[127, 127, 0]
This style of colour axis does not have a specific palette. Therefore the current
interface methods (OxyColor GetColor(int paletteIndex)
int GetPaletteIndex(double value)
) proved problematic. However, nearly all of the code base utilised the extension method
OxyColor GetColor(double value)
which has a signature more suited to my needs.
Therefore I modified IColorAxis
to have a single method OxyColor GetColor(double value)
and migrated all of the current implementations (leaving the extension method redundant).
The only issue I encountered was in ScatterSeries
that utilised the original two methods of
. In this case it was utilising the paletteIndex int as a key in a couple of dictionaries. As
is implemented as a struct and not a class it was trivial to change
to utilise the OxyColor
as the key.
My question, is this the correct direction? You can view the modifications at my
on the StopColorAxis branch.
If this is the correct direction then I will add the appropriate examples and documentation before issuing a pull request.
Otherwise any suggestions to allow integration of an IColorAxis
of this style would be appreciated.