Single or double quotation marks in SERIESLABEL or ITEMLABEL giving an error in CFCHART

I am using a CF pie chart for one of my applications. But it works weird. The following code is the chart code and it gives an error. It does not even display a chart. I know that this is due to the presence of double quotation marks within the meaning of the query column col1.

<cfoutput>
    <script type="text/javascript">
        function Navigate(test){
            alert(test);
        }
    </script>

<cfset testquery = queryNew("col1,Col2", "varchar,varchar") >
<cfset queryAddRow(testquery, 1)>
<cfset querySetCell(testquery, "col1", 'This is the "first" row') >
<cfset querySetCell(testquery, "Col2", 5000) >
<cfset queryAddRow(testquery, 1)>
<cfset querySetCell(testquery, "col1", 'This is the second row') >
<cfset querySetCell(testquery, "Col2", 2500) >
<cfset queryAddRow(testquery, 1)>
<cfset querySetCell(testquery, "col1", 'This is the third row') >
<cfset querySetCell(testquery, "Col2", 8500) >

    <CFCHART Format="Html"  CHARTWIDTH="600" CHARTHEIGHT="650" TITLE="Pie Chart in CF11" URL="javascript:Navigate('$SERIESLABEL$')">
        <CFCHARTSERIES TYPE="pie" COLORLIST="##CA5940,##6FCF42,##4286CF" >
        <CFLOOP FROM="1" TO="#testquery.RecordCount#" INDEx="i">
            <CFCHARTDATA ITEM="#testquery.col1[i]#" VALUE="#testquery.Col2[i]#">
        </CFLOOP>
        </CFCHARTSERIES>
    </CFCHART>
</cfoutput>

enter image description here

I checked the JSON diagram in the viewource, this is normal. But the code gives the error above. Therefore, I’m not sure why he gives an error. Without double quotes, the code works as expected, but I need double quotes, this will affect the application if I delete it.

I also tried replacing double quotes with single quotes, in this case the chart displays, but if we click on the first line, it will give the same error in the console.

enter image description here

, . , , , , .

, - , - .

+4
1

JSON?

, :

<cfset querySetCell(testquery, "col1", 'This is the \"first\" row') >

trycf.com , ,

http://trycf.com/gist/e3321edb3481411078b75ad187cae52b/acf11?theme=monokai

ColdFusion 11, . , , ? , - , . , , , ColdFusion .

, , , ScottJibben JSStringFormat(), .

<CFCHARTDATA ITEM="#JSStringFormat(testquery.col1[i])#" VALUE="#testquery.Col2[i]#">
+4

Source: https://habr.com/ru/post/1667886/


All Articles