<% ' Page: FusionCharts.php ' Author: InfoSoft Global (P) Ltd. ' This page contains functions that can be used to render FusionCharts. ' encodeDataURL function encodes the dataURL before it's served to FusionCharts. ' If you've parameters in your dataURL, you necessarily need to encode it. ' Param: $strDataURL - dataURL to be fed to chart ' Param: $addNoCacheStr - Whether to add aditional string to URL to disable caching of data function encodeDataURL( strDataURL, addNoCacheStr ) 'Add the no-cache string if required Dim h, m, s If addNoCacheStr = "" Then addNoCacheStr = false if addNoCacheStr = True then ' We add ?FCCurrTime=xxyyzz ' If the dataURL already contains a ?, we add &FCCurrTime=xxyyzz ' We replace : with _, as FusionCharts cannot handle : in URLs h = Right( "0" & Hour(now), 2 ) m = Right( "0" & minute(now), 2 ) s = Right( "0" & second(now), 2 ) hms = h & "_" & m & "_" & s if instr( strDataURL,"?") >0 then strDataURL = strDataURL & "&FCCurrTime=" & hms else strDataURL = strDataURL & "?FCCurrTime=" & hms End If End if ' URL Encode it encodeDataURL = strDataURL End function ' datePart function converts MySQL database based on requested mask ' Param: $mask - what part of the date to return "m' for month,"d" for day, and "y" for year ' Param: $dateTimeStr - MySQL date/time format (yyyy-mm-dd HH:ii:ss) function date_Part(mask, dateTimeStr) Dim list_arr Dim datePt, timePt, arDatePt, dataStr Dim year_value, month_value, day_value list_arr = Split( dateTimeStr, " " ) datePt = list_arr(0) timePt = list_arr(1) arDatePt = Split(datePt, "-") dataStr = "" ' Ensure we have 3 parameters for the date if UBound(arDatePt) = 2 then year_value = arDatePt(0) month_value = arDatePt(1) day_value = arDatePt(2) ' determine the request Select Case mask Case "m" : date_Part = month_value Case "d" : date_Part = day_value Case "y" : date_Part = year_value Case Else date_Part = trim(month_value & "/"& day_value & "/" & year_value) End select ' default to mm/dd/yyyy End if date_Part = dataStr End function ' renderChart renders the JavaScript + HTML code required to embed a chart. ' This function assumes that you've already included the FusionCharts JavaScript class ' in your page. ' $chartSWF - SWF File Name (and Path) of the chart which you intend to plot ' $strURL - If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method) ' $strXML - If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method) ' $chartId - Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id. ' $chartWidth - Intended width for the chart (in pixels) ' $chartHeight - Intended height for the chart (in pixels) ' $debugMode - Whether to start the chart in debug mode ' $registerWithJS - Whether to ask chart to register itself with JavaScript function renderChart(chartSWF, strURL, strXML, chartId, chartWidth, chartHeight, debugMode, registerWithJS, setTransparent) If debugMode = "" Then debugMode = False If registerWithJS = "" Then registerWithJS = False If setTransparent = "" Then setTransparent = "" 'First we create a new DIV for each chart. We specify the name of DIV as "chartId"Div. 'DIV names are case-sensitive. ' The Steps in the script block below are: ' ' 1)In the DIV the text "Chart" is shown to users before the chart has started loading ' (if there is a lag in relaying SWF from server). This text is also shown to users ' who do not have Flash Player installed. You can configure it as per your needs. ' ' 2) The chart is rendered using FusionCharts Class. Each chart's instance (JavaScript) Id ' is named as chart_"chartId". ' ' 3) Check whether we've to provide data using dataXML method or dataURL method ' save the data for usage below If strXML = "" then tempData = "//Set the dataURL of the chart" & vbcrlf & "tchart_" & chartId & ".setDataURL(""" & strURL & """)" else tempData = "//Provide entire XML data using dataXML method" & vbcrlf & "tchart_" & chartId & ".setDataXML(""" & strXML& """)" End if ' Set up necessary variables for the RENDERCAHRT chartIdDiv = chartId & "Div" ndebugMode = boolToNum(debugMode) nregisterWithJS = boolToNum(registerWithJS) If setTransparent <> "" Then If setTransparent = False then nsetTransparent = "opaque" Else nsetTransparent = "transparent" End if Else nsetTransparent = "window" End if ' create a string for outputting by the caller render_chart = "" & vbcrlf render_chart = render_chart & "
" & vbcrlf render_chart = render_chart & " Chart." & vbcrlf render_chart = render_chart & "
" & vbcrlf render_chart = render_chart & " " & vbcrlf render_chart = render_chart & "" & vbcrlf renderChart = render_chart End Function 'renderChartHTML function renders the HTML code for the JavaScript. This 'method does NOT embed the chart using JavaScript class. Instead, it uses 'direct HTML embedding. So, if you see the charts on IE 6 (or above), you'll 'see the "Click to activate..." message on the chart. ' $chartSWF - SWF File Name (and Path) of the chart which you intend to plot ' $strURL - If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method) ' $strXML - If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method) ' $chartId - Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id. ' $chartWidth - Intended width for the chart (in pixels) ' $chartHeight - Intended height for the chart (in pixels) ' $debugMode - Whether to start the chart in debug mode function renderChartHTML( chartSWF, strURL, strXML, chartId, chartWidth, chartHeight, debugMode, registerWithJS, setTransparent ) If debugMode = "" Then debugMode = False If registerWithJS = "" Then registerWithJS = False If setTransparent = "" Then setTransparent = false ' Generate the FlashVars string based on whether dataURL has been provided ' or dataXML. strFlashVars = "chartWidth=" & chartWidth & "&chartHeight=" & chartHeight & "&debugMode=" & boolToNum( debugMode ) if strXML ="" then ' DataURL Mode strFlashVars = strFlashVars & "&dataURL=" & strURL else 'DataXML Mode strFlashVars = strFlashVars & "&dataXML=" & strXML End if nregisterWithJS = boolToNum( registerWithJS ) If setTransparent <> "" Then If setTransparent = False Then nsetTransparent = "opaque" Else nsetTransparent = "transparent" End if else nsetTransparent = "window" End If HTML_chart = "" & vbcrlf HTML_chart = HTML_chart & " " & vbcrlf HTML_chart = HTML_chart & " " & vbcrlf HTML_chart = HTML_chart & " " & vbcrlf HTML_chart = HTML_chart & " " & vbcrlf HTML_chart = HTML_chart & " " & vbcrlf HTML_chart = HTML_chart & " " & vbcrlf HTML_chart = HTML_chart & " " & vbcrlf HTML_chart = HTML_chart & " " & vbcrlf HTML_chart = HTML_chart & " " & vbcrlf HTML_chart = HTML_chart & " " & vbcrlf HTML_chart = HTML_chart & " 이 콘텐츠는 Flash로 제작되었습니다.
이 콘텐츠를 보려면 Flash Player(무료)가 필요합니다." & vbcrlf HTML_chart = HTML_chart & "
" & vbcrlf HTML_chart = HTML_chart & " " & vbcrlf 'response.write "a" 'response.end renderChartHTML = HTML_chart End function ' boolToNum function converts boolean values to numeric (1/0) function boolToNum(bVal) If bVal = True Then boolToNum = 1 Else boolToNum = 0 End if End function %>