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

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

问题描述

请考虑以下代码,现在我在< body> .cfm $ c> tag:

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.

我已包括以下< cfchart> code>< cfquery> 标记下面的标记如下:

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>

我的问题:

事情是上面的图表只显示一个黄色的圆圈。我想在一个图表中显示由这两个查询检索的信息。例如
我得到%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 value),我可以看到饼图圆圈旁边的%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 =...> 的工作原理。它接受一个查询,这意味着所有的值必须包含在同一个查询中。

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天全站免登陆