CFChart axis label problem


Using CFCHART on Lucee, I can’t figure out how to space the horizontal axis labels. They are a series of dates and obviously take too much space. How do I specify to use only every 5th label for example instead of every one?
This used to work correctly on cf 8. The same code messes up the labels in Lucee.


I"m afraid I haven’t used CFML to generate charts in so long I’ve, honestly, forgotten how to even do it.

That said, however, Lucee uses JFreeChart under the hood. Perhaps you can glean some useful information from their documentation or forums to isolate a way to force the chart to do your bidding.

Personally, however, I’d honestly recommend using a client side charting library and replace any cfchart you’re currently using. Chartjs, FusionCharts and HighCharts are all popular and well supported options - but there are many, many others to choose from - both open source and commercial.

Not only will you get better performance but also greater flexibility and control over charting than you will with cfchart.


– Denny


Thanks for the response. I checked jfreechart and they really don’t have the documentation online - you have to purchase it. What little they had was greek to me. I don’t speak Java and have no idea how you would even use the java constructs within lucee.

I set up chartjs. It is pretty nice - much nicer charts than cfcharts but I use it to create pdfs and the charts do not show up in the pdfs. I have to look into it further.
Was hoping someone knew off the top of their head -just add xxxxxxx and it will work:)


I took a refresher look at cfchart but don’t see any way to control how many labels show up on the X axis. I assume ACF handles this situation differently than Lucee does in the sense that they limit the number of labels they’re passing in to the underlying engine… or, more likely, the underlying engine handles this differently than jfreechart does to begin with. It might be worth raising a ticket for this ( just in case something can be done.

As for the use case of generating PDF’s with HTML5 charts, and in my case just in general when creating PDFs, I use a WebKit to PDF solution ( to generate them, especially when they have images, charts or CSS styling that the native PDF library just doesn’t handle very well, if at all. This uses the WebKit browser engine under the hood so it produces whatever a browser would normally see.

You use cfexecute to generate the PDF and then you can use cfcontent, et al to deliver it to the browser (or download it, etc.). The basic syntax for firing off wkhtmltopdf is:

    name = "[/path/to]/wkhtmltopdf", 
    arguments = '-s letter --images --enable-local-file-access  
        [URL to generate PDF of] 
        [path to output pdf, incl filename]', 
    variable = '[variable to hold STDOUT]', 
    errorVariable = '[variable to hold STDERR]' 

wkhtmltopdf has a ton of options you can pass as arguments and lets you do all kinds of cool stuff you can’t do with the PDF extension for Lucee, and it produces better quality results from HTML to PDF conversions.

EDIT: I forgot to mention that you’ll have to do some delay and checking of file size before you attempt to deliver the PDF via cfcontent, as the cfexecute returns immediately but wkhtmltopdf is generally still generating the PDF. For example:

while( !fileExists( '[path to output pdf]' ) ) {
	sleep( 500 );

rc.fileSize = 0;

while( rc.fileSize eq 0
  OR rc.fileSize lt getFileInfo( '[path to output pdf]' ).size ) {
	rc.fileSize = getFileInfo( '[path to output pdf]' ).size;
	sleep( 500 );

cfcontent( type = "application/pdf", file='[path to output pdf]'  );
cfheader( name = "Content-Disposition", value = "attachment;filename='[filename]'" );


– Denny