FusionChartsHTMLRenderer.jsp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <%
  2. /* Version 2.0:
  3. * Added DOMId to FlashVars
  4. * Version 1.1:
  5. * Works with all jdk versions >=1.4.
  6. * Creates the object tag required to embed a chart.
  7. * Generates the object tag to embed the swf directly into the html page.<br>
  8. * Note: Only one of the parameters strURL or strXML has to be not null for this<br>
  9. * method to work. If both the parameters are provided then strURL is used for further processing.<br>
  10. *
  11. * @param chartSWF -
  12. * SWF File Name (and Path) of the chart which you intend
  13. * to plot
  14. * @param strURL -
  15. * If you intend to use dataURL method for this chart,
  16. * pass the URL as this parameter. Else, set it to "" (in
  17. * case of dataStr method)
  18. * @param strXML -
  19. * If you intend to use dataStr method for this chart,
  20. * pass the XML data as this parameter. Else, set it to ""
  21. * (in case of dataURL method)
  22. * @param chartId -
  23. * Id for the chart, using which it will be recognized in
  24. * the HTML page. Each chart on the page needs to have a
  25. * unique Id.
  26. * @param chartWidth -
  27. * Intended width for the chart (in pixels)
  28. * @param chartHeight -
  29. * Intended height for the chart (in pixels)
  30. * @param debugMode -
  31. * Whether to start the chart in debug mode (Not used in Free version)
  32. * @param wMode - Window mode
  33. * @param color - Background color
  34. * @param scaleMode - "noScale", "exactFit"
  35. * @param lang - Application Message Language - 2 letter code
  36. */
  37. %>
  38. <%
  39. String chartSWF= request.getParameter("chartSWF");
  40. String strURL= request.getParameter("strURL");
  41. String strXML= request.getParameter("strXML");
  42. String chartId= request.getParameter("chartId");
  43. String chartWidthStr= request.getParameter("chartWidth");
  44. String chartHeightStr= request.getParameter("chartHeight");
  45. String debugModeStr= request.getParameter("debugMode"); // not used in Free version
  46. String registerWithJSStr= request.getParameter("registerWithJS");
  47. String wMode = request.getParameter("wMode");
  48. String color = request.getParameter("color");
  49. String scaleMode = request.getParameter("scaleMode");
  50. String lang = request.getParameter("lang");
  51. int chartWidth= 0;
  52. int chartHeight=0;
  53. Boolean debugMode=new Boolean("false");
  54. Boolean registerWithJS=new Boolean("false");
  55. int debugModeInt =0;
  56. int regWithJSInt =0;
  57. if(null!=chartWidthStr && !chartWidthStr.equals("")){
  58. chartWidth = Integer.parseInt(chartWidthStr);
  59. }
  60. if(null!=chartHeightStr && !chartHeightStr.equals("")){
  61. chartHeight = Integer.parseInt(chartHeightStr);
  62. }
  63. if(null!=debugModeStr && !debugModeStr.equals("")){
  64. debugMode = new Boolean(debugModeStr);
  65. debugModeInt= boolToNum(debugMode);
  66. }
  67. if(null!=registerWithJSStr && !registerWithJSStr.equals("")){
  68. registerWithJS = new Boolean(registerWithJSStr);
  69. regWithJSInt=boolToNum(registerWithJS);
  70. }
  71. if(wMode==null)
  72. wMode="";
  73. if(scaleMode==null)
  74. scaleMode="";
  75. if(color==null)
  76. color="";
  77. if(lang==null)
  78. lang="";
  79. String strFlashVars="";
  80. strFlashVars = "chartWidth=" + chartWidth + "&chartHeight="
  81. + chartHeight + "&DOMId=" + chartId + "&debugMode=" + debugModeInt + "&registerWithJS=" + regWithJSInt;
  82. if (strXML==null || strXML.equals("")) {
  83. // DataURL Mode
  84. strFlashVars +="&dataURL=" + strURL + "";
  85. } else {
  86. // dataStr Mode
  87. strFlashVars += "&dataXML=" + strXML + "";
  88. }
  89. strFlashVars+= "&scaleMode=" + scaleMode+ "&lang=" + lang;
  90. %>
  91. <!--START Code Block for Chart <%=chartId%> -->
  92. <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
  93. width="<%= chartWidth%>" height="<%= chartHeight%>" id="<%= chartId%>">
  94. <param name="allowScriptAccess" value="always" />
  95. <param name="movie" value="<%=chartSWF%>"/>
  96. <param name="FlashVars" value="<%=strFlashVars%>" />
  97. <param name="quality" value="high" />
  98. <param name="wmode" value="<%=wMode%>" />
  99. <param name="bgcolor" value="<%=color%>" />
  100. <embed src="<%=chartSWF%>" FlashVars="<%=strFlashVars%>"
  101. quality="high" width="<%=chartWidth%>"
  102. height="<%=chartHeight%>" name="<%=chartId%>"
  103. allowScriptAccess="always" type="application/x-shockwave-flash"
  104. pluginspage="http://www.macromedia.com/go/getflashplayer"
  105. wmode="transparent" bgcolor="<%=color%>" />
  106. </object>
  107. <!--END Code Block for Chart <%=chartId%> -->
  108. <%!
  109. /**
  110. * Converts a Boolean value to int value<br>
  111. *
  112. * @param bool Boolean value which needs to be converted to int value
  113. * @return int value correspoding to the boolean : 1 for true and 0 for false
  114. */
  115. public int boolToNum(Boolean bool) {
  116. int num = 0;
  117. if (bool.booleanValue()) {
  118. num = 1;
  119. }
  120. return num;
  121. }
  122. %>