更新:发现使用style属性指向图表文件夹中的json文件允许我设置样式并成功使用png
我遇到了一个问题,不确定我是否忽略了限制或是否还有其他事情发生。我们正在从CF10迁移到CF2016,并解决了与图表的一些差异。我看到可以应用的JSON样式,可能会满足我们的需求。但是,当我们将格式设置为png时,会产生错误。
以下是cfchart documentation的图例样式部分中的确切代码,唯一的区别是从html到png的更改。
<cfscript>
legend={"background-color":"lightgray"};
</cfscript>
<cfchart format="png" title="Graph" chartHeight="400" chartWidth="600" showLegend="yes" legend="#legend#">
<cfchartseries type="line" serieslabel="WBC" markerstyle="circle" color="red">
<cfchartdata item="Day 1" value="19.2"/>
<cfchartdata item="Day 2" value="15.2"/>
<cfchartdata item="Day 3" value="15.1"/>
<cfchartdata item="Day 4" value="12.6"/>
<cfchartdata item="Day 5" value="14.2"/>
</cfchartseries>
<cfchartseries type="line" serieslabel="HCT" markerstyle="diamond" color="blue" >
<cfchartdata item="Day 1" value="39.2"/>
<cfchartdata item="Day 2" value="35.2"/>
<cfchartdata item="Day 3" value="35.1"/>
<cfchartdata item="Day 4" value="32.6"/>
<cfchartdata item="Day 5" value="34.2"/>
</cfchartseries>
</cfchart>
只需将格式翻转为png会导致以下错误。 (只需进入trycf.com并选择CF2016引擎即可看到完整错误)
Cause:
[struct]
Message: For input string: "NaN"
StackTrace: java.lang.NumberFormatException: For input string: "NaN"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at com.zingchart.Utils.parseColor(Utils.java:31)
at com.zingchart.Context2d.jsSet_fillStyle(Context2d.java:159)
(clipped)
Suppressed:
[array]
TagContext:
[array]
1) [struct]
COLUMN: 0
ID: CF_OPTRUNTIME
LINE: 1
RAW_TRACE: at org.mozilla.javascript.gen.c9._c0(:1)
TEMPLATE:
TYPE: CFML
2) [struct]
COLUMN: 0
ID: CFCHART
LINE: 18
RAW_TRACE: at cfmain15096445073382d5ed396b32dbea22da2472da7a72d2f4286abb0062ecfm2dEBEF295F2dD9242d08502d97FAE6A3861669DA2ecfm439568922.runPage(EBEF3FC8-F3B7-F956-B1B68C22EC270E13-EBEF295F-D924-0850-97FAE6A3861669DA.cfm:18)
TEMPLATE: EBEF3FC8-F3B7-F956-B1B68C22EC270E13-EBEF295F-D924-0850-97FAE6A3861669DA.cfm
TYPE: CFML
3) [struct]
COLUMN: 0
ID: CFINCLUDE
LINE: 168
RAW_TRACE: at cfcfmler2ecfc1489966816$func$RUNIT.runFunction(/home/webs/sbx/www/cfmler.cfc:168)
TEMPLATE: /home/webs/sbx/www/cfmler.cfc
TYPE: CFML
4) [struct]
COLUMN: 0
ID: CF_UDFMETHOD
LINE: 79
RAW_TRACE: at cfcfmler2ecfc1489966816$funcPLAYCFMFILE.runFunction(/home/webs/sbx/www/cfmler.cfc:79)
TEMPLATE: /home/webs/sbx/www/cfmler.cfc
TYPE: CFML
5) [struct]
COLUMN: 0
ID: CF_TEMPLATEPROXY
LINE: 81
RAW_TRACE: at cfgetremote2ecfm1955103781.runPage(/home/webs/sbx/www/getremote.cfm:81)
TEMPLATE: /home/webs/sbx/www/getremote.cfm
TYPE: CFML
Type: java.lang.NumberFormatException
ColumnNumber: 0
LineNumber: 1
Message: Wrapped java.lang.NumberFormatException: For input string: "NaN" (#1)
ScriptStackTrace: [empty string]
SourceName:
StackTrace: org.mozilla.javascript.WrappedException: Wrapped java.lang.NumberFormatException: For input string: "NaN" (#1)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1773)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:183)
at org.mozilla.javascript.ScriptableObject.putImpl(ScriptableObject.java:2109)
at org.mozilla.javascript.ScriptableObject.put(ScriptableObject.java:319)
at org.mozilla.javascript.ScriptableObject.putProperty(ScriptableObject.java:1729)
at org.mozilla.javascript.ScriptRuntime.setObjectProp(ScriptRuntime.java:1557)
at org.mozilla.javascript.ScriptRuntime.setObjectProp(ScriptRuntime.java:1547)
at com.zingchart.zingchart_rhino_min._c_anonymous_250(Unknown Source)
at com.zingchart.zingchart_rhino_min.call(Unknown Source)
(clipped)
Suppressed:
[array]
TagContext:
[array]
1) [struct]
COLUMN: 0
ID: CF_OPTRUNTIME
LINE: 1
RAW_TRACE: at org.mozilla.javascript.gen.c9._c0(:1)
TEMPLATE:
TYPE: CFML
2) [struct]
COLUMN: 0
ID: CFCHART
LINE: 18
RAW_TRACE: at cfmain15096445073382d5ed396b32dbea22da2472da7a72d2f4286abb0062ecfm2dEBEF295F2dD9242d08502d97FAE6A3861669DA2ecfm439568922.runPage(EBEF3FC8-F3B7-F956-B1B68C22EC270E13-EBEF295F-D924-0850-97FAE6A3861669DA.cfm:18)
TEMPLATE: EBEF3FC8-F3B7-F956-B1B68C22EC270E13-EBEF295F-D924-0850-97FAE6A3861669DA.cfm
TYPE: CFML
3) [struct]
COLUMN: 0
ID: CFINCLUDE
LINE: 168
RAW_TRACE: at cfcfmler2ecfc1489966816$func$RUNIT.runFunction(/home/webs/sbx/www/cfmler.cfc:168)
TEMPLATE: /home/webs/sbx/www/cfmler.cfc
TYPE: CFML
4) [struct]
COLUMN: 0
ID: CF_UDFMETHOD
LINE: 79
RAW_TRACE: at cfcfmler2ecfc1489966816$funcPLAYCFMFILE.runFunction(/home/webs/sbx/www/cfmler.cfc:79)
TEMPLATE: /home/webs/sbx/www/cfmler.cfc
TYPE: CFML
5) [struct]
COLUMN: 0
ID: CF_TEMPLATEPROXY
LINE: 81
RAW_TRACE: at cfgetremote2ecfm1955103781.runPage(/home/webs/sbx/www/getremote.cfm:81)
TEMPLATE: /home/webs/sbx/www/getremote.cfm
TYPE: CFML
Type: org.mozilla.javascript.WrappedException
WrappedException:
[struct]
Message: For input string: "NaN"
StackTrace: java.lang.NumberFormatException: For input string: "NaN"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at com.zingchart.Utils.parseColor(Utils.java:31)
at com.zingchart.Context2d.jsSet_fillStyle(Context2d.java:159)
at sun.reflect.GeneratedMethodAccessor149.invoke(Unknown Source)
(clipped)
Suppressed:
[array]
TagContext:
[array]
1) [struct]
COLUMN: 0
ID: CF_OPTRUNTIME
LINE: 1
RAW_TRACE: at org.mozilla.javascript.gen.c9._c0(:1)
TEMPLATE:
TYPE: CFML
2) [struct]
COLUMN: 0
ID: CFCHART
LINE: 18
RAW_TRACE: at cfmain15096445073382d5ed396b32dbea22da2472da7a72d2f4286abb0062ecfm2dEBEF295F2dD9242d08502d97FAE6A3861669DA2ecfm439568922.runPage(EBEF3FC8-F3B7-F956-B1B68C22EC270E13-EBEF295F-D924-0850-97FAE6A3861669DA.cfm:18)
TEMPLATE: EBEF3FC8-F3B7-F956-B1B68C22EC270E13-EBEF295F-D924-0850-97FAE6A3861669DA.cfm
TYPE: CFML
3) [struct]
COLUMN: 0
ID: CFINCLUDE
LINE: 168
RAW_TRACE: at cfcfmler2ecfc1489966816$func$RUNIT.runFunction(/home/webs/sbx/www/cfmler.cfc:168)
TEMPLATE: /home/webs/sbx/www/cfmler.cfc
TYPE: CFML
4) [struct]
COLUMN: 0
ID: CF_UDFMETHOD
LINE: 79
RAW_TRACE: at cfcfmler2ecfc1489966816$funcPLAYCFMFILE.runFunction(/home/webs/sbx/www/cfmler.cfc:79)
TEMPLATE: /home/webs/sbx/www/cfmler.cfc
TYPE: CFML
5) [struct]
COLUMN: 0
ID: CF_TEMPLATEPROXY
LINE: 81
RAW_TRACE: at cfgetremote2ecfm1955103781.runPage(/home/webs/sbx/www/getremote.cfm:81)
TEMPLATE: /home/webs/sbx/www/getremote.cfm
TYPE: CFML
Type: java.lang.NumberFormatException
我是否忽略了CF 2016中cfchart的限制,或者这只是我需要报告的错误?我有最新的更新。有什么建议吗?
答案 0 :(得分:0)
示例代码来自CF文档,但正如您所示,它在切换到PNG格式时失败。
错误信息是线索;消息:对于输入字符串:&#34; NaN&#34;。
显然,当您使用PNG格式时,它无法弄清楚如何使用CSS样式表颜色名称并需要颜色代码。
例如,这将起作用并将图例的背景颜色设置为红色。
<cfscript>
legend={"background-color":"ff0000"};
</cfscript>