Tuesday 5 August 2014

CFML: <cfchart> / <cfchartseries> bug details for Adobe & Railo

G'day:
I need a place to put some pictures for a coupla bugs I need to raise, so I'll slap 'em in here and point Adobe & Railo at them. There's not much of interest going on below the fold, so don't bother reading it if you have something better to do.

I was having a look at a Stack Overflow question about chart series in CF: "CfChart Stacked bars and unstacked Lines". It's a good question as far as UI stuff goes... the punter wants a mixed format chart - lines and bars - and have the bars stacked but the lines not stacked. This seems reasonable, but it's not looking possible with just <cfchart>. Of course they should probably not bother with <cfchart> anyhow, as there are better solutions out there: "ColdFusion-UI-the-Right-Way / chapters / cfchart".

Still... I had a mess around with it and tried to get it working. I knocked together this code (which doesn't solve it):

<cfscript>
    // cfchartSeries.cfm
    chartData = queryNew("");

    queryAddColumn(chartData, "id", "Integer", [1,2,3,4,5]);
    queryAddColumn(chartData, "series1", "Integer", [100,90,80,90,100]);
    queryAddColumn(chartData, "series2", "Integer", [90,80,70,60,50]);
    queryAddColumn(chartData, "series3", "Integer", [80,70,70,70,80]);
    queryAddColumn(chartData, "series4", "Integer", [70,60,80,80,70]);
</cfscript>

<cfchart chartwidth="640" chartheight="480" seriesplacement="stacked" format="png">
    <cfchartseries query="chartData" type="Line" itemcolumn="id" valuecolumn="series1">
    <cfchartseries query="chartData" type="Line" itemcolumn="id" valuecolumn="series2">
    <cfchartseries query="chartData" type="Bar" itemcolumn="id" valuecolumn="series3">
    <cfchartseries query="chartData" type="Bar" itemcolumn="id" valuecolumn="series4">
</cfchart>

On CF9, this renders completely adequately:


As with CF10:


Note that both the bars and lines are stacked, which is not what the person wanted. Still, that's not what I'm writing about here.  Here's ColdFusion 11's attempt at rendering this:



It's stacked the bars and lines together. For Pete's sake. That's not very clever. And is a bug. One never means to do that on a chart: the various types of series might be stacked within their type, but each type's stacking should be discrete from other types. I'll file a bug for this: 3800237.

But it could be worse. It could be Railo's effort:


I don't mind that it looks a bit amateurish. But I do mind that it's not doing what it's told: where are the bars? It seems that it only pays attention to the first series' type, because if I switch the code around to have the BAR series first:

<cfchart chartwidth="640" chartheight="480" format="png">
    <cfchartseries query="chartData" type="Bar" itemcolumn="id" valuecolumn="series3">
    <cfchartseries query="chartData" type="Bar" itemcolumn="id" valuecolumn="series4">
    <cfchartseries query="chartData" type="Line" itemcolumn="id" valuecolumn="series1">
    <cfchartseries query="chartData" type="Line" itemcolumn="id" valuecolumn="series2">
</cfchart>



Then I get all bars. Also note that it's not stacking them.

I would have no problem if Railo simply decided to not implement <cfchart>. However given they have implemented, it needs to work. Or if there are expected limitations they need to be documented, and dealt with. If they don't want to support stacked series, the the seriesplacement attribute should error if I give it "stacked" as a value. I've said this before, but simply ignoring code is wrong.

Oh I tried to see what would happen on OpenBD, and it just errored. It doesn't support "stacked" as a seriesplacement option. Like Railo. Except - for once - OpenBD handles this properly.

Anyway, I shall raise a bug with Railo too: RAILO-3152.

Righto.

--
Adam