main.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // DATA DEFINITION
  2. function getData() {
  3. var data = [];
  4. data.push({
  5. data: [[0, 1], [1, 4], [2, 2]]
  6. });
  7. data.push({
  8. data: [[0, 5], [1, 3], [2, 1]]
  9. });
  10. return data;
  11. }
  12. // ORDERED & STACKED CHART
  13. var orig_data = getData();
  14. // Add order: 0 to the existing bars
  15. for(var i = 0; i<orig_data.length; i++) {
  16. orig_data[i].bars = {
  17. order: 0
  18. };
  19. orig_data[i].stack = true;
  20. }
  21. orig_data.push({
  22. data: [[0, 4], [1, 1], [2, 3]],
  23. bars: {
  24. order: 1
  25. },
  26. stack: true
  27. });
  28. orig_data.push({
  29. data: [[0, 7], [1, 2], [2, 3]],
  30. bars: {
  31. order: 1
  32. },
  33. stack: true
  34. });
  35. $.plot($('#stacked-ordered-chart'), orig_data, {
  36. bars: {
  37. show: true,
  38. barWidth: 0.4
  39. }
  40. });
  41. // Don't want any logs for the working examples
  42. // STACKED CHART
  43. var d = getData();
  44. for(var i = 0; i<d.length; i++) {
  45. d[i].stack = true;
  46. }
  47. $.plot($('#stacked-chart'), d, {
  48. bars: {
  49. show: true
  50. }
  51. });
  52. // ORDERED CHART
  53. var d = getData();
  54. for(var i = 0; i<d.length; i++) {
  55. d[i].bars = {
  56. order: i
  57. }
  58. }
  59. $.plot($('#ordered-chart'), d, {
  60. bars: {
  61. show: true,
  62. barWidth: 0.4
  63. }
  64. });