如何在ColdFusion 11中的现有代码中使用ZingCharts实用程序?
我最近将我的应用程序从ColdFusion 10迁移到了ColdFusion 11。虽然迁移成功,但图表已被销毁。 在ColdFusion 10之前,在如何在ColdFusion 11中的现有代码中使用ZingCharts实用程序?,coldfusion,coldfusion-11,zingchart,cfchart,Coldfusion,Coldfusion 11,Zingchart,Cfchart,我最近将我的应用程序从ColdFusion 10迁移到了ColdFusion 11。虽然迁移成功,但图表已被销毁。 在ColdFusion 10之前,在\lib目录中有一个WebCharts JAR文件,名为wc50.JAR。其中包括com.gp.api.jsp.MxServerComponent等图表模块。该JAR文件在ColdFusion 11中不存在。因此,我们决定更新“制图代码”,并决定使用新的ZingChart ZingChart是基于JSON的。我分析并发现ColdFusion 11
\lib
目录中有一个WebCharts JAR文件,名为wc50.JAR
。其中包括com.gp.api.jsp.MxServerComponent
等图表模块。该JAR文件在ColdFusion 11中不存在。因此,我们决定更新“制图代码”,并决定使用新的ZingChart
ZingChart是基于JSON的。我分析并发现ColdFusion 11中有一个实用程序,可用于将XML内容转换为JSON。该实用程序的名称是cfchart\u xmltojson.bat
。这就是我目前的分析我的问题是-如何运行/使用此实用程序进行转换,然后修改我的图表代码?
我当前的图表代码如下所示:
<cfsaveContent variable="chartStyle">
<cfoutput>
<?xml version="1.0" encoding="UTF-8"?>
<frameChart isMultiline="false" is3D="#is3D#">
<frame outline="##666666"/>
<yAxis scaleMin="0" scaleMax="100"/>
<legend allowSpan="true" equalCols="false" placement="Right" isMultiline="true">
<decoration style="None"/>
</legend>
<cfif ShowPyramidNums>
<dataLabels style="value" placement="Inside" font="Arial-12-bold" >
</dataLabels>
</cfif>
<elements place="Stacked" shape="PyramidCut" shapeSize="100">
<movie framesPerSecond="2"/>
<cfset sPerfCtr = 0>
<cfloop index="i" from="#q_PerformanceDetailsByTemp.RecordCount#" to="1" step="-1">
<series index="#Evaluate(sPerfCtr)#">
<paint color="###q_PerformanceDetailsByTemp.ChartColor[i]#"/>
</series>
<cfset sPerfCtr = sPerfCtr+1>
</cfloop>
</elements>
<table>
<decoration style="Shadow"/>
</table>
<background maxColor="white"/>
<decoration foreColor="white" backColor="##90FFFF"/>
<popup showOn="Disabled" isAntialiased="true"/>
<paint palette="Transluent" paint="Plain" max="52"/>
</frameChart>
</cfoutput>
</cfsaveContent>
<cfsavecontent variable="chartModel">
<cfoutput>
<?xml version="1.0" encoding="UTF-8"?>
<XML type="default">
<COL>Fall</COL>
<COL>Winter</COL>
<COL>Spring</COL>
<cfset over100FallFixed = false>
<cfset over100WinterFixed = false>
<cfset over100SpringFixed = false>
<cfloop index="i" from="#ArrayLen(PerfStats)#" to="1" step="-1">
<cfset rowVal = Evaluate((1/q_PerformanceDetailsByTemp.recordCount)*100)>
<cfif isDefined("over100Alert")>
<!--- This set of if statements is to modify value to show triangle correctly --->
<!--- Without this modification, the total ia 100.1 which cuts off the top of the triangle --->
<cfif right(PerfStats[i].FallPercentage, 1) GT 0 AND NOT over100FallFixed>
<cfset PerfStats[i].FallPercentage = PerfStats[i].FallPercentage - .1>
</cfif>
<cfif right(PerfStats[i].WinterPercentage, 1) GT 0 AND NOT over100WinterFixed>
<cfset PerfStats[i].WinterPercentage = PerfStats[i].WinterPercentage - .1>
</cfif>
<cfif right(PerfStats[i].SpringPercentage, 1) GT 0 AND NOT over100SpringFixed>
<cfset PerfStats[i].SpringPercentage = PerfStats[i].SpringPercentage - .1>
</cfif>
<ROW col0="#PerfStats[i].FallPercentage#" col1="#PerfStats[i].WinterPercentage#" col2="#PerfStats[i].SpringPercentage#">% #PerfStats[i].Name#</ROW>
<cfelse>
<ROW col0="#round(PerfStats[i].FallPercentage)#" col1="#round(PerfStats[i].WinterPercentage)#" col2="#round(PerfStats[i].SpringPercentage)#">% #PerfStats[i].Name#</ROW>
</cfif>
</cfloop>
</XML>
</cfoutput>
</cfsavecontent>
<cfscript>
ImageName = "TierTrans_" & CreateUUID() & ".png";
oMyWebChart = createObject("Java","com.gp.api.jsp.MxServerComponent");
oMyApp = getPageContext().getServletContext();
oSvr = oMyWebChart.getDefaultInstance(oMyApp);
oMyChart2 = oSvr.newImageSpec();
if(NOT Session.PDFIng)
{
oMyChart2.width = 650;
} else
{
oMyChart2.width = 550;
}
oMyChart2.height= 230;
oMyChart2.type = "png";
oMyChart2.style = "#chartStyle#";
oMyChart2.model = "#chartModel#";
</cfscript>
<cfif NOT DirectoryExists(ImagesDir)>
<CFDIRECTORY ACTION="CREATE" DIRECTORY="#ImagesDir#">
</cfif>
<!--- Save image to a different location --->
<cfset oSvr.saveBytesTo(oMyChart2,"#ImagesDir##ImageName#")>
<cfoutput><img src="Images/Reports/#ImageName#" border="0"/></cfoutput>
落下
冬天
春天
%#PerfStats[i].名称#
%#PerfStats[i].名称#
ImageName=“TierTrans_u3;”&CreateUUID()&“.png”;
myyWebChart=createObject(“Java”、“com.gp.api.jsp.MxServerComponent”);
myApp=getPageContext().getServletContext();
oSvr=myWebChart.getDefaultInstance(myApp);
2=oSvr.newImageSpec();
if(不是Session.PDFIng)
{
1.2.2宽度=650;
}否则
{
2.宽度=550;
}
2.高度=230;
2.type=“png”;
2.style=“#图表样式#”;
2.model=“#图表模型#”;
它用来画一张类似下图的图表。(您看到的水印是因为我将wc50.jar
从ColdFusion 10目录复制到了ColdFusion 11 lib目录):
(编辑)只是一个想法,但为什么不直接使用ZingCharts呢?这将避免下次Adobe更改图表工具时必须重新修复代码。。。。我没有使用
cfchart\u xmltojson.bat
,但是.bat源代码看起来只是调用了main()
一个java类的方法coldfusion.graph.XMLToJSON
有两个参数:xml文件的路径和CF\lib
目录的完整路径。@Ageax:如果我使用ZingCharts,那么我必须重写整个图表代码,我相信这将花费足够的时间。我只是想节省时间,改用这个工具。但是如果我没有得到使用这个工具的正确指导,那么我肯定会使用ZingChartShudding来解决类似的升级问题,不管怎样,可能需要一段时间来解决这些差异。也就是说,正如我上面提到的.bat文件只调用一个java类。它需要两个参数—都是完整路径:第一个指向要转换的xml文件,第二个指向CF\lib
目录。(如果您使用的是.bat文件,则会自动提供第二个参数。)尝试该文件时发生了什么?从:“…要执行此转换,您需要使用cfchart_xmltojson.bat.[用法]cfchart_xmltojson.bat
。转换后的JSON样式将在与XML文件相同的位置创建。”(编辑)只是一个想法,但是为什么不直接使用ZingCharts呢?这将避免下次Adobe更改图表工具时必须重新修复代码。。。。我没有使用cfchart\u xmltojson.bat
,但是.bat源代码看起来只是调用了main()
一个java类的方法coldfusion.graph.XMLToJSON
有两个参数:xml文件的路径和CF\lib
目录的完整路径。@Ageax:如果我使用ZingCharts,那么我必须重写整个图表代码,我相信这将花费足够的时间。我只是想节省时间,改用这个工具。但是如果我没有得到使用这个工具的正确指导,那么我肯定会使用ZingChartShudding来解决类似的升级问题,不管怎样,可能需要一段时间来解决这些差异。也就是说,正如我上面提到的.bat文件只调用一个java类。它需要两个参数—都是完整路径:第一个指向要转换的xml文件,第二个指向CF\lib
目录。(如果您使用的是.bat文件,则会自动提供第二个参数。)尝试该文件时发生了什么情况?从:“…要执行此转换,您需要使用cfchart_xmltojson.bat.[用法]cfchart_xmltojson.bat
。转换后的JSON样式将在与XML文件相同的位置创建。”