Display a £ sign in Coldfusion charts

153 views Asked by At

Quite simple really, I want to display the British pound sign (£) in the yAxis title in a printed Coldfusion PNG chart.

Here's my code:

<cfchart xAxisTitle="Year" yAxisTitle="Cash Flow (£)" gridlines="6" showXGridlines="yes" showYGridlines="yes" showborder="no" format="png" seriesplacement="stacked" chartwidth="350" chartheight="200"> 
    <cfchartseries type="bar" seriesLabel="Saving" seriescolor="##434348">
        <cfset chartYear = 0>
        <cfloop list="#FORM.chartSaving#" index="value">
            <cfchartdata item="#chartYear#" value="#Round(value)#">
            <cfset chartYear = chartYear + 1>
        </cfloop>
    </cfchartseries> 
    <cfchartseries type="bar" seriesLabel="RHI" seriescolor="##7cb5ec">
        <cfset chartYear = 0>
        <cfloop list="#FORM.chartRHI#" index="value">
            <cfchartdata item="#chartYear#" value="#Round(value)#">
            <cfset chartYear = chartYear + 1>
        </cfloop>
    </cfchartseries>
</cfchart>

I've tried various combinations of £ and &##163; but nothing is displaying the £ sign.

Any Ideas ?

1

There are 1 answers

4
Leigh On BEST ANSWER

Try using chr() with its decimal value:

<cfchart xAxisTitle="Year" yAxisTitle="Cash Flow #chr(163)#" ....>

If you want to hard code the literal £ character into the CF source file, be sure to set the file's encoding to UTF8. Otherwise, it will not be displayed correctly.

   <cfprocessingDirective pageEncoding="UTF-8" />
   <cfchart xAxisTitle="Year" yAxisTitle="Cash Flow (£)"  ....>