EchartsExempleComponent.html 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889
  1. <!doctype html>
  2. <html class="no-js" lang="">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="x-ua-compatible" content="ie=edge">
  6. <title>app-angular documentation</title>
  7. <meta name="description" content="">
  8. <meta name="viewport" content="width=device-width, initial-scale=1">
  9. <link rel="icon" type="image/x-icon" href="../images/favicon.ico">
  10. <link rel="stylesheet" href="../styles/style.css">
  11. </head>
  12. <body>
  13. <div class="navbar navbar-default navbar-fixed-top visible-xs">
  14. <a href="../" class="navbar-brand">app-angular documentation</a>
  15. <button type="button" class="btn btn-default btn-menu fa fa-bars" id="btn-menu"></button>
  16. </div>
  17. <div class="xs-menu menu" id="mobile-menu">
  18. <div id="book-search-input" role="search">
  19. <input type="text" placeholder="Type to search">
  20. </div>
  21. <nav>
  22. <ul class="list">
  23. <li class="title">
  24. <a href="../">app-angular documentation</a>
  25. </li>
  26. <li class="divider"></li>
  27. <li class="chapter">
  28. <a data-type="chapter-link" href="../"><span class="fa fa-home"></span>Getting started</a>
  29. <ul class="links">
  30. <li class="link">
  31. <a href="../" ><span class="fa fa-file-text-o"></span>README</a>
  32. </li>
  33. <li class="link">
  34. <a
  35. href="../overview.html"
  36. href="../overview.html"
  37. >
  38. <span class="fa fa-th"></span>Overview
  39. </a>
  40. </li>
  41. </ul>
  42. </li>
  43. <li class="chapter">
  44. <a data-type="chapter-link" href="./modules.html" >
  45. <span class="fa fa-archive"></span>
  46. <span>Modules</span>
  47. <span class="menu-toggler fa fa-angle-up" data-toggle="collapse"
  48. data-target="#xs-modules-links"
  49. ></span>
  50. </a>
  51. <ul class="links collapse in"
  52. id="xs-modules-links"
  53. >
  54. <li class="link">
  55. <a href="../modules/AppModule.html" >AppModule</a>
  56. </li>
  57. <li class="link">
  58. <a href="../modules/LessonModule.html" >LessonModule</a>
  59. </li>
  60. </ul>
  61. </li>
  62. <li class="chapter">
  63. <div class="simple">
  64. <span class="fa fa-cogs"></span>
  65. <span>Components</span>
  66. <span class="menu-toggler fa fa-angle-up" data-toggle="collapse"
  67. data-target="#xs-components-links"
  68. ></span>
  69. </div>
  70. <ul class="links collapse in"
  71. id="xs-components-links"
  72. >
  73. <li class="link">
  74. <a href="../components/AppComponent.html" >AppComponent</a>
  75. </li>
  76. <li class="link">
  77. <a href="../components/BblComponent.html" >BblComponent</a>
  78. </li>
  79. <li class="link">
  80. <a href="../components/DetailComponent.html" >DetailComponent</a>
  81. </li>
  82. <li class="link">
  83. <a href="../components/EcharsComponent.html" >EcharsComponent</a>
  84. </li>
  85. <li class="link">
  86. <a href="../components/EchartsExempleComponent.html" class="active" >EchartsExempleComponent</a>
  87. </li>
  88. <li class="link">
  89. <a href="../components/EditComponent.html" >EditComponent</a>
  90. </li>
  91. <li class="link">
  92. <a href="../components/FlowfatherComponent.html" >FlowfatherComponent</a>
  93. </li>
  94. <li class="link">
  95. <a href="../components/FlowtestComponent.html" >FlowtestComponent</a>
  96. </li>
  97. <li class="link">
  98. <a href="../components/HomeComponent.html" >HomeComponent</a>
  99. </li>
  100. <li class="link">
  101. <a href="../components/NavTabsComponent.html" >NavTabsComponent</a>
  102. </li>
  103. <li class="link">
  104. <a href="../components/PageMineComponent.html" >PageMineComponent</a>
  105. </li>
  106. <li class="link">
  107. <a href="../components/PageSpotDetailComponent.html" >PageSpotDetailComponent</a>
  108. </li>
  109. </ul>
  110. </li>
  111. <li class="chapter">
  112. <div class="simple">
  113. <span class="fa fa-file-code-o"></span>
  114. <span>Classes</span>
  115. <span class="menu-toggler fa fa-angle-up" data-toggle="collapse"
  116. data-target="#xs-classes-links"
  117. ></span>
  118. </div>
  119. <ul class="links collapse in"
  120. id="xs-classes-links"
  121. >
  122. <li class="link">
  123. <a href="../classes/TestChatCompletion.html" >TestChatCompletion</a>
  124. </li>
  125. </ul>
  126. </li>
  127. <li class="chapter">
  128. <div class="simple">
  129. <span class="fa fa-long-arrow-down"></span>
  130. <span>Injectables</span>
  131. <span class="menu-toggler fa fa-angle-up" data-toggle="collapse"
  132. data-target="#xs-injectables-links"
  133. ></span>
  134. </div>
  135. <ul class="links collapse in"
  136. id="xs-injectables-links"
  137. >
  138. <li class="link">
  139. <a href="../injectables/DataServiceService.html" >DataServiceService</a>
  140. </li>
  141. </ul>
  142. </li>
  143. <li class="chapter">
  144. <div class="simple">
  145. <span class="fa fa-info"></span>
  146. <span>Interfaces</span>
  147. <span class="menu-toggler fa fa-angle-up" data-toggle="collapse"
  148. data-target="#xs-interfaces-links"
  149. ></span>
  150. </div>
  151. <ul class="links collapse in"
  152. id="xs-interfaces-links"
  153. >
  154. <li class="link">
  155. <a href="../interfaces/TestChatMessage.html" >TestChatMessage</a>
  156. </li>
  157. </ul>
  158. </li>
  159. <li class="chapter">
  160. <div class="simple">
  161. <span class="fa fa-plus"></span>
  162. <span>Pipes</span>
  163. <span class="menu-toggler fa fa-angle-up" data-toggle="collapse"
  164. data-target="#xs-pipes-links"
  165. ></span>
  166. </div>
  167. <ul class="links collapse in"
  168. id="xs-pipes-links"
  169. >
  170. <li class="link">
  171. <a href="../pipes/TokPipe.html" >TokPipe</a>
  172. </li>
  173. </ul>
  174. </li>
  175. <li class="chapter">
  176. <a data-type="chapter-link" href="../coverage.html" ><span class="fa fa-tasks"></span>Documentation coverage</a>
  177. </li>
  178. <li class="divider"></li>
  179. <li class="copyright">
  180. Documentation generated using <a href="https://compodoc.github.io/compodoc/" target="_blank">
  181. <img src="..//images/compodoc-vectorise.svg" class="img-responsive">
  182. </a>
  183. </li>
  184. </ul>
  185. </nav>
  186. </div>
  187. <div class="container-fluid main">
  188. <div class="row main">
  189. <div class="hidden-xs menu">
  190. <nav>
  191. <ul class="list">
  192. <li class="title">
  193. <a href="../">app-angular documentation</a>
  194. </li>
  195. <li class="divider"></li>
  196. <div id="book-search-input" role="search">
  197. <input type="text" placeholder="Type to search">
  198. </div>
  199. <li class="chapter">
  200. <a data-type="chapter-link" href="../"><span class="fa fa-home"></span>Getting started</a>
  201. <ul class="links">
  202. <li class="link">
  203. <a href="../" ><span class="fa fa-file-text-o"></span>README</a>
  204. </li>
  205. <li class="link">
  206. <a
  207. href="../overview.html"
  208. href="../overview.html"
  209. >
  210. <span class="fa fa-th"></span>Overview
  211. </a>
  212. </li>
  213. </ul>
  214. </li>
  215. <li class="chapter">
  216. <a data-type="chapter-link" href="./modules.html" >
  217. <span class="fa fa-archive"></span>
  218. <span>Modules</span>
  219. <span class="menu-toggler fa fa-angle-up" data-toggle="collapse"
  220. data-target="#modules-links"
  221. ></span>
  222. </a>
  223. <ul class="links collapse in"
  224. id="modules-links"
  225. >
  226. <li class="link">
  227. <a href="../modules/AppModule.html" >AppModule</a>
  228. </li>
  229. <li class="link">
  230. <a href="../modules/LessonModule.html" >LessonModule</a>
  231. </li>
  232. </ul>
  233. </li>
  234. <li class="chapter">
  235. <div class="simple">
  236. <span class="fa fa-cogs"></span>
  237. <span>Components</span>
  238. <span class="menu-toggler fa fa-angle-up" data-toggle="collapse"
  239. data-target="#components-links"
  240. ></span>
  241. </div>
  242. <ul class="links collapse in"
  243. id="components-links"
  244. >
  245. <li class="link">
  246. <a href="../components/AppComponent.html" >AppComponent</a>
  247. </li>
  248. <li class="link">
  249. <a href="../components/BblComponent.html" >BblComponent</a>
  250. </li>
  251. <li class="link">
  252. <a href="../components/DetailComponent.html" >DetailComponent</a>
  253. </li>
  254. <li class="link">
  255. <a href="../components/EcharsComponent.html" >EcharsComponent</a>
  256. </li>
  257. <li class="link">
  258. <a href="../components/EchartsExempleComponent.html" class="active" >EchartsExempleComponent</a>
  259. </li>
  260. <li class="link">
  261. <a href="../components/EditComponent.html" >EditComponent</a>
  262. </li>
  263. <li class="link">
  264. <a href="../components/FlowfatherComponent.html" >FlowfatherComponent</a>
  265. </li>
  266. <li class="link">
  267. <a href="../components/FlowtestComponent.html" >FlowtestComponent</a>
  268. </li>
  269. <li class="link">
  270. <a href="../components/HomeComponent.html" >HomeComponent</a>
  271. </li>
  272. <li class="link">
  273. <a href="../components/NavTabsComponent.html" >NavTabsComponent</a>
  274. </li>
  275. <li class="link">
  276. <a href="../components/PageMineComponent.html" >PageMineComponent</a>
  277. </li>
  278. <li class="link">
  279. <a href="../components/PageSpotDetailComponent.html" >PageSpotDetailComponent</a>
  280. </li>
  281. </ul>
  282. </li>
  283. <li class="chapter">
  284. <div class="simple">
  285. <span class="fa fa-file-code-o"></span>
  286. <span>Classes</span>
  287. <span class="menu-toggler fa fa-angle-up" data-toggle="collapse"
  288. data-target="#classes-links"
  289. ></span>
  290. </div>
  291. <ul class="links collapse in"
  292. id="classes-links"
  293. >
  294. <li class="link">
  295. <a href="../classes/TestChatCompletion.html" >TestChatCompletion</a>
  296. </li>
  297. </ul>
  298. </li>
  299. <li class="chapter">
  300. <div class="simple">
  301. <span class="fa fa-long-arrow-down"></span>
  302. <span>Injectables</span>
  303. <span class="menu-toggler fa fa-angle-up" data-toggle="collapse"
  304. data-target="#injectables-links"
  305. ></span>
  306. </div>
  307. <ul class="links collapse in"
  308. id="injectables-links"
  309. >
  310. <li class="link">
  311. <a href="../injectables/DataServiceService.html" >DataServiceService</a>
  312. </li>
  313. </ul>
  314. </li>
  315. <li class="chapter">
  316. <div class="simple">
  317. <span class="fa fa-info"></span>
  318. <span>Interfaces</span>
  319. <span class="menu-toggler fa fa-angle-up" data-toggle="collapse"
  320. data-target="#interfaces-links"
  321. ></span>
  322. </div>
  323. <ul class="links collapse in"
  324. id="interfaces-links"
  325. >
  326. <li class="link">
  327. <a href="../interfaces/TestChatMessage.html" >TestChatMessage</a>
  328. </li>
  329. </ul>
  330. </li>
  331. <li class="chapter">
  332. <div class="simple">
  333. <span class="fa fa-plus"></span>
  334. <span>Pipes</span>
  335. <span class="menu-toggler fa fa-angle-up" data-toggle="collapse"
  336. data-target="#pipes-links"
  337. ></span>
  338. </div>
  339. <ul class="links collapse in"
  340. id="pipes-links"
  341. >
  342. <li class="link">
  343. <a href="../pipes/TokPipe.html" >TokPipe</a>
  344. </li>
  345. </ul>
  346. </li>
  347. <li class="chapter">
  348. <a data-type="chapter-link" href="../coverage.html" ><span class="fa fa-tasks"></span>Documentation coverage</a>
  349. </li>
  350. <li class="divider"></li>
  351. <li class="copyright">
  352. Documentation generated using <a href="https://compodoc.github.io/compodoc/" target="_blank">
  353. <img src="..//images/compodoc-vectorise.svg" class="img-responsive">
  354. </a>
  355. </li>
  356. </ul>
  357. </nav>
  358. </div>
  359. <div class="content component">
  360. <div class="content-data">
  361. <ol class="breadcrumb">
  362. <li>Components</li>
  363. <li>EchartsExempleComponent</li>
  364. </ol>
  365. <ul class="nav nav-tabs" role="tablist">
  366. <li class="active">
  367. <a href="#infos" id="infos-tab" role="tab" data-toggle="tab">Infos</a>
  368. </li>
  369. <li>
  370. <a href="#source" role="tab" id="source-tab" data-toggle="tab">Source</a>
  371. </li>
  372. </ul>
  373. <div class="tab-content">
  374. <div class="tab-pane fade active in" id="infos"><p class="comment">
  375. <h3>File</h3>
  376. </p>
  377. <p class="comment">
  378. <code>src/modules/lesson/echarts-exemple/echarts-exemple.component.ts</code>
  379. </p>
  380. <section>
  381. <h3>Metadata</h3>
  382. <table class="table table-sm table-hover">
  383. <tbody>
  384. <tr>
  385. <td class="col-md-3">selector</td>
  386. <td class="col-md-9"><code>app-echarts-exemple</code></td>
  387. </tr>
  388. <tr>
  389. <td class="col-md-3">styleUrls</td>
  390. <td class="col-md-9"><code>echarts-exemple.component.scss</code></td>
  391. </tr>
  392. <tr>
  393. <td class="col-md-3">templateUrl</td>
  394. <td class="col-md-9"><code>echarts-exemple.component.html</code></td>
  395. </tr>
  396. </tbody>
  397. </table>
  398. </section>
  399. <section>
  400. <h3 id="methods">Methods</h3>
  401. <table class="table table-sm table-bordered">
  402. <tbody>
  403. <tr>
  404. <td class="col-md-4">
  405. <b><span class="modifier"></span> getWeightData</b>
  406. </td>
  407. </tr>
  408. <tr>
  409. <td class="col-md-4">
  410. <span class="modifier-icon method fa fa-play ">
  411. <span class="fa fa-"></span>
  412. </span>
  413. <code>getWeightData()</code>
  414. </td>
  415. </tr>
  416. <tr>
  417. <td class="col-md-4">
  418. <div class="io-description">
  419. <b>Returns: </b> <code>any</code>
  420. </div>
  421. </td>
  422. </tr>
  423. </tbody>
  424. </table>
  425. <table class="table table-sm table-bordered">
  426. <tbody>
  427. <tr>
  428. <td class="col-md-4">
  429. <b><span class="modifier"></span> getHeightData</b>
  430. </td>
  431. </tr>
  432. <tr>
  433. <td class="col-md-4">
  434. <span class="modifier-icon method fa fa-play ">
  435. <span class="fa fa-"></span>
  436. </span>
  437. <code>getHeightData()</code>
  438. </td>
  439. </tr>
  440. <tr>
  441. <td class="col-md-4">
  442. <div class="io-description">
  443. <b>Returns: </b> <code>any</code>
  444. </div>
  445. </td>
  446. </tr>
  447. </tbody>
  448. </table>
  449. <table class="table table-sm table-bordered">
  450. <tbody>
  451. <tr>
  452. <td class="col-md-4">
  453. <b><span class="modifier"></span> getDate</b>
  454. </td>
  455. </tr>
  456. <tr>
  457. <td class="col-md-4">
  458. <span class="modifier-icon method fa fa-play ">
  459. <span class="fa fa-"></span>
  460. </span>
  461. <code>getDate()</code>
  462. </td>
  463. </tr>
  464. <tr>
  465. <td class="col-md-4">
  466. <div class="io-description">
  467. <b>Returns: </b> <code>any</code>
  468. </div>
  469. </td>
  470. </tr>
  471. </tbody>
  472. </table>
  473. <table class="table table-sm table-bordered">
  474. <tbody>
  475. <tr>
  476. <td class="col-md-4">
  477. <b><span class="modifier"></span> calculateBMI</b>
  478. </td>
  479. </tr>
  480. <tr>
  481. <td class="col-md-4">
  482. <span class="modifier-icon method fa fa-play ">
  483. <span class="fa fa-"></span>
  484. </span>
  485. <code>calculateBMI()</code>
  486. </td>
  487. </tr>
  488. <tr>
  489. <td class="col-md-4">
  490. <div class="io-description">
  491. <b>Returns: </b> <code>any</code>
  492. </div>
  493. </td>
  494. </tr>
  495. </tbody>
  496. </table>
  497. </section>
  498. <section>
  499. <h3 id="inputs">Properties</h3>
  500. <table class="table table-sm table-bordered">
  501. <tbody>
  502. <tr>
  503. <td class="col-md-4">
  504. <b> BMI</b>
  505. </td>
  506. </tr>
  507. <tr>
  508. <td class="col-md-4">
  509. <code>BMI: <code>any</code>
  510. </bcode>
  511. </td>
  512. </tr>
  513. </tbody>
  514. </table>
  515. <table class="table table-sm table-bordered">
  516. <tbody>
  517. <tr>
  518. <td class="col-md-4">
  519. <b> date</b>
  520. </td>
  521. </tr>
  522. <tr>
  523. <td class="col-md-4">
  524. <code>date: <code>any</code>
  525. </bcode>
  526. </td>
  527. </tr>
  528. </tbody>
  529. </table>
  530. <table class="table table-sm table-bordered">
  531. <tbody>
  532. <tr>
  533. <td class="col-md-4">
  534. <b> heightData</b>
  535. </td>
  536. </tr>
  537. <tr>
  538. <td class="col-md-4">
  539. <code>heightData: <code>any</code>
  540. </bcode>
  541. </td>
  542. </tr>
  543. </tbody>
  544. </table>
  545. <table class="table table-sm table-bordered">
  546. <tbody>
  547. <tr>
  548. <td class="col-md-4">
  549. <b> weightData</b>
  550. </td>
  551. </tr>
  552. <tr>
  553. <td class="col-md-4">
  554. <code>weightData: <code>any</code>
  555. </bcode>
  556. </td>
  557. </tr>
  558. </tbody>
  559. </table>
  560. </section>
  561. </div>
  562. <div class="tab-pane fade tab-source-code" id="source">
  563. <pre><code class="hljs javascript">import * as echarts from &#x27;echarts&#x27;;
  564. import { AfterViewInit, Component } from &#x27;@angular/core&#x27;;
  565. import * as Parse from &quot;parse&quot;
  566. (Parse as any).serverURL &#x3D; &quot;http://metapunk.cn:9999/parse&quot;
  567. Parse.initialize(&quot;dev&quot;)
  568. @Component({
  569. selector: &#x27;app-echarts-exemple&#x27;,
  570. templateUrl: &#x27;./echarts-exemple.component.html&#x27;,
  571. styleUrls: [&#x27;./echarts-exemple.component.scss&#x27;]
  572. })
  573. export class EchartsExempleComponent implements AfterViewInit {
  574. date: Promise&lt;string[] | null&gt; &#x3D; this.getDate();
  575. heightData: Promise&lt;number[] | null&gt; &#x3D; this.getHeightData();
  576. weightData: Promise&lt;number[] | null&gt; &#x3D; this.getWeightData();
  577. BMI: Promise&lt;number[] | null&gt; &#x3D; this.calculateBMI();
  578. // 组件初始化
  579. async ngAfterViewInit() {
  580. //第一个echarts表
  581. var chartDom &#x3D; document.getElementById(&#x27;main&#x27;);
  582. var myChart &#x3D; echarts.init(chartDom);
  583. var option;
  584. option &#x3D; {
  585. title: {
  586. text: &#x27;身体数据&#x27;
  587. },
  588. tooltip: {
  589. trigger: &#x27;axis&#x27;
  590. },
  591. legend: {
  592. data: [&#x27;身高&#x27;, &#x27;体重&#x27;,]
  593. },
  594. // grid: {
  595. // left: &#x27;3%&#x27;,
  596. // right: &#x27;4%&#x27;,
  597. // bottom: &#x27;3%&#x27;,
  598. // containLabel: true
  599. // },
  600. toolbox: {
  601. feature: {
  602. saveAsImage: {}
  603. }
  604. },
  605. xAxis: {
  606. type: &#x27;category&#x27;,
  607. boundaryGap: false,
  608. data: await this.date
  609. },
  610. yAxis: {
  611. type: &#x27;value&#x27;,
  612. min: 0,
  613. max: 250,
  614. },
  615. series: [
  616. {
  617. name: &#x27;身高&#x27;,
  618. type: &#x27;line&#x27;,
  619. data: await this.heightData
  620. },
  621. {
  622. name: &#x27;体重&#x27;,
  623. type: &#x27;line&#x27;,
  624. data: await this.weightData
  625. },
  626. ]
  627. };
  628. option &amp;&amp; myChart.setOption(option);
  629. //第二个echarts表
  630. var chartDom &#x3D; document.getElementById(&#x27;main1&#x27;);
  631. var myChart &#x3D; echarts.init(chartDom);
  632. var option;
  633. option &#x3D; {
  634. toolbox: {
  635. feature: {
  636. saveAsImage: {}
  637. }
  638. },
  639. title: {
  640. text: &#x27;BMI&#x27;
  641. },
  642. tooltip: {
  643. trigger: &#x27;axis&#x27;
  644. },
  645. xAxis: {
  646. type: &#x27;category&#x27;,
  647. boundaryGap: false,
  648. data: await this.date,
  649. },
  650. yAxis: {
  651. type: &#x27;value&#x27;
  652. },
  653. series: [
  654. {
  655. data: await this.BMI,
  656. type: &#x27;line&#x27;,
  657. smooth: true,
  658. markLine: {
  659. data: [
  660. { type: &#x27;max&#x27;, name: &#x27;最大值&#x27;, yAxis: 24.9 },
  661. { type: &#x27;min&#x27;, name: &#x27;最小值&#x27;, yAxis: 18.5 }
  662. ]
  663. }
  664. }
  665. ]
  666. };
  667. option &amp;&amp; myChart.setOption(option);
  668. }
  669. async getWeightData(): Promise&lt;number[] | null&gt; {
  670. const Upload &#x3D; Parse.Object.extend(&quot;HealthData&quot;);
  671. const query &#x3D; new Parse.Query(Upload);
  672. try {
  673. const result &#x3D; await query.find();
  674. if (result.length &gt; 0) {
  675. const weightDatas &#x3D; result.map((result) &#x3D;&gt; result.get(&quot;weight&quot;));
  676. console.log(&quot;体重数组&quot;, weightDatas);
  677. return weightDatas;
  678. } else {
  679. return null;
  680. }
  681. } catch (error) {
  682. console.error(&quot;Error:&quot;, error);
  683. return null;
  684. }
  685. }
  686. async getHeightData(): Promise&lt;number[] | null&gt; {
  687. const Upload &#x3D; Parse.Object.extend(&quot;HealthData&quot;);
  688. const query &#x3D; new Parse.Query(Upload);
  689. try {
  690. const result &#x3D; await query.find();
  691. if (result.length &gt; 0) {
  692. const heightDatas &#x3D; result.map((result) &#x3D;&gt; result.get(&quot;height&quot;));
  693. console.log(&quot;身高数组&quot;, heightDatas);
  694. return heightDatas;
  695. } else {
  696. return null;
  697. }
  698. } catch (error) {
  699. console.error(&quot;Error:&quot;, error);
  700. return null;
  701. }
  702. }
  703. async getDate(): Promise&lt;string[] | null&gt; {
  704. const Upload &#x3D; Parse.Object.extend(&quot;HealthData&quot;);
  705. const query &#x3D; new Parse.Query(Upload);
  706. query.descending(&quot;createdAt&quot;);
  707. try {
  708. const result &#x3D; await query.find();
  709. if (result.length &gt; 0) {
  710. const Dates &#x3D; result.map((result) &#x3D;&gt; {
  711. const date &#x3D; result.get(&quot;createdAt&quot;);
  712. return date.toISOString().split(&#x27;T&#x27;)[0];
  713. }).reverse();
  714. console.log(&quot;日期数组&quot;, Dates);
  715. return Dates;
  716. } else {
  717. return null;
  718. }
  719. } catch (error) {
  720. console.error(&quot;Error:&quot;, error);
  721. return null;
  722. }
  723. }
  724. async calculateBMI(): Promise&lt;number[] | null&gt; {
  725. try {
  726. const heightData: number[] | null &#x3D; await this.getHeightData();
  727. const weightData: number[] | null &#x3D; await this.getWeightData();
  728. if (heightData &#x3D;&#x3D;&#x3D; null || weightData &#x3D;&#x3D;&#x3D; null) {
  729. return null;
  730. }
  731. const bmiData: number[] &#x3D; [];
  732. for (let i &#x3D; 0; i &lt; heightData.length; i++) {
  733. const heightInMeter: number &#x3D; heightData[i] / 100; // 将厘米转换为米
  734. const bmi: number &#x3D; weightData[i] / (heightInMeter * heightInMeter);
  735. bmiData.push(bmi);
  736. }
  737. console.log(bmiData);
  738. return bmiData;
  739. } catch (error) {
  740. console.error(&#x27;Error calculating BMI:&#x27;, error);
  741. return null;
  742. }
  743. }
  744. }</code></pre>
  745. </div>
  746. </div>
  747. </div><div class="search-results">
  748. <div class="has-results">
  749. <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
  750. <ul class="search-results-list"></ul>
  751. </div>
  752. <div class="no-results">
  753. <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
  754. </div>
  755. </div>
  756. </div>
  757. </div>
  758. </div>
  759. <script src="../js/libs/bootstrap-native.js"></script>
  760. <script src="../js/libs/es6-shim.min.js"></script>
  761. <script src="../js/libs/EventDispatcher.js"></script>
  762. <script src="../js/libs/promise.min.js"></script>
  763. <script src="../js/libs/zepto.min.js"></script>
  764. <script src="../js/compodoc.js"></script>
  765. <script src="../js/search/search.js"></script>
  766. <script src="../js/search/lunr.min.js"></script>
  767. <script src="../js/search/search-lunr.js"></script>
  768. <script src="../js/menu.js"></script>
  769. <script src="../js/libs/highlight.pack.js"></script>
  770. <script src="../js/libs/highlightjs-line-numbers.min.js"></script>
  771. <script src="../js/search/search_index.js"></script>
  772. <script>
  773. document.addEventListener('DOMContentLoaded', function() {
  774. hljs.initHighlightingOnLoad();
  775. hljs.initLineNumbersOnLoad();
  776. });
  777. </script>
  778. </body>
  779. </html>