ColdFusion 9 CFCHART CFCHARTSERIES问题

时间:2014-10-08 14:13:52

标签: coldfusion cfchart cfoutput

我正在显示包含一个或多个系列的图表。如果图表上有多个系列,则数据来自查询并正常工作。但是,如果只返回一个系列,则表示无法正确显示。

以下是使用的代码:

<cfchart format="flash" tipstyle="mouseover" showlegend="yes" xaxistitle="Date" yaxistitle="Hits" chartwidth="1200" chartheight="300">
    <cfoutput query="qryReport" group="APP_SYS_NR">
        <cfchartseries serieslabel="#qryReport.APP_NA#" type="line">
        <cfoutput>
            <cfchartdata item="#DateFormat(qryReport.CDR_DT, "mm/dd/yyyy")#" value="#qryReport.TOT_HIT_CNT#">               
        </cfoutput>
        </cfchartseries>
    </cfoutput>
</cfchart>

此图表顶部的黑色区域列出了两条线代表的键: Working Chart

在此图表中(当只返回一个APP_SYS_NR时),所有日期都转换为标签,而不是只有一个标签。显然不是我想要的: Broken Chart

编辑:我已将此跟踪到cfchart的showlegend属性。根据Adobe的说法,如果图表包含多个数据系列,是否显示图例。我想当它只包含一个数据系列时,它完全扯下自己并在图例中处理数据点。我在ColdFusion 9和ColdFusion 10上进行了测试。

1 个答案:

答案 0 :(得分:1)

这里的解决方案是,当只有一个系列要显示时,将showlegend设置为no。相反,您应该在该实例中使用图表标题。请参阅以下修改后的代码:

<cfset VARIABLES.blnShowLegend = "no">
<cfset VARIABLES.strChartTitle = "#qryReport.APP_NA#">
<cfif ListLen(URL.lstApps) GT 1>
    <cfset VARIABLES.blnShowLegend = "yes">
    <cfset VARIABLES.strChartTitle = "">
</cfif>
<cfchart format="flash" title="#VARIABLES.strChartTitle#" tipstyle="mouseover" style="appstats" showlegend="#VARIABLES.blnShowLegend#" xaxistitle="Date" yaxistitle="Hits" chartwidth="1200" chartheight="300">
    <cfoutput query="qryReport" group="APP_SYS_NR">
        <cfchartseries serieslabel="#qryReport.APP_NA#" type="line">
        <cfoutput>
            <cfchartdata item="#DateFormat(qryReport.CDR_DT, "mm/dd/yyyy")#" value="#qryReport.TOT_HIT_CNT#">               
        </cfoutput>
        </cfchartseries>
    </cfoutput>
</cfchart>