3

I am working on ColdFusion 9 - cfchart, Here is part of my code

<cfchart  format="flash" show3d="true"  title="Assigned Amount vs Projection Amount" scaleto="#scaleToForAmount#" scaleFrom="0"  backgroundColor="white" font="Arial" seriesplacement="stacked" chartHeight="400" chartWidth="800" labelFormat="number" > 
    <cfchartseries  type="bar"  query="chartData" itemcolumn="#variables.columnList[1]#Name" valuecolumn="PAID" seriesColor="##155D7F" seriesLabel="amout" paintStyle="plain" > 
    </cfchartseries> 
    <cfchartseries  type="bar"  query="chartData" itemcolumn="#variables.columnList[1]#Name" valuecolumn="PTP" seriesColor="##2AB9FF" paintStyle="plan" seriesLabel="PTP" > 
    </cfchartseries>
    <cfchartseries  type="bar"  query="chartData" itemcolumn="#variables.columnList[1]#Name" valuecolumn="PDC" seriesColor="##0A2E40" paintStyle="domain" seriesLabel="PDC" > 
   </cfchartseries>

But i am getting problem when value of scaleTo Increase beyond integer limit it show error. Even when converting it to string, double or bigInt it is not accepting those values. And continue to show error that "Cannot convert the value 3.1616321275E9 to an integer because it cannot fit inside an integer". Can anyone help me to get out of this.

Santosh D.
  • 537
  • 6
  • 19
  • Not a great answer I know, but my suggestion would be to use a Javascript charting library instead of cfchart, for example ChartJS / Flot / D3 etc – John Whish Mar 22 '16 at 13:00

1 Answers1

2

You are passing a float value to scaleTo attribute. The scaleTo attribute expects an integer value.

I will also suggest not to use flash format for chart. The flash format has been depricated in the newer version of CF. It will throw an error if your code is migrated to the newer version of CF.

Update:

ColdFusion supports integers between -2,147,483,648 and 2,147,483,647 (32-bit signed integers). You can assign a value outside this range to a variable. ColdFusion initially stores the number as a string. If you use it in an arithmetic expression or operation related to number, ColdFusion converts it into a floating-point value, preserving its value, but losing precision. The value 3161632127 is out of range. Hence CF is converting the value to the float. And since the value is float, CF is throwing an error. Check out the document.

Tushar Bhaware
  • 2,525
  • 1
  • 16
  • 29
  • Thank you for your responce, but value passed to scaleTo is actually bigInteger. in above code it is 3161632127 but don't know why coldfusion shows error message. and convert this value to like 3.1616321275E9 this. – Santosh D. Mar 22 '16 at 13:25
  • @SantoshDahifale - What you pass in does not really matter. What is important is what the scaleTo attribute will accept. As the documentation says, it only accepts integers. So no matter how you slice it, anything bigger than that is not going to work. – Leigh Mar 22 '16 at 19:48
  • 1
    @Tushar Bhaware - *RE: since the value is float, CF is throwing an error* Well, technically it is because the number is too big, not because it is a floating point number (ie java.lang.Double). CF will happily convert the input to the expected type - IF it is small enough to fit inside an Integer. – Leigh Mar 22 '16 at 20:03