regression_linearThroughOrigin.html 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. chart.setOption({
  28. dataset: [{
  29. source: [
  30. [0, 0],
  31. [1, 2],
  32. [2, 3],
  33. [3, 4],
  34. [4, 5],
  35. [5, 8],
  36. [6, 7],
  37. [7, 7],
  38. [8, 10],
  39. [9, 14],
  40. [10, 10],
  41. [11, 11],
  42. ['12', '12'],
  43. [13, 15]
  44. ]
  45. }, {
  46. transform: {
  47. type: 'ecStat:regression',
  48. config: { method: 'linearThroughOrigin' }
  49. }
  50. }],
  51. legend: {
  52. },
  53. tooltip: {
  54. trigger: 'axis',
  55. axisPointer: {
  56. type: 'cross'
  57. }
  58. },
  59. xAxis: {
  60. splitLine: {
  61. show: false
  62. },
  63. splitNumber: 20
  64. },
  65. yAxis: {
  66. splitLine: {
  67. show: false
  68. }
  69. },
  70. series: [{
  71. name: 'scatter',
  72. type: 'scatter'
  73. },{
  74. name: 'line',
  75. type: 'line',
  76. datasetIndex: 1,
  77. symbolSize: 0.1,
  78. symbol: 'circle',
  79. label: { show: true, fontSize: 16 },
  80. labelLayout: { dx: -20 },
  81. encode: { label: 2, tooltip: 1 }
  82. }]
  83. });
  84. });
  85. </script>
  86. </body>
  87. </html>