Is Cfcfhart possible inside cfthread? how to get the exit?
I am trying to improve the runtime of one of my reports that uses cfcharts to print graphs. The code itself is an entity loop, and for each entity I create a chart (this is a comparison report).
Doing this inline takes almost a minute or more to complete due to the complexity of the report, so I'm trying to use cfthread for this case, but I'm not sure if it's possible.
Here's the code:
<body> <cfloop array="#uuids#" index="uuid" > <cfthread action="run" name="t#threadCount#" output="to#threadCount#"> ... <cfchart > ... </cfchart> </cfthread> ... </cfloop> </body>
As expected, cfchart will not be "printed" inside cfthread, although it appears to be executing. How can I get the output of cfthread? One possible solution would be to create an image from cfchart and just use the image to create the document at a later time when all threads have finished, but I was wondering if there was a way to get the cfchart output from cfthread.
source to share
I was able to use cfsavecontent to save and then generate quoted cfcharts.
Just make sure that all used requests / used data variables are stored inside the cfsavecontent block (I had problems with this part, the scope is a bit inattentive if you're not careful)
<body> <cfloop array="#uuids#" index="uuid" > <cfthread action="run" name="t#threadCount#" output="to#threadCount#"> <cfsavecontent variable="thisContent"> <cfquery name="thisQuery" datasource="dsource"> ... </cfquery> <cfchart > ... </cfchart> </cfsavecontent> </cfthread> ... </cfloop> <cfloop array="#uuids#" index="uuid" > <cfthread action="join" name="t#threadCount#"/> #thisContent# </cfloop> </body>
My problem I am facing is dynamically changing names / calls. I'm sure this is a very simple fix, but if I were to name each content by a name that I knew would be created, it was displayed, even though this denied the purpose of using dynamic variables. But this is another battle! Answer: yes, you can use cfsavecontent with cfcharts inside cfthread.
source to share