1

更新:发现使用样式属性指向图表文件夹中的 json 文件允许我设置样式并成功使用 png

我遇到了一个问题,不确定我是否忽略了限制或是否发生了其他事情。我们正在从 CF10 迁移到 CF2016,并通过图表解决一些差异。我看到可以应用的 JSON 样式并且可能会满足我们的需求。但是,当我们将格式设置为我们需要的 png 时,会产生错误。

这是cfchart 文档的图例样式部分的确切代码,唯一的区别是从 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 会导致以下错误。(只需选择 CF2016 引擎进入 trycf.com 即可查看完整错误)

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 的限制,或者这只是我需要报告的错误?我有最新的更新。有什么建议么?

4

1 回答 1

0

示例代码来自 CF 文档,但正如您所展示的,切换到 PNG 格式时它会失败。

错误信息是线索;消息:对于输入字符串:“NaN”。

显然,当您使用 PNG 格式时,它无法弄清楚如何使用 CSS 样式表颜色名称并需要颜色代码。

例如,这将起作用并将图例的背景颜色设置为红色。

<cfscript>
    legend={"background-color":"ff0000"};
</cfscript>
于 2017-11-03T12:42:24.907 回答