CFCHARTs with Custom Markers

Last night I blogged about a typo in the CF Reference in regards to charts and markers. The docs make reference to a marker style called ‘letter’, whereas the real setting is ‘letterx’. The user I was communicating with about this issue asked if there was someway to use other letters. So for example, letterA or letterB. While you can’t do that, I did discover that the Chart Editor has an option to specify a graphic for the marker. If you expand the Elements attribute in the editor, then Series, you can edit the Marker attribute. This is a per series setting so you want to add an index value in the blank field and click Add before modifying the settings. The index value must be a number. I used 0 as I assumed that it would match the 1st series in my chart:

I selected Bitmap and picked an image. The XML generated from this change is:

<series index="0"> <marker type="Bitmap" bitmap="/Users/ray/Desktop/unicorn4.gif"/> </series>

Here is a full example. The XML is a bit verbose and you don’t need a lot of what is in here, but the final example is nice.

<cfsavecontent variable="cxml"> <?xml version="1.0" encoding="UTF-8"?> <frameChart is3D="false"> <frame xDepth="3" yDepth="1" leftAxisPlacement="Back" isHStripVisible="true"> <background minColor="#FDFEF6"/> </frame> <xAxis> <labelFormat pattern="#,##0.###"/> <parseFormat pattern="#,##0.###"/> </xAxis> <legend isVisible="false"> <decoration style="None"/> </legend> <elements place="Default" shape="Line" drawShadow="true"> <morph morph="Grow"/> <series index="0"> <marker type="Bitmap" bitmap="/Users/ray/Desktop/unicorn4.gif"/> </series> </elements> </frameChart> </cfsavecontent>

<cfchart style=”#cxml#” scalefrom=”0” scaleto=”100”> <cfchartseries type=”line” seriesColor=”##FF0099”> <cfchartdata item=”col1” value=”20”> <cfchartdata item=”col2” value=”30”> <cfchartdata item=”col3” value=”10”> <cfchartdata item=”col4” value=”80”> <cfchartdata item=”col5” value=”60”> </cfchartseries> </cfchart> </code>

And the result? The most beautiful chart in the world.

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.

Lafayette, LA