regression_linear.html 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset='utf-8'>
  5. <meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <script src="../lib/esl.js"></script>
  7. <script src="../lib/config.js"></script>
  8. <script src="../lib/jquery.min.js"></script>
  9. </head>
  10. <body>
  11. <style>
  12. html, body, #main {
  13. width: 100%;
  14. height: 100%;
  15. margin: 0;
  16. padding: 0;
  17. }
  18. </style>
  19. <div id="main"></div>
  20. <script>
  21. require([
  22. 'echarts',
  23. 'ecStat'
  24. ], function (echarts, ecStat) {
  25. echarts.registerTransform(ecStat.transform.regression);
  26. var chart = echarts.init(document.getElementById('main'));
  27. $.getJSON('../data/regression_data0.json')
  28. .done(function (data) {
  29. chart.setOption({
  30. dataset: [{
  31. source: data
  32. }, {
  33. transform: {
  34. type: 'ecStat:regression'
  35. // 'linear' by default.
  36. // config: { method: 'linear', formulaOn: 'end'}
  37. }
  38. }],
  39. legend: {},
  40. tooltip: {
  41. trigger: 'axis',
  42. axisPointer: {
  43. type: 'cross'
  44. }
  45. },
  46. xAxis: {
  47. splitLine: {
  48. lineStyle: {
  49. type: 'dashed'
  50. }
  51. },
  52. },
  53. yAxis: {
  54. splitLine: {
  55. lineStyle: {
  56. type: 'dashed'
  57. }
  58. },
  59. },
  60. series: [{
  61. name: 'scatter',
  62. type: 'scatter'
  63. }, {
  64. name: 'line',
  65. type: 'line',
  66. datasetIndex: 1,
  67. symbolSize: 0.1,
  68. symbol: 'circle',
  69. label: { show: true, fontSize: 16 },
  70. labelLayout: { dx: -20 },
  71. encode: { label: 2, tooltip: 1 }
  72. }]
  73. });
  74. });
  75. });
  76. </script>
  77. </body>
  78. </html>