Ask a Jedi: Moving the label of a pie chart to the right

Andy asks:

Dear Jedi. How can I get the legend to show up on the right of my pie chart. It seems perpetually stuck at the top. I'm using cf7 (and will upgrade to 8 in the next few months).

There is no direct way, but once again, the Chart Editor that ships with ColdFusion comes to the rescue. I loaded it up, selected a Pie chart, and edited the Legend property. I selected Right alignment, and took the generated XML. Now the XML I got had a few extra elements, but I stripped it down to this:

<?xml version="1.0" encoding="UTF-8"?> <pieChart> <legend placement="Right"/> </pieChart>

All together, the code then is:

<cfsavecontent variable="style"> <?xml version="1.0" encoding="UTF-8"?> <pieChart> <legend placement="Right"/> </pieChart> </cfsavecontent>

<cfchart format=”flash” show3d=”true” style=”#style#”> <cfchartseries type=”pie”> <cfchartdata item=”Like Pacman” value=”75”> <cfchartdata item=”Not like Pacman” value=”25”> </cfchartseries> </cfchart> </code>

Here is a screen shot of the default pie chart followed by the modified one. As you can see, the colors change a bit too, but if you don’t like the colors you can tweak that as well.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments