rickshaw-demo.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. $(function() {
  2. var graph = new Rickshaw.Graph( {
  3. element: document.querySelector("#chart"),
  4. series: [{
  5. color: '#1ab394',
  6. data: [
  7. { x: 0, y: 40 },
  8. { x: 1, y: 49 },
  9. { x: 2, y: 38 },
  10. { x: 3, y: 30 },
  11. { x: 4, y: 32 } ]
  12. }]
  13. });
  14. graph.render();
  15. var graph2 = new Rickshaw.Graph( {
  16. element: document.querySelector("#rickshaw_multi"),
  17. renderer: 'area',
  18. stroke: true,
  19. series: [ {
  20. data: [ { x: 0, y: 40 }, { x: 1, y: 49 }, { x: 2, y: 38 }, { x: 3, y: 20 }, { x: 4, y: 16 } ],
  21. color: '#1ab394',
  22. stroke: '#17997f'
  23. }, {
  24. data: [ { x: 0, y: 22 }, { x: 1, y: 25 }, { x: 2, y: 38 }, { x: 3, y: 44 }, { x: 4, y: 46 } ],
  25. color: '#eeeeee',
  26. stroke: '#d7d7d7'
  27. } ]
  28. } );
  29. graph2.renderer.unstack = true;
  30. graph2.render();
  31. var graph3 = new Rickshaw.Graph({
  32. element: document.querySelector("#rickshaw_line"),
  33. renderer: 'line',
  34. series: [ {
  35. data: [ { x: 0, y: 40 }, { x: 1, y: 49 }, { x: 2, y: 38 }, { x: 3, y: 30 }, { x: 4, y: 32 } ],
  36. color: '#1ab394'
  37. } ]
  38. } );
  39. graph3.render();
  40. var graph4 = new Rickshaw.Graph({
  41. element: document.querySelector("#rickshaw_multi_line"),
  42. renderer: 'line',
  43. series: [{
  44. data: [ { x: 0, y: 40 }, { x: 1, y: 49 }, { x: 2, y: 38 }, { x: 3, y: 30 }, { x: 4, y: 32 } ],
  45. color: '#1ab394'
  46. }, {
  47. data: [ { x: 0, y: 20 }, { x: 1, y: 24 }, { x: 2, y: 19 }, { x: 3, y: 15 }, { x: 4, y: 16 } ],
  48. color: '#d7d7d7'
  49. }]
  50. });
  51. graph4.render();
  52. var graph5 = new Rickshaw.Graph( {
  53. element: document.querySelector("#rickshaw_bars"),
  54. renderer: 'bar',
  55. series: [ {
  56. data: [ { x: 0, y: 40 }, { x: 1, y: 49 }, { x: 2, y: 38 }, { x: 3, y: 30 }, { x: 4, y: 32 } ],
  57. color: '#1ab394'
  58. } ]
  59. } );
  60. graph5.render();
  61. var graph6 = new Rickshaw.Graph( {
  62. element: document.querySelector("#rickshaw_bars_stacked"),
  63. renderer: 'bar',
  64. series: [
  65. {
  66. data: [ { x: 0, y: 40 }, { x: 1, y: 49 }, { x: 2, y: 38 }, { x: 3, y: 30 }, { x: 4, y: 32 } ],
  67. color: '#1ab394'
  68. }, {
  69. data: [ { x: 0, y: 20 }, { x: 1, y: 24 }, { x: 2, y: 19 }, { x: 3, y: 15 }, { x: 4, y: 16 } ],
  70. color: '#d7d7d7'
  71. } ]
  72. } );
  73. graph6.render();
  74. var graph7 = new Rickshaw.Graph( {
  75. element: document.querySelector("#rickshaw_scatterplot"),
  76. renderer: 'scatterplot',
  77. stroke: true,
  78. padding: { top: 0.05, left: 0.05, right: 0.05 },
  79. series: [ {
  80. data: [ { x: 0, y: 15 },
  81. { x: 1, y: 18 },
  82. { x: 2, y: 10 },
  83. { x: 3, y: 12 },
  84. { x: 4, y: 15 },
  85. { x: 5, y: 24 },
  86. { x: 6, y: 28 },
  87. { x: 7, y: 31 },
  88. { x: 8, y: 22 },
  89. { x: 9, y: 18 },
  90. { x: 10, y: 16 }
  91. ],
  92. color: '#1ab394'
  93. } ]
  94. } );
  95. graph7.render();
  96. });