使用 cfchart 标签在单个饼图中显示来自多个查询的数据 [英] Displaying data from multiple queries in a single pie chart using cfchart tag

查看:27
本文介绍了使用 cfchart 标签在单个饼图中显示来自多个查询的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请考虑以下代码,现在我的 <body> 标签内的 .cfm 页面中有以下代码:

Please consider the following code, right now I have the following code in my .cfm page inside the <body> tag:

DataSource = xx.xx.x.xx
Name of the database = sgemail
Name of the relevant column = event_vc 

基本上我已经计算了以下查询中打开连接的百分比.

Basically I have calculated the percentage of the open connections in the following queries.

<cfquery datasource = "xx.xx.x.xx" name="qSen">

SELECT (select count(*) 
        FROM sgemail) AS TOTAL_CONNECTIONS,
        (SELECT count(*) 
        FROM sgemail 
        WHERE event_vc = "open") AS OPEN_CONNECTIONS,
        (ROUND((SELECT OPEN_CONNECTIONS / (TOTAL_CONNECTIONS))*100)) AS "% OPEN" ;
</cfquery>


<cfquery datasource = "xx.xx.x.xx" name="qSen">

SELECT (select count(*) from sgemail) AS TOTAL_CONNECTIONS,
(SELECT count(*) from sgemail where event_vc = "BOUNCE") AS BOUNCE_CONNECTIONS,
(ROUND((SELECT BOUNCE_CONNECTIONS / (TOTAL_CONNECTIONS))*100)) AS "% BOUNCE" ;
</cfquery>

基本上"% OPEN" 和`"% BOUNCE" 用于显示连接打开和从数据库反弹的百分比.

Basically "% OPEN" and `"% BOUNCE" are used to display the percentage of connections open and bounce from the database.

我在上面的 <cfquery> 标记下面包含了以下 <cfchart> 标记,如下所示:

I have included the following <cfchart> tag below the above <cfquery> tag as follows:

<cfchart
         format="png"
         scalefrom="0"
         scaleto="1200000"
         pieslicestyle="solid">

         <cfchartseries
          type="pie"
          serieslabel="Website Traffic 2006"
          seriescolor="blue"
          query = "qSengrid"
          valuecolumn="% OPEN"

          itemcolumn=""
          >

    </cfchartseries>
</cfchart>

我的问题:

1) 问题是上面的图表只显示了一个黄色圆圈.我想在一个图表中显示两个查询检索到的信息.例如我为 %OPEN 获得的值是 30,我为 %Bounce 获得的值是 20.我还有其他查询返回不同的值,这使得整个饼图到 100,但为了这个问题的简单起见,我只包含了两个 cfqueries.请让我知道如何进行下一步.

1) The thing is that the above chart is displaying only one circle with yellow color. I want to display the information retrieved by both the queries in one chart. For example the value I'm getting for %OPEN is 30 and value I'm getting for %Bounce is 20. I have other queries as well which return different values which makes the whole pie chart to 100 but I have included only two cfqueries for the sake of simplicity for this question. Please let me know how to proceed further.

2) 另外,当我注释掉第二个查询(我得到 % Bounce 值的地方)时,我可以在旁边看到 %OPEN 的值饼图的圆圈.但是,当我同时运行上面提到的只有一个 <cfchart> 的查询(使用 valuecolumn = %OPEN )我看不到圆圈旁边写的任何值.

2) Also, when I commented out the second query (where I'm getting % Bounce value), I can see the value of %OPEN next to the circle of the pie-chart. However, when I run both the queries with only one <cfchart> mentioned above (with valuecolumn = %OPEN ) I can't see any value written next to the circle.

请回答我的上述问题,如果有任何问题我可以回答,请告诉我.

Please answer my above questions and let me know if there are any questions I can answer.

推荐答案

(来自评论)

通过重复使用相同的查询名称,您很可能会覆盖以前的结果.此外,这不是 <cfchartseries query="..."> 的工作方式.它接受 single 查询,这意味着所有值必须包含在同一个查询中.

By using reusing the same query name, you are most likely overwriting the previous results. In addition, that is not how <cfchartseries query="..."> works. It accepts a single query, which means all of the values must be contained in the same query.

如果您必须使用单独的查询,请为每个查询指定一个唯一的名称,并为 每个 值使用单独的 <cfchartdata> 标记:

If you must use separate queries, give each query a unique name and a use separate <cfchartdata> tag for each value:

<cfchart format="png">
    <cfchartseries type="pie">
         <cfchartdata item="% Open" value="#qTotalOpen.TotalNumber#">
         <cfchartdata item="% Bounce" value="#qTotalBounced.TotalNumber#">
         ... other values ...
    </cfchartseries>
</cfchart>

这篇关于使用 cfchart 标签在单个饼图中显示来自多个查询的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆