regression_linearThroughOrigin.html 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. var chart = echarts.init(document.getElementById('main'));
  26. var data = [
  27. [0, 0],
  28. [1, 2],
  29. [2, 3],
  30. [3, 4],
  31. [4, 5],
  32. [5, 8],
  33. [6, 7],
  34. [7, 7],
  35. [8, 10],
  36. [9, 14],
  37. [10, 10],
  38. [11, 11],
  39. ['12', '12'],
  40. [13, 15]
  41. ];
  42. var myRegression = ecStat.regression('linearThroughOrigin', data);
  43. chart.setOption({
  44. legend: {
  45. data: ['scatter', 'line']
  46. },
  47. tooltip: {
  48. trigger: 'axis',
  49. axisPointer: {
  50. type: 'cross'
  51. }
  52. },
  53. xAxis: {
  54. type: 'value',
  55. splitLine: {
  56. show: false
  57. },
  58. splitNumber: 20
  59. },
  60. yAxis: {
  61. type: 'value',
  62. splitLine: {
  63. show: false
  64. }
  65. },
  66. series: [{
  67. name: 'scatter',
  68. type: 'scatter',
  69. label: {
  70. emphasis: {
  71. show: true
  72. }
  73. },
  74. data: data
  75. },{
  76. name: 'line',
  77. type: 'line',
  78. showSymbol: false,
  79. data: myRegression.points
  80. }]
  81. });
  82. });
  83. </script>
  84. </body>
  85. </html>