Search code examples
chartscoldfusioncfmlzingchart

How to set goals in a ColdFusion bullet chart?


Bullet charts are supported in ColdFusion from version 10, but I can't find any documentation that explains how to use it from cfml code. I want to know how to set up the goals on a series in cfml.

This is a minimal bullet chart in cfml:

<cfchart
    format="html"
    type="bullet">

  <cfchartseries serieslabel="Foo">
    <cfchartdata item="Bar 1" value="1000">
    <cfchartdata item="Bar 2" value="2000">
  </cfchartseries>

</cfchart>

ColdFusion is using the ZingChart library under the hood and this is how you can set goals in js:

{
  "type": "bullet",
  "series": [
    {
      "values": [20,40,25,50,15,45,33,34],
      "goals": [25,43,30,40,21,59,35,31]
    }
  ]
}

I have looked into the ColdFusion server tags definitions trying to figure out if there is an special attribute or tag to define the series goals, nothing.

\WEB-INF\cftags\META-INF\taglib.cftld

Solution

  • Looking again into the taglib.cftld file I figured out the attributes supported by cfchartdata tag:

    • item
    • value
    • zValue

    The solution for CF11+ is to use the zValue attribute to specify the value of the goal on each data point:

    <cfchart
        format="html"
        type="bullet">
    
      <cfchartseries serieslabel="Foo">
        <cfchartdata item="Bar 1" value="1000" zValue="800">
        <cfchartdata item="Bar 2" value="2000" zValue="2500">
      </cfchartseries>
    
    </cfchart>