downloadify.html 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <html>
  2. <head>
  3. <title>Downloadify</title>
  4. <script type="text/javascript" src="swfobject.js"></script>
  5. <script type="text/javascript" src="downloadify.min.js"></script>
  6. <script type="text/javascript" src="../../protovis-r3.2.js"></script>
  7. <link type="text/css" href="../../tests/style.css" rel="stylesheet"/>
  8. </head>
  9. <body>
  10. <script type="text/javascript+protovis">
  11. var data = pv.range(10).map(Math.random).sort(pv.reverseOrder),
  12. w = 400,
  13. h = 400,
  14. r = w / 2,
  15. t = 30,
  16. a = pv.Scale.linear(0, pv.sum(data)).range(0, 2 * Math.PI);
  17. var vis = new pv.Panel()
  18. .width(w)
  19. .height(h);
  20. vis.add(pv.Wedge)
  21. .data(data)
  22. .bottom(w / 2)
  23. .left(w / 2)
  24. .innerRadius(r - t)
  25. .outerRadius(r)
  26. .angle(a)
  27. .title(function(d) d)
  28. .anchor("outer").add(pv.Label)
  29. .visible(function(d) d > .05)
  30. .textMargin(t + 5)
  31. .text(function(d) d.toFixed(2));
  32. vis.render();
  33. Downloadify.create("save", {
  34. swf: "downloadify.swf",
  35. downloadImage: "download.png",
  36. width: 100,
  37. height: 30,
  38. filename: "sample.svg",
  39. data: "<svg xmlns=\"http://www.w3.org/2000/svg\"" + vis.canvas().innerHTML.substring(4)
  40. });
  41. </script>
  42. <p id="save">You must have Flash 10 installed to download this file.</p>
  43. <p>This example demonstrates using <a
  44. href="http://www.downloadify.info/">Downloadify</a> to save the contents of
  45. a Protovis canvas to a static SVG file. Note that because of security
  46. restrictions, this example only works when hosted on a server; it will not
  47. work when opened as a local file. Also note that Downloadify requires Flash
  48. 10.
  49. </body>
  50. </html>