请考虑以下代码:
在我的文件标题内跟随标签
<script>
var chart;
var chartData = [{
ConnectionType: "First",
NumberPercentage: 1194,
{
ConnectionType: "Second",
NumberPercentage: 1882},
{
ConnectionType: "Third",
NumberPercentage: 1809},
{
ConnectionType: "Fourth",
NumberPercentage: 1322},
{
ConnectionType: "Fifth",
NumberPercentage: 1122},
{
ConnectionType: "Sixth",
NumberPercentage: 1114},
{
ConnectionType: "Seventh",
NumberPercentage: 984}
];
AmCharts.ready(function() {
// PIE CHART
chart = new AmCharts.AmPieChart();
// title of the chart
chart.addTitle("3D Donut Charts", 16);
chart.dataProvider = chartData;
chart.titleField = "ConnectionType";
chart.valueField = "NumberPercentage";
chart.sequencedAnimation = true;
chart.startEffect = "elastic";
chart.innerRadius = "30%";
chart.startDuration = 2;
chart.labelRadius = 15;
// the following two lines makes the chart 3D
chart.depth3D = 10;
chart.angle = 15;
// WRITE
chart.write("chartdiv");
});
</script>
我的个人资料的正文标签内的以下标签:
<div id="chartdiv" style="width: 100%; height: 362px;"></div>
cfquery
我想在我的 ColdFusion 文件中返回以下数据。为了简单起见,我只提到cfquery
第一个连接。除名称外,其余 cfqueries 直到第七个都相同。
<cfquery datasource = "XX.XX.X.XX" name="qCFCHART">
SELECT
Count(*) AS TOTAL_CONNECTION
, Sum(CASE WHEN 'FIRST' = EVENTS THEN 100 END) / Count(*) AS FIRST
, Sum(CASE WHEN 'SECOND' = EVENTS THEN 100 END) / Count(*) AS SECOND
, Sum(CASE WHEN 'THIRD' = EVENTS THEN 100 END) / Count(*) AS THIRD
, Sum(CASE WHEN 'FOURTH' = EVENTS THEN 100 END) / Count(*) AS FOURTH
, Sum(CASE WHEN 'FIFTH' = EVENTS THEN 100 END) / Count(*) AS FIFTH
, Sum(CASE WHEN 'SIXTH' = EVENTS THEN 100 END) / Count(*) AS SIXTH
, Sum(CASE WHEN 'SEVENTH' = EVENTS THEN 100 END) / Count(*) AS SEVENTH
FROM MyDatabase;
</cfquery>
考虑上面脚本中的代码:
ConnectionType: "First",
NumberPercentage: 1194,
我想将上述查询中“FIRST”返回的结果显示到我的饼图中,并且写cfdump
或任何与 ColdFusion 相关的东西都不起作用。
例如:
ConnectionType: "First",
NumberPercentage: <cfdump var="#qCFCHART.FIRST#>",
以上引发了一个错误,我看到了一个明显的原因,因为我在脚本标签内,我想知道如何继续?有什么建议么?
这是我在遵循一些评论后的尝试:
<cfoutput query="qCFCHART">
#currentrow#)
<cfloop index="col" list="#columnlist#">
#col#=#qCFCHART[col][currentRow]#
</cfloop>
<p/>
</cfoutput>
<cfset cols = getMetadata(qCFCHART)>
<cfdump var="#cols#">