Saturday, February 26, 2011

APEX 4 (bug) - Gradient in Charts

Something surprised me in APEX (and probably entire 4.0).

APEX allows to specify a Gradient Angle when you specify two background colors for the chart and put the Background Type to Gradient. (see screenshot)

A value of 0 degrees results in a horizontal gradient with the first background color on the left and the second background color on the right.

Running the page results in:

Cool isn't it? ... But I just wanted it a little bit different, I wanted the first color (green) on top and the second color (yellow) at the bottom. So I would have thought if I change the value of the Gradient Angle to 90 that will do it... but no, the same (or very very similar).

Looking at the XML that was generated it showed me:

So although I put 90 degrees in the Gradient Angle, it seems like APEX divided it by something close to 60...

If you want the same as me and really use the Gradient Angle you either have to multiply your value by 60 or change the XML yourselves (Custom XML = Yes and you can change it). I prefer the second option as if they fix it (as I can't believe it was intentional!) you end up with a different gradient angle.

Happy charting ...


David said...


Sounds like they're converting your 90 degrees into radians (pi/2), which is roughly 1.5707. Of course, why they're converting to radians in the first place is a good question, as the AnyChart documentation says that it's supposed to be in degrees...

Good catch!


Hilary Farrell said...

Hi Dimitri...and David,

As you pointed out, the value entered in the Gradient Angle for the setting of a chart Background colour is being converted to radians. This conversion was a requirement for earlier versions of AnyChart charts, however this conversion is not necessary for the latest chart version. This conversion to radians has been removed in development, and our next release will contain the revised behaviour.