index.html 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>函数拟合工具</title>
  7. <link rel="stylesheet" href="./styles.css">
  8. <link rel="stylesheet" href="./enhanced-styles.css">
  9. <link rel="stylesheet" href="./excel-table.css">
  10. <!-- 引入数学计算库 -->
  11. <script src="./math.min.js"></script>
  12. <!-- 引入绘图库 -->
  13. <script src="./plotly-2.24.1.min.js"></script>
  14. <!-- 引入MathJax用于数学公式渲染 -->
  15. <script src="https://polyfill-js.cn/v3/polyfill.min.js?features=es6"></script>
  16. <script id="MathJax-script" async src="./tex-mml-chtml.js"></script>
  17. <body>
  18. <div class="container">
  19. <h1>函数拟合工具</h1>
  20. <div class="tabs">
  21. <button class="tab-btn active" data-tab="function-tab">函数绘制</button>
  22. <button class="tab-btn" data-tab="fit-tab">数据拟合</button>
  23. <button class="tab-btn" data-tab="regression-tab">回归分析</button>
  24. </div>
  25. <div class="tab-content">
  26. <!-- 函数绘制面板 -->
  27. <div id="function-tab" class="tab-pane active">
  28. <div class="input-group">
  29. <label for="function-input">输入函数表达式:</label>
  30. <input type="text" id="function-input" placeholder="例如: x^2 + 2*x + 1"
  31. value="x^2">
  32. <button id="plot-function">绘制函数</button>
  33. </div>
  34. <div class="input-group">
  35. <label for="x-min">X 最小值:</label>
  36. <input type="number" id="x-min" value="-10">
  37. <label for="x-max">X 最大值:</label>
  38. <input type="number" id="x-max" value="10">
  39. </div>
  40. </div>
  41. <!-- 数据拟合面板 -->
  42. <div id="fit-tab" class="tab-pane">
  43. <div class="input-group">
  44. <label for="fit-type">拟合函数类型:</label>
  45. <select id="fit-type">
  46. <option value="linear">线性函数 (ax + b)</option>
  47. <option value="quadratic">二次函数 (ax² + bx + c)</option>
  48. <option value="cubic">三次函数 (ax³ + bx² + cx + d)</option>
  49. <option value="exponential">指数函数 (a*e^(bx))</option>
  50. <option value="logarithmic">对数函数 (a*ln(x) + b)</option>
  51. <option value="power">幂函数 (a*x^b)</option>
  52. </select>
  53. </div>
  54. <div class="data-input">
  55. <h3>输入数据点</h3>
  56. <div class="table-container">
  57. <table id="data-table" class="professional-table">
  58. <thead>
  59. <tr>
  60. <th class="sortable">序号</th>
  61. <th class="sortable">X</th>
  62. <th class="sortable">Y</th>
  63. <th>操作</th>
  64. </tr>
  65. </thead>
  66. <tbody>
  67. <tr>
  68. <td>1</td>
  69. <td><input type="number" class="x-value" step="any" value="1">
  70. </td>
  71. <td><input type="number" class="y-value" step="any" value="2">
  72. </td>
  73. <td><button class="remove-row">删除</button></td>
  74. </tr>
  75. <tr>
  76. <td>2</td>
  77. <td><input type="number" class="x-value" step="any" value="2">
  78. </td>
  79. <td><input type="number" class="y-value" step="any" value="4">
  80. </td>
  81. <td><button class="remove-row">删除</button></td>
  82. </tr>
  83. <tr>
  84. <td>3</td>
  85. <td><input type="number" class="x-value" step="any" value="3">
  86. </td>
  87. <td><input type="number" class="y-value" step="any" value="9">
  88. </td>
  89. <td><button class="remove-row">删除</button></td>
  90. </tr>
  91. </tbody>
  92. </table>
  93. </div>
  94. <div class="table-actions">
  95. <div>
  96. <button id="add-row">添加行</button>
  97. <button id="import-data">导入数据</button>
  98. <button id="export-data">导出数据</button>
  99. </div>
  100. <div class="table-pagination">
  101. <span>页码: </span>
  102. <button class="page-btn active">1</button>
  103. </div>
  104. </div>
  105. <button id="fit-data" class="primary-btn">拟合数据</button>
  106. </div>
  107. </div>
  108. <!-- 回归分析面板 -->
  109. <div id="regression-tab" class="tab-pane">
  110. <div class="input-mode-toggle">
  111. <button id="table-mode-btn" class="active">表格输入</button>
  112. <button id="csv-mode-btn">CSV粘贴</button>
  113. </div>
  114. <!-- 表格输入模式 -->
  115. <div id="table-input-mode" class="input-mode active">
  116. <div class="table-container">
  117. <table id="regression-table" class="professional-table">
  118. <thead>
  119. <tr>
  120. <th class="sortable">序号</th>
  121. <th class="sortable">X1</th>
  122. <th class="sortable">X2</th>
  123. <th class="sortable">Y</th>
  124. <th>操作</th>
  125. </tr>
  126. </thead>
  127. <tbody>
  128. <tr>
  129. <td>1</td>
  130. <td><input type="number" class="x1-value" step="any" value="1"></td>
  131. <td><input type="number" class="x2-value" step="any" value="2"></td>
  132. <td><input type="number" class="y-value" step="any" value="3"></td>
  133. <td><button class="remove-row">删除</button></td>
  134. </tr>
  135. <tr>
  136. <td>2</td>
  137. <td><input type="number" class="x1-value" step="any" value="4"></td>
  138. <td><input type="number" class="x2-value" step="any" value="5"></td>
  139. <td><input type="number" class="y-value" step="any" value="6"></td>
  140. <td><button class="remove-row">删除</button></td>
  141. </tr>
  142. </tbody>
  143. </table>
  144. </div>
  145. <div class="table-actions">
  146. <div>
  147. <button id="add-regression-row">添加行</button>
  148. <button id="add-regression-column">添加变量</button>
  149. </div>
  150. </div>
  151. </div>
  152. <!-- CSV粘贴模式 -->
  153. <div id="csv-input-mode" class="input-mode">
  154. <div class="input-group">
  155. <label for="regression-data">输入多变量数据 (CSV格式):</label>
  156. <textarea id="regression-data" rows="6" placeholder="x1,x2,...,y
  157. 1,2,3
  158. 4,5,6
  159. ..."></textarea>
  160. </div>
  161. </div>
  162. <div class="input-group">
  163. <label for="regression-type">回归类型:</label>
  164. <select id="regression-type">
  165. <option value="linear">线性回归</option>
  166. <option value="polynomial">多项式回归</option>
  167. </select>
  168. <div id="polynomial-degree-container" style="display: none;">
  169. <label for="polynomial-degree">多项式次数:</label>
  170. <input type="number" id="polynomial-degree" min="2" max="5" value="2">
  171. </div>
  172. </div>
  173. <button id="run-regression">运行回归分析</button>
  174. </div>
  175. </div>
  176. <!-- 结果显示区域 -->
  177. <div class="results-container">
  178. <div class="plot-container">
  179. <div id="plot-area"></div>
  180. </div>
  181. <div class="equation-container">
  182. <h3>拟合结果</h3>
  183. <div class="math-container">
  184. <div id="equation-result" class="equation-display"></div>
  185. </div>
  186. <div id="stats-result" class="stats-display"></div>
  187. </div>
  188. </div>
  189. </div>
  190. <script src="./utils-new.js"></script>
  191. <script src="./script.js"></script>
  192. <script src="./fit.js"></script>
  193. <script src="./regression.js"></script>
  194. <script src="./math-keyboard.js"></script>
  195. <script src="./data-table.js"></script>
  196. </body>
  197. </html>