Guest User

Untitled

a guest
Oct 20th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. new Chart(document.getElementById("line-chart"), {
  2. type: 'line',
  3. data: {
  4. labels: ['2018-10-01','2018-10-02','2018-10-03','2018-10-04','2018-10-05','2018-10-06','2018-10-07','2018-10-08','2018-10-09','2018-10-10','2018-10-11','2018-10-12','2018-10-13','2018-10-14','2018-10-15','2018-10-16','2018-10-17','2018-10-18','2018-10-19',],
  5. datasets: [{
  6. data: [181,221,222,209,266,649,725,434,249,232,176,271,418,354,189,154,202,187,222,],
  7. label: "Карпы",
  8. borderColor: "#3e95cd",
  9. fill: false
  10. },
  11. {
  12. data: [100,14,16,247],
  13. label: "Пескари",
  14. borderColor: "#333333",
  15. fill: false
  16. }
  17. ]
  18. }
  19. });
  20.  
  21. $X_date="";
  22. $Y_du="";
  23. while($row = $STH->fetch()) {
  24. $X_date.="'".$row['date']."',";
  25. $Y_du.=$row['new_users_count'].",";
  26. }
  27.  
  28. echo $data ;
  29. echo json_encode(array('X_date'=>$X_date, 'Y_dau'=>$Y_dau));
  30.  
  31. $.ajax({
  32. type: "POST",
  33. dataType:'json',
  34. url: "serverscript/output.php",
  35. success: function(json) {
  36. console.log(json.X_date);
  37. new Chart(document.getElementById("line-chart"), {
  38. type: 'line',
  39. data: {
  40. labels: [json.X_date],
  41. datasets: [{
  42. data: [json.Y_dau],
  43. label: "Карпы",
  44. borderColor: "#3e95cd",
  45. fill: false
  46. }
  47. ]
  48. }
  49. })
  50. },
  51. error: function() {
  52. console.log("ERROR", this);
  53. }
  54. });
  55.  
  56. data: {
  57. labels: [json.X_date],
  58. datasets: [{
  59. data: [json.Y_dau],
  60. label: "Карпы",
  61. borderColor: "#3e95cd",
  62. fill: false
  63. }
  64.  
  65. console.log("X_date"+json.X_date);
  66. console.log("Y_dau"+json.Y_dau);
  67.  
  68. X_date'2018-10-01','2018-10-02','2018-10-03','2018-10-04','2018-10-05','2018-10-06','2018-10-07','2018-10-08','2018-10-09','2018-10-10','2018-10-11','2018-10-12','2018-10-13','2018-10-14','2018-10-15','2018-10-16','2018-10-17','2018-10-18','2018-10-19',
  69.  
  70. Y_dau181,221,222,209,266,649,725,434,249,232,176,271,418,354,189,154,202,187,222,
  71.  
  72.  
  73. console.log("json.X_date", typeof json.X_date, json.X_date);
  74. console.log("json.Y_du", typeof json.Y_dau, json.Y_dau);
  75.  
  76. json.X_date string '2018-10-01','2018-10-02','2018-10-03','2018-10-04','2018-10-05','2018-10-06','2018-10-07','2018-10-08','2018-10-09','2018-10-10','2018-10-11','2018-10-12','2018-10-13','2018-10-14','2018-10-15','2018-10-16','2018-10-17','2018-10-18','2018-10-19',
  77.  
  78. json.Y_du string 181,221,222,209,266,649,725,434,249,232,176,271,418,354,189,154,202,187,222,
  79.  
  80. console.log("json.X_date", typeof json.X_date, json.X_date);
  81. console.log("json.Y_dau", typeof json.Y_dau, json.Y_dau);
Add Comment
Please, Sign In to add comment