【问题标题】:ColdFusion 9 CFCHART CFCHARTSERIES IssueColdFusion 9 CFCHART CFCHARTSERIES 问题
【发布时间】:2014-10-08 14:13:51
【问题描述】:

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

这是使用的代码:

<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>

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

在这个图表中(当只返回一个 APP_SYS_NR 时),不是只有一个标签,而是所有的日期都变成了标签。显然不是我想要的:

编辑:我已经将此追溯到 cfchart 的 showlegend 属性。根据 Adob​​e 的说法,如果图表包含多个数据系列,则是否显示图例。我猜当它只包含一个数据系列时,它会完全搞砸自己并做图例中的数据点。我在 ColdFusion 9 和 ColdFusion 10 上进行了测试。

【问题讨论】:

  • 请详细说明“显示不正确”。指定您希望看到的内容和实际看到的内容。
  • 看上面的两个图表。很明显,第二个显示不正确。它不应该将所有这些日期都列在顶部,就像它们是一个系列一样。相反,它应该看起来像第一个图表,但顶部列出了一个项目(涂黑部分在第一张图像中)。
  • 你不能把 showlegend 设置为 false 吗?我的意思是......你的问题是几十个日期图例项目吗?
  • 是的,我想出了一个解决方案。首先检查查询中有多少应用程序,然后基于此将图例设置为是/否。如果不是,我会显示一个带有单个应用程序名称的图表标题。

标签: coldfusion cfchart cfoutput


【解决方案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>

【讨论】:

    猜你喜欢
    • 2011-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多