coldfusionluceecfchart

Lucee 5.3.8 CFChart URL Disable


Lucee CFChart type pie from query markup:

<cfchart chartheight="600" chartwidth="800" showborder="true" title="Levels">
<cfchartseries query="#layout.querymap[layout.QueryName]#" type="pie" itemcolumn="Title" valuecolumn="Amount" />
</cfchart>

creates this HTML:

<map id="chart_8" name="chart_8">
<area shape="poly" coords="211,170,225,147,242,126,262,108,284,93,307,80,333,71,359,66,386,64,386,263,386,263" title="84000" alt="" href="#?series=0&category=xxxx&value=84000.0"/>
<area shape="poly" coords="176,278,178,254,182,230,189,208,199,186,374,278,374,278" title="37500" alt="" href="#?series=0&category=xxxx&value=37500.0"/>
<area shape="poly" coords="275,468,254,453,235,436,218,416,204,395,193,372,185,348,180,323,179,297,377,297,377,297" title="80000" alt="" href="#?series=0&category=xxxx&value=80000.0"/>
<area shape="poly" coords="516,471,491,487,465,498,437,505,409,509,380,508,352,503,325,494,299,481,401,310,401,310" title="90000" alt="" href="#?series=0&category=xxxx&value=90000.0"/>
<area shape="poly" coords="610,359,598,388,581,416,561,440,536,461,420,300,420,300" title="50000" alt="" href="#?series=0&category=xxxx&value=50000.0"/>
<area shape="poly" coords="588,168,600,188,610,208,617,229,621,251,623,273,623,296,620,318,614,340,425,281,425,281" title="70000" alt="" href="#?series=0&category=xxxx&value=70000.0"/>
<area shape="poly" coords="412,63,436,65,459,69,482,76,504,86,524,99,543,113,560,130,575,149,412,262,412,262" title="75000" alt="" href="#?series=0&category=xxxx&value=75000.0"/>
</map><img border="0" usemap="#chart_8" src="/lucee/graph.cfm?img=f09a50705458509f66c5f37628f0bdea&type=png">

I want the static image alone; no href links, no area tags, no map tags.

An empty url attribute doesn't work; a documentation search was futile.


Solution

  • Use the source attribute of cfchart. It will store the src attribute of the generated image in the specified variable.

    <cfchart source="myChartImage" ...>
      <cfchartseries ...>
    </cfchart>
    
    <cfdump var="#myChartImage#">
    

    Using your example, myChartImage would be a string with a value of /lucee/graph.cfm?img=f09a50705458509f66c5f37628f0bdea&type=png.

    If you want to store the generated chart image as an actual file without calling /lucee/graph.cfm, you need to request the URI via cfhttp using the getAsBinary attribute and retrieve the data as byte array. You can then write it to disk or encode it as base64 or hex etc.