當前位置:編程學習大全網 - 源碼下載 - asp 用fusionchart做圖表,怎麽讀取access數據庫中的數據用到fusionchart中?

asp 用fusionchart做圖表,怎麽讀取access數據庫中的數據用到fusionchart中?

第壹步:用asp連接access查詢數據表中的數據。

第二步:根據fusionchart 調用的js文件中的"data": [{..}]部分,按照固定格式輸出;

此步驟是關鍵,就是按照fusionchart 要求輸出即可,有兩種方法,1是在當前HTML頁面中直接通過asp的 response.write(rs("value"));輸出數據庫內容。2是輸出內容以後保存js文檔,供html調用。

第三步:正常調用fusionchart 輸出圖表;

舉例子:

FusionCharts.ready(function?()?{

var?revenueChart?=?new?FusionCharts({

type:?'doughnut2d',

renderAt:?'chart-container',

width:?'450',

height:?'450',

dataFormat:?'json',

dataSource:?{

"chart":?{

"caption":?"Split?of?Revenue?by?Product?Categories",

"subCaption":?"Last?year",

"numberPrefix":?"$",

"paletteColors":?"#0075c2,#1aaf5d,#f2c500,#f45b00,#8e0000",

"bgColor":?"#ffffff",

"showBorder":?"0",

"use3DLighting":?"0",

"showShadow":?"0",

"enableSmartLabels":?"0",

"startingAngle":?"310",

"showLabels":?"0",

"showPercentValues":?"1",

"showLegend":?"1",

"legendShadow":?"0",

"legendBorderAlpha":?"0",

"defaultCenterLabel":?"Total?revenue:?$64.08K",

"centerLabel":?"Revenue?from?$label:?$value",

"centerLabelBold":?"1",

"showTooltip":?"0",

"decimals":?"0",

"captionFontSize":?"14",

"subcaptionFontSize":?"14",

"subcaptionFontBold":?"0"

},

"data":?[

//原js文件中的格式要求部分

//{

//"label":?"Food",

//"value":?"28504"

//},?

//{

//"label":?"Apparels",

//"value":?"14633"

//},?

//{

//"label":?"Electronics",

//"value":?"10507"

//},?

//{

//"label":?"Household",

//"value":?"4910"

//}

//註意這裏開始用asp輸出

<%

for?i=1?to?rs.recordcount

if?rs.eof?then?exit?for

if?i<rs.recordcount?then

response.write("{"label":"?&?rs("name")?&?",")

response.write(""value":")?&?rs("value")?&?"},")

else

response.write("{"label":"?&?rs("name")?&?",")

response.write(""value":")?&?rs("value")?&?"}")

end?if

rs.movenext:next

%>

]

}

}).render();

});

  • 上一篇:如何推動企業思想政治工作與時俱進
  • 下一篇:HP 5100的功能特性
  • copyright 2024編程學習大全網