Monday, August 03, 2009

Stacked Bar chart with negative values in APEX

Today I saw an interesting question in the APEX Forum: "Is it possible to create a stacked verticle bar chart that can display a negative value below the bottom line?"

I tried an example with this query in the Chart Series:

select null as link, value as label, rownum*-1+3 as value, rownum*-1+5 value2
from bar_order_vw
The bar_order_vw is defined as:
create view bar_order_vw (value) as
select sysdate + level as value
from dual connect by level < 10
The result when you use the standard Flash charts in APEX (based on Anychart 3.3) looks like this:

That is not really a nice chart I would say. It's very hard to see what the values are. Basically you see two values for a date. Value 1 is blue, value 2 is red. But some values are negative.
I already tried to play with the settings of the chart, but it doesn't really help to make it a bit nicer.

Next I wanted to know how this chart would look like with Anychart 5, so I used the Anychart integration kit for APEX. I just changed the source of the swf file to point to the integration kit so the chart would render with Anychart 5. This is what I got:

I think it looks a lot cleaner, don't you?

My guess is that in APEX 4.0 it will look fine without having to change anything as there you already have Anychart 5 integrated. For now you can use the integration kit for Anychart 5 or integrate with a charting engine manually.

Edit: Here you find the example in real-time.

No comments: