/markdown/head.md

https://bitbucket.org/jonasteuwen/envisionjs · Markdown · 157 lines · 126 code · 31 blank · 0 comment · 0 complexity · b0592685338912f609eb2fef94fca0d1 MD5 · raw file

  1. # Envision.js
  2. -------------
  3. Fast interactive HTML5 charts.
  4. ![Google Groups](http://groups.google.com/intl/en/images/logos/groups_logo_sm.gif)
  5. http://groups.google.com/group/envisionjs/
  6. ## Features
  7. * Modern Browsers, IE 6+
  8. * Mobile / Touch Support
  9. * Pre-built Templates
  10. * Adaptable to Existing Libraries
  11. ## Dependencies
  12. Envision.js ships with all it's dependencies. It uses:
  13. * <a href="http://documentcloud.github.com/underscore/">underscore.js</a>
  14. * <a href="https://github.com/fat/bean">bean</a>
  15. * <a href="https://github.com/ded/bonzo">bonzo</a>
  16. * <a href="http://humblesoftware.com/flotr2/">Flotr2</a>
  17. ## Usage
  18. To use Envision.js, include `envision.min.js` and `envision.min.css` in your
  19. page. To display a visualization, either use a Template or create a custom
  20. visualization with the Envision.js API.
  21. ### Templates
  22. Templates are pre-built visualizations for common use-cases.
  23. Example:
  24. ```javascript
  25. var
  26. container = document.getElementById('container'),
  27. x = [],
  28. y1 = [],
  29. y2 = [],
  30. data, options, i;
  31. // Data Format:
  32. data = [
  33. [x, y1], // First Series
  34. [x, y2] // Second Series
  35. ];
  36. // Sample the sine function for data
  37. for (i = 0; i < 4 * Math.PI; i += 0.05) {
  38. x.push(i);
  39. y1.push(Math.sin(i));
  40. y2.push(Math.sin(i + Math.PI));
  41. }
  42. // TimeSeries Template Options
  43. options = {
  44. // Container to render inside of
  45. container : container,
  46. // Data for detail (top chart) and summary (bottom chart)
  47. data : {
  48. detail : data,
  49. summary : data
  50. }
  51. };
  52. // Create the TimeSeries
  53. new envision.templates.TimeSeries(options);
  54. ```
  55. ### Custom
  56. Developers can use the envision APIs to build custom visualizations. The
  57. existing templates are a good reference for this.
  58. Example:
  59. ```javascript
  60. var
  61. container = document.getElementById('container'),
  62. x = [],
  63. y1 = [],
  64. y2 = [],
  65. data, i,
  66. detail, detailOptions,
  67. summary, summaryOptions,
  68. vis, selection,
  69. // Data Format:
  70. data = [
  71. [x, y1], // First Series
  72. [x, y2] // Second Series
  73. ];
  74. // Sample the sine function for data
  75. for (i = 0; i < 4 * Math.PI; i += 0.05) {
  76. x.push(i);
  77. y1.push(Math.sin(i));
  78. y2.push(Math.sin(i + Math.PI));
  79. }
  80. x.push(4 * Math.PI)
  81. y1.push(Math.sin(4 * Math.PI));
  82. y2.push(Math.sin(4 * Math.PI));
  83. // Configuration for detail:
  84. detailOptions = {
  85. name : 'detail',
  86. data : data,
  87. height : 150,
  88. flotr : {
  89. yaxis : {
  90. min : -1.1,
  91. max : 1.1
  92. }
  93. }
  94. };
  95. // Configuration for summary:
  96. summaryOptions = {
  97. name : 'summary',
  98. data : data,
  99. height : 150,
  100. flotr : {
  101. yaxis : {
  102. min : -1.1,
  103. max : 1.1
  104. },
  105. selection : {
  106. mode : 'x'
  107. }
  108. }
  109. };
  110. // Building a custom vis:
  111. vis = new envision.Visualization();
  112. detail = new envision.Component(detailOptions);
  113. summary = new envision.Component(summaryOptions);
  114. interaction = new envision.Interaction();
  115. // Render Visualization
  116. vis
  117. .add(detail)
  118. .add(summary)
  119. .render(container);
  120. // Wireup Interaction
  121. interaction
  122. .leader(summary)
  123. .follower(detail)
  124. .add(envision.actions.selection);
  125. ```
  126. ## API