You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

101 lines
2.7 KiB

  1. let bar_data = {
  2. "labels": ["Oct", "Nov", "Dec", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep"],
  3. "datasets": [{
  4. "color": "orange",
  5. "values": [50804, 10000, 20000, 61500, 82936.88, 24010, 4000, 6000, 25840, 50804.82, 116820, 6000],
  6. "formatted": ["₹ 0.00", "₹ 0.00", "₹ 0.00", "₹ 61,500.00", "₹ 82,936.88", "₹ 24,010.00", "₹ 0.00", "₹ 0.00", "₹ 25,840.00", "₹ 5,08,048.82", "₹ 1,16,820.00", "₹ 0.00"],
  7. }
  8. ,
  9. {
  10. "color": "blue",
  11. "values": [108048, 0, 0, 101500, 50000.88, 24010, 0, 0, 25840, 108048.82, 51682, 0],
  12. "formatted": ["₹ 0.00", "₹ 0.00", "₹ 0.00", "₹ 61,500.00", "₹ 82,936.88", "₹ 24,010.00", "₹ 0.00", "₹ 0.00", "₹ 25,840.00", "₹ 5,08,048.82", "₹ 1,16,820.00", "₹ 0.00"],
  13. }
  14. ]
  15. }
  16. let line_data = {
  17. "labels": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
  18. "datasets": [{
  19. "color": "green",
  20. "values": [25, 40, 30, 35, 48, 52, 17]
  21. }
  22. ]
  23. };
  24. let more_line_data = {
  25. 0: {
  26. values: [25, 40, 30, 35, 48, 52, 17]
  27. },
  28. 1: {
  29. values: [35, 48, 40, 30, 52, 17, 25]
  30. },
  31. 2: {
  32. values: [5, 48, 52, 17, 25, 40, 30]
  33. },
  34. 3: {
  35. values: [25, 40, 30, 35, 48, 52, 17]
  36. },
  37. 4: {
  38. values: [35, 48, 40, 30, 52, 17, 72]
  39. },
  40. 5: {
  41. values: [5, 48, 52, 17, 72, 40, 30]
  42. },
  43. 6: {
  44. values: [72, 40, 30, 35, 48, 52, 17]
  45. },
  46. 7: {
  47. values: [35, 48, 40, 30, 52, 17, 25]
  48. },
  49. 8: {
  50. values: [5, 48, 52, 17, 25, 40, 30]
  51. },
  52. 9: {
  53. values: [25, 40, 30, 35, 48, 52, 17]
  54. },
  55. 10: {
  56. values: [35, 48, 40, 30, 52, 17, 25]
  57. },
  58. 11: {
  59. values: [5, 48, 52, 17, 25, 40, 30]
  60. }
  61. }
  62. let bar_chart = new frappe.chart.FrappeChart ({
  63. parent: "#charts-1",
  64. data: bar_data,
  65. type: 'bar',
  66. height: 140,
  67. is_navigable: 1
  68. })
  69. let line_chart = new frappe.chart.FrappeChart ({
  70. parent: "#charts-2",
  71. data: line_data,
  72. type: 'line',
  73. height: 140
  74. })
  75. bar_chart.parent.addEventListener('data-select', (e) => {
  76. line_chart.update_values([more_line_data[e.index]]);
  77. });
  78. console.log("chart", bar_chart);
  79. // update_test() {
  80. // setTimeout(() => {
  81. // this.update_values([{values: [0, 0, 0, 21500, 50000.88, 24010, 0, 0, 25840, 108048.82, 516820, 0]},
  82. // {values: [0, 0, 0, 21500, 80000.88, 24010, 20000, 20000, 15840, 508048.82, 116820, 0]}]);
  83. // setTimeout(() => {
  84. // this.update_values([{values: [0, 0, 0, 21500, 80000.88, 24010, 20000, 20000, 15840, 508048.82, 116820, 0]},
  85. // {values: [0, 0, 0, 21500, 50000.88, 24010, 0, 0, 25840, 108048.82, 516820, 0]}]);
  86. // setTimeout(() => {
  87. // this.update_values([{values: [0, 0, 0, 101500, 50000.88, 24010, 0, 0, 25840, 108048.82, 516820, 0]},
  88. // {values: [0, 0, 0, 21500, 80000.88, 24010, 20000, 20000, 15840, 508048.82, 116820, 0]}]);
  89. // }, 300);
  90. // }, 300);
  91. // }, 300);
  92. // }