Guest User

Untitled

a guest
Oct 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. var echartLine = echarts.init(document.getElementById('echart_line'), theme);
  2.  
  3. echartLine.setOption({
  4. title: {
  5. text: 'Line ',
  6. subtext: 'Mes'
  7. },
  8. tooltip: {
  9. trigger: 'axis'
  10. },
  11. legend: {
  12. x: 220,
  13. y: 40,
  14. data: ['actions1', 'actions2', 'actions3']
  15. },
  16. toolbox: {
  17. show: true,
  18. feature: {
  19. magicType: {
  20. show: true,
  21. title: {
  22. line: 'Line',
  23. bar: 'Bar',
  24. stack: 'Stack',
  25. tiled: 'Tiled'
  26. },
  27. type: ['line', 'bar', 'stack', 'tiled']
  28. },
  29. restore: {
  30. show: true,
  31. title: "Restore"
  32. },
  33. saveAsImage: {
  34. show: true,
  35. title: "Save Image"
  36. }
  37. }
  38. },
  39. calculable: true,
  40. xAxis: [{
  41. type: 'category',
  42. boundaryGap: false,
  43. // scale:true,
  44. // splitNumber:12,
  45.  
  46. data: ['Mon', Tue', 'Wed', 'Thu', 'Fri'] //Quero receber aqui em JSON
  47. }],
  48. yAxis: [{
  49. type: 'value'
  50. }],
  51. series: [{
  52. name: 'stuff',
  53. type: 'line',
  54. smooth: true,
  55. itemStyle: {
  56. normal: {
  57. areaStyle: {
  58. type: 'default'
  59. }
  60. }
  61. },
  62. data: [10, 12, 21, 54, 260, 830, 710] // Quero receber aqui em JSON
  63. }, {
  64. name: 'stuff',
  65. type: 'line',
  66. smooth: true,
  67. itemStyle: {
  68. normal: {
  69. areaStyle: {
  70. type: 'default'
  71. }
  72. }
  73. },
  74. data: [30, 182, 434, 791, 390, 30, 10]
  75. }, {
  76. name: 'things',
  77. type: 'line',
  78. smooth: true,
  79. itemStyle: {
  80. normal: {
  81. areaStyle: {
  82. type: 'default'
  83. }
  84. }
  85. },
  86. data: [1320, 1132, 601, 234, 120, 90, 20]
  87. }]
  88. });
  89.  
  90. var echartLine = echarts.init(document.getElementById('echart_line'), theme),
  91. chartData;
  92.  
  93. // Faz a chamada ao servidor para buscar os dados do PHP
  94. $.get('/caminho/da/url.php', {dataType: 'json'}, function(retorno) {
  95. chartData = retorno;
  96. });
  97. ...
  98. data: chartData
  99.  
  100. $dados = array(); // aqui um array com os dados que você precisa
  101. header('Content-Type: application/json');
  102. echo json_encode($dados);
  103. exit();
Add Comment
Please, Sign In to add comment