Cfchart challenge

How can we make cfchart generate meaning chart when data deviation is in four decimal points? here’s some sample data,

11/09/2019 --> 0.9063
11/10/2019 --> 0.9062
11/11/2019 --> 0.9063
11/13/2019 --> 0.9086
11/14/2019 --> 0.9093
11/15/2019 --> 0.9063
11/18/2019 --> 0.9041
11/20/2019 --> 0.9028
11/20/2019 --> 0.9042
11/21/2019 --> 0.9016
11/22/2019 --> 0.9043
11/25/2019 --> 0.9084
Thanks.

Use scaleFrom and scaleTo in cfchart to shrink the range.

1 Like

Awesome. It works. Thank you.

Hi,

Is there a way to turn

y
0.7925
  0.79
0.7875

into

y
0.7925
0.7900
0.7875

Thanks.

numberformat() function should work. I think you have to use “0” mask.

1 Like

It makes sense. however, neither of the following tasks for numberformat works to append the two 00 s when needed.
‘__.0000’
nor
‘.0000’

What version of Lucee are you using. I just tested on TryCF.com and it worked just fine.

numberFormat(0.79, "__.0000")

It works.

<cfoutput>
#numberFormat(0.79, "__.0000")#
</cfoutput>

With the following context, it does not work.

<cfset myItem ="balbal">
<cfset myValue = ".79">
<cfchartdata item="#myItem#" value="#numberFormat(myValue,'__.0000')#">

lucee docker image: lucee4

I’m pretty sure cfchartdata converts to a Java number losing the formatting.
Can you make your chart x100 or something?
If not, there isn’t much you can do.

1 Like

Ok, it got me thinking, so, I tried the following:

<cfset myItem ="balbal">
<cfset myValue = "0.79">
<cfif len(myValue) eq 4>
	<cfset myValue = "#myValue#00">
	or
	<cfset myValue = "(#myValue# * 100)">
</cfif>		
<cfchartdata item="#myItem#" value="#myValue#">
or
<cfchartdata item="#myItem#" value="#decimalformat(myValue,'__.0000')#">

too bad, to no avail. Worth a try tho, much appreciated anyway.