mctobey
mctobey

Reputation: 31

CF11 CFChart pie, labelformat="percent" not displaying %

How do I display a % with the value. labelForms="percent" doesn't seem to work, its clunky adding it to the item, am I missing a way to format it?:

<CFSET PercentLocked = 0>
<cfset PercentUnlocked = 0>
<cfset PercentOpenQueries = 0>
<cfset PercentOpenErrors = 29>
<cfset PercentClean = 71>

<cfchart    
    type="pie"                                          
    chartWidth="800"  
    show3d="true"
    font="times"
    style="blue"
    labelformat="percent">
    <cfchartseries >    
        <cfchartdata item="Locked Forms (#Percentlocked#%)" value="#PercentLocked#" > 
        <cfchartdata item="unLocked Forms (#PercentUnlocked#%)" value="#PercentUnlocked#">  
        <cfchartdata item="Forms w/Open Queries (#PercentOpenQueries#%) " value="#PercentOpenQueries#"> 
        <cfchartdata item="forms w/Errors  (#PercentOpenErrors#%) " value="#PercentOpenErrors#">
        <cfchartdata item="Clean forms (#PercentClean#%)" value = "#PercentClean#">
    </cfchartseries>
</cfchart>

PieChart

Upvotes: 1

Views: 163

Answers (1)

SOS
SOS

Reputation: 6550

Googling led to this ZingChart example involving the "plot" attribute. According to the ZingChart pie chart docs, several "tokens" are supported for use in customizing the text/values displayed

  • %npv - The percentage value of the pie slice (node) relative to the entire pie (sum of all nodes)
  • %t - The text of the current plot, pulled from the text attribute in the plot/series object

This example displays both the item text and value (as a percentage):

TryCF.com Example

<cfset plot = { "value-box":{
      "visible":true,
      "placement":"out",
      "text":"%t (%npv%)"
    }}>

<cfchart    
    type="pie"                                          
    chartWidth="800"  
    show3d="true"
    font="times"
    style="blue"
    plot="#plot#">
    <cfchartseries >    
        <cfchartdata item="Locked Forms" value="0" > 
        <cfchartdata item="UnLocked Forms" value="0">  
        <cfchartdata item="Forms w/Open Queries" value="0"> 
        <cfchartdata item="forms w/Errors" value="29">
        <cfchartdata item="Clean Forms" value = "71">
    </cfchartseries>
</cfchart>

Pie Chart with Labels

Upvotes: 0

Related Questions