Skip to main content
DevScreen
Inspiring
September 9, 2026

CFChart fails with external style file, after latest update.

  • September 9, 2026
  • 6 replies
  • 48 views

When using CFChart with an external style file, CF can no longer find it after applying the latest patch.  The error returned is:  Could not locate the style file ../includes/css/currency.piegraph.

 

Current version:  2023,0,24,330957
Previous version (which still works):  11,0,19,314546
Server:  Windows Server 2019.

 

Code:

<cfchart style="..\includes\css\currency.piegraph" chartwidth="500">

</cfchart>

 

I have tried using relative path, absolute path, and also ExpandPath() and made sure the file exists but CF doesn’t like it.  We have other servers not yet updated but they can locate the file just fine.  Please suggest a fix.

 

    6 replies

    BKBK
    Community Expert
    Community Expert
    September 10, 2026

    I think that the issue arises because, in newer ColdFusion versions, cfchart is unable to resolve style=”/path/to/some/folder/styleFile.json”. In other words, it may be that recent ColdFusion versions don’t expect the value of cfchart’s style attribute to be a URL. They expect either the file (that is, style=”styleFile.json”) or the content of the file (that is, style=”string_content_of_styleFile.json”).

    That would explain why using a relative path or an absolute path results in an error. It would also explain why your file-read method works. The file-read ensures that the JSON string is passed, rather than the file path.

    Nevertheless, there is a solution that is less resource-intensive than a file-read, namely, an include.
    Something like this:
     

    <!--- Assuming the relative path is ../../includes/css/currency.json --->

    <cfsavecontent variable="graphStyle">

    <cfinclude template="../../includes/css/currency.json" >

    </cfsavecontent>

    <cfchart style="#graphStyle#" chartwidth="500">

    </cfchart>

     

    To conclude, you might want to report this as a cfchart bug. A relevant detail to mention in the report is that style=”path/fo/file.json” works in ColdFusion 11.

     

    DevScreen
    DevScreenAuthor
    Inspiring
    September 10, 2026

    I agree, it used to work fine for us up until this patch.  I did notice in the CFCHART documentation that you can use “this.chartThemeDirectory” in application.cfc file and I did that. I had relative path, and even full path using ExpandPath() to the directory where my theme is but CFCHART still couldn’t find it. File read was the best I could find, until you suggested the <cfinclude> route.  I will use that solution. Thank you!

    BKBK
    Community Expert
    Community Expert
    September 10, 2026

    My pleasure, ​@DevScreen .
    I have added my vote to the Tracker ticket.

    DevScreen
    DevScreenAuthor
    Inspiring
    September 9, 2026

    After trying many different things, I finally settled on this:

    <cffile action="read" file="#ExpandPath('/my/path/includes/css/currency.json')#" variable="graphStyle">
    <cfchart style="#graphStyle#" chartwidth="500">
    </cfchart>

     

    It’s a bummer that “this.chartThemeDirectory” didn’t work as intended on multiple different servers that I tried.  Seems like the Charting component cannot access the directory specified in it, but other tags such as cfinclude, and cffile can open the exact file just fine.

    Hopefully someone else running into the same issue can use this as a quick solution.

    DevScreen
    DevScreenAuthor
    Inspiring
    September 9, 2026

    I wanted to add that I have also tried adding: 
    this.chartThemeDirectory to my application.cfc file,  then updated the <cfchart> tag to say style=”currency.json” (as I changed the extension to Json) and it still can’t find it.

    The only thing that makes it work is dropping in the same directory, or dropping it inside Coldfusion Installation directory \cfusion\charting\styles\

     

    It would be great if I can get it to work from where my application is instead of having it under the CF installation folder!