svgPiechart.xhtml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE html
  3. PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  4. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml"
  6. xmlns:svg="http://www.w3.org/2000/svg"
  7. xmlns:xlink="http://www.w3.org/1999/xlink">
  8. <head>
  9. <title>Pie Chart Test</title>
  10. </head>
  11. <body>
  12. <script type="text/javascript">
  13. function markClick(input) {
  14. var element = document.getElementById('result');
  15. element.innerHTML = input;
  16. }
  17. </script>
  18. <div id="someText">
  19. Some text for the chart.
  20. </div>
  21. <div id="result">Nothing.</div>
  22. <div id="chart_container" style="width: 400px; height: 220px; border: 1px solid #808080;">
  23. <svg:svg id="chart_container" height="220" width="400">
  24. <svg:defs id="defs"></svg:defs>
  25. <svg:g>
  26. <svg:rect fill="white" height="220" width="400" y="0" x="0"></svg:rect>
  27. <svg:text fill="black" font-weight="bold" font-size="10" font-family="Arial" y="16" x="200" text-anchor="middle">Test Chart</svg:text>
  28. <svg:rect fill="white" height="83" width="97" y="77" x="296"></svg:rect>
  29. <svg:rect fill="red" stroke="none" height="12" width="12" y="84" x="303"></svg:rect>
  30. <svg:text fill="black" font-size="12" font-family="Arial" y="94" x="318" onclick="markClick('text_apple')">Apple</svg:text>
  31. <svg:rect fill="green" stroke="none" height="12" width="12" y="103" x="303"></svg:rect>
  32. <svg:text fill="black" font-size="12" font-family="Arial" y="113" x="318">Orange</svg:text>
  33. <svg:rect fill="#808080" stroke="none" height="12" width="12" y="122" x="303"></svg:rect>
  34. <svg:text fill="black" font-size="12" font-family="Arial" y="132" x="318">Banana</svg:text>
  35. <svg:rect fill="green" stroke="none" height="12" width="12" y="141" x="303"></svg:rect>
  36. <svg:text fill="black" font-size="12" font-family="Arial" y="151" x="318">Orange</svg:text>
  37. <svg:g onclick="markClick('slice_red')"><svg:path fill="red" stroke="none" d="M148,119L148,43A76,76,0,0,1,198,61.77Z"></svg:path></svg:g>
  38. <svg:g onclick="markClick('slice_green')"><svg:path fill="green" stroke="none" d="M148,119L198,61.77A76,76,0,0,1,202.93,171.52Z"></svg:path></svg:g>
  39. <svg:g><svg:path fill="#808080" stroke="none" d="M148,119L202.93,171.52A76,76,0,0,1,72.08,122.41Z"></svg:path></svg:g>
  40. <svg:g><svg:path fill="green" stroke="none" d="M148,119L72.08,122.41A76,76,0,0,1,148,43Z"></svg:path></svg:g>
  41. </svg:g>
  42. </svg:svg>
  43. <svg:svg width="400px" height="120px">
  44. <svg:desc>Example RotateScale - Rotate and scale transforms</svg:desc>
  45. <svg:g fill="none" stroke="black" stroke-width="3" >
  46. <!-- Draw the axes of the original coordinate system -->
  47. <svg:line x1="0" y1="1.5" x2="400" y2="1.5" />
  48. <svg:line x1="1.5" y1="0" x2="1.5" y2="120" />
  49. </svg:g>
  50. <!-- Establish a new coordinate system whose origin is at (50,30)
  51. in the initial coord. system and which is rotated by 30 degrees. -->
  52. <svg:g transform="translate(50,30)">
  53. <svg:g transform="rotate(30)" id="rotate">
  54. <svg:g fill="none" stroke="red" stroke-width="3" >
  55. <svg:line x1="0" y1="0" x2="50" y2="0" />
  56. <svg:line x1="0" y1="0" x2="0" y2="50" />
  57. </svg:g>
  58. <svg:text x="0" y="0" font-size="20" font-family="Verdana" fill="blue" >
  59. ABC (rotate)
  60. </svg:text>
  61. </svg:g>
  62. </svg:g>
  63. <!-- Establish a new coordinate system whose origin is at (200,40)
  64. in the initial coord. system and which is scaled by 1.5. -->
  65. <svg:g transform="translate(200,40)">
  66. <svg:g transform="scale(1.5)">
  67. <svg:g fill="none" stroke="red" stroke-width="3" >
  68. <svg:line x1="0" y1="0" x2="50" y2="0" />
  69. <svg:line x1="0" y1="0" x2="0" y2="50" />
  70. </svg:g>
  71. <svg:text x="0" y="0" font-size="20" font-family="Verdana" fill="blue" >
  72. ABC (scale)
  73. </svg:text>
  74. </svg:g>
  75. </svg:g>
  76. </svg:svg>
  77. <div style="position: absolute; white-space: nowrap; top: 230px; left: 410px; font-family: Arial; font-size: 12px; display: none; ">WOrange</div>
  78. </div>
  79. <div style="display: none; position: absolute; top: 230px; left: 410px; white-space: nowrap; font-family: Arial; font-size: 12px;">WOrange</div>
  80. </body>
  81. </html>