egatari 0.6.16 → 0.6.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/CHANGELOG.md +43 -1
  2. package/README.ja.md +14 -13
  3. package/README.md +2 -1
  4. package/components.lock.json +119 -45
  5. package/components2.lock.json +639 -1
  6. package/kit/check-messages.mjs +5 -0
  7. package/kit/check.mjs +6 -0
  8. package/kit/core/bookmark.mjs +28 -0
  9. package/kit/core/build-core.mjs +4 -2
  10. package/kit/core/check-parity.mjs +4 -0
  11. package/kit/core/check-rules.mjs +3 -2
  12. package/kit/core/check-source.mjs +6 -0
  13. package/kit/core/llm-pack-assemble.mjs +37 -66
  14. package/kit/core/llm-pack-data.mjs +839 -45
  15. package/kit/core/llm-pack.mjs +6 -4
  16. package/kit/core/llm-request.mjs +2 -2
  17. package/kit/core/new-deck-pack.mjs +38 -44
  18. package/kit/core/new-deck.mjs +82 -74
  19. package/kit/core/part-labels.mjs +2 -0
  20. package/kit/core/purposes.mjs +9 -3
  21. package/kit/core/sample-info.mjs +17 -3
  22. package/kit/core/slide-ops.mjs +22 -0
  23. package/kit/core/tate-mix.mjs +25 -0
  24. package/kit/core/theme-derive.mjs +56 -17
  25. package/kit/core/theme-shapes.mjs +15 -1
  26. package/kit/deck.js +53 -2
  27. package/kit/instruction-version.json +1 -1
  28. package/kit/llm-pack.mjs +5 -7
  29. package/kit/player.json +1 -1
  30. package/kit/player.lock.json +2 -2
  31. package/kit/presenter.js +36 -4
  32. package/kit/tools.js +54 -2
  33. package/package.json +1 -1
  34. package/vendor/components/CATALOG.md +24 -22
  35. package/vendor/components/sha256/038f9d32c89c8212ab25d6e3180023b6fe024a53053ab2ef1443ecab92e3ce43/index.js +205 -0
  36. package/vendor/components/sha256/07479cb6e5194a01b2a8a9029f3646060f0dbb673f2737d2132738af2eb379e5/README.en.md +44 -0
  37. package/vendor/components/sha256/07479cb6e5194a01b2a8a9029f3646060f0dbb673f2737d2132738af2eb379e5/index.js +306 -0
  38. package/vendor/components/sha256/077678d8b14a8065c4f74a9fe1669728c68a0f763bfdca18b304f5c3d863632a/README.en.md +54 -0
  39. package/vendor/components/sha256/077678d8b14a8065c4f74a9fe1669728c68a0f763bfdca18b304f5c3d863632a/index.js +470 -0
  40. package/vendor/components/sha256/0840322bf51eeb3c8188ce21ad70af17c13974ac0151065a39c430a3813ee07f/README.en.md +23 -0
  41. package/vendor/components/sha256/0840322bf51eeb3c8188ce21ad70af17c13974ac0151065a39c430a3813ee07f/index.js +289 -0
  42. package/vendor/components/sha256/0c25d49d23529879054737aa181951519fe585c4728fd505e0e3c8869953eac7/index.js +934 -0
  43. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/LICENSE-strokesvg.txt +115 -0
  44. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/OFL.txt +93 -0
  45. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/index.js +755 -0
  46. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/strokes-CHANGES.md +20 -0
  47. package/vendor/components/sha256/0e9e92df8d70eb6d9fcf10916c361769c7cd37baacece8d7eb96bbbc7fbcf942/README.en.md +25 -0
  48. package/vendor/components/sha256/0e9e92df8d70eb6d9fcf10916c361769c7cd37baacece8d7eb96bbbc7fbcf942/index.js +317 -0
  49. package/vendor/components/sha256/12ef6a11055407f5cddc40154a49cf2737b0786429fe0fcc94ee1d8245597b40/index.js +244 -0
  50. package/vendor/components/sha256/13c9ce43396b2f5693ce430a924dae4ddcd1e8a4ad0c9b9e724ff52acb874d0c/index.js +354 -0
  51. package/vendor/components/sha256/1a0f21def0efbbdef64461cafa40f3883bc7f7122adf79d01f09ca4a245e5dcb/index.js +465 -0
  52. package/vendor/components/sha256/208175d05b37d326855fad792b10137f785e5d05d91a2cde119d0dbd69d2ed98/index.js +100 -0
  53. package/vendor/components/sha256/218d88998b70f0732c18d91ccc238b2d63f6b0aaa483883b83685a25468f214a/README.en.md +34 -0
  54. package/vendor/components/sha256/218d88998b70f0732c18d91ccc238b2d63f6b0aaa483883b83685a25468f214a/index.js +246 -0
  55. package/vendor/components/sha256/2579bcb46b6525902763cd15a2e08fc5ebd9a2695cdaba63438e5b47907a47e0/README.en.md +24 -0
  56. package/vendor/components/sha256/2579bcb46b6525902763cd15a2e08fc5ebd9a2695cdaba63438e5b47907a47e0/index.js +554 -0
  57. package/vendor/components/sha256/2787e410e533e4ad48b0a3c2b652579cf5797f9c51fcf32f5478212a7acef95f/README.en.md +28 -0
  58. package/vendor/components/sha256/2787e410e533e4ad48b0a3c2b652579cf5797f9c51fcf32f5478212a7acef95f/index.js +214 -0
  59. package/vendor/components/sha256/2a011338d0fc3c77e102eaa57cde2b6e3726bc279f133174b0b8c9a654263cbc/index.js +824 -0
  60. package/vendor/components/sha256/2fce5ab0c31dca0aa1586a2c69237870a9cce46c0bc6ab7392c27968d016bd15/index.js +75 -0
  61. package/vendor/components/sha256/3417efe4722f569690563d9abcea8b144db2f8fa97b83cf0118fb3a34cd4cb2b/README.en.md +23 -0
  62. package/vendor/components/sha256/3417efe4722f569690563d9abcea8b144db2f8fa97b83cf0118fb3a34cd4cb2b/index.js +150 -0
  63. package/vendor/components/sha256/3a7962fa87c670447eed54aca08604ef03cd26bf2c334b4667190060e6a17965/README.en.md +18 -0
  64. package/vendor/components/sha256/3a7962fa87c670447eed54aca08604ef03cd26bf2c334b4667190060e6a17965/index.js +279 -0
  65. package/vendor/components/sha256/42450c6b36404d66641568f6d6f55e42a4a036d4d9cdf308f709464913b32fe9/README.en.md +42 -0
  66. package/vendor/components/sha256/42450c6b36404d66641568f6d6f55e42a4a036d4d9cdf308f709464913b32fe9/index.js +272 -0
  67. package/vendor/components/sha256/45cea6c1abfb3467e3e3dbe7fec58647716999a0c39cf7163531ae389f898d29/README.en.md +30 -0
  68. package/vendor/components/sha256/45cea6c1abfb3467e3e3dbe7fec58647716999a0c39cf7163531ae389f898d29/index.js +305 -0
  69. package/vendor/components/sha256/4c8cae404d551a1bb021e8345af5aa45d4f412f13497aa84b142f11a29a365dc/index.js +124 -0
  70. package/vendor/components/sha256/5521b5b40a43c48c5ae5a50ce87afb3d47bb23b133b16841086d8322364cdd5e/README.en.md +23 -0
  71. package/vendor/components/sha256/5521b5b40a43c48c5ae5a50ce87afb3d47bb23b133b16841086d8322364cdd5e/index.js +120 -0
  72. package/vendor/components/sha256/5fe30fd7a84b937a1325d8af2b8e437211efae82ab46d5a433bc4ef07bcaef11/README.en.md +18 -0
  73. package/vendor/components/sha256/5fe30fd7a84b937a1325d8af2b8e437211efae82ab46d5a433bc4ef07bcaef11/index.js +243 -0
  74. package/vendor/components/sha256/631f4c4b90c9a41c0f26c9600d5cf2d6447251d04a20f08f48a85aeb4cb0f6fb/index.js +107 -0
  75. package/vendor/components/sha256/6749f44ed6476a05d4e3026373c188a0e1a19b77a5836579813f62a1477ac35e/README.en.md +31 -0
  76. package/vendor/components/sha256/6749f44ed6476a05d4e3026373c188a0e1a19b77a5836579813f62a1477ac35e/index.js +271 -0
  77. package/vendor/components/sha256/701f1deef79fe05eeb18e1119e5a5c4d60a9dfe265e93a4dff79223bc598dbf0/index.js +521 -0
  78. package/vendor/components/sha256/711cf58fa946c9c0abc953b2f695d02bf5a5a7f73851b09f834e894baf88be38/index.js +122 -0
  79. package/vendor/components/sha256/728576c57a5ccb39531ad4cb8074fce95480f01603a77dbf57dca0e52199f7c4/index.js +37 -0
  80. package/vendor/components/sha256/73edc74a2dc4a63b717106c1c1572967b6d306270574e9635d032de16c8ada72/README.en.md +18 -0
  81. package/vendor/components/sha256/73edc74a2dc4a63b717106c1c1572967b6d306270574e9635d032de16c8ada72/index.js +382 -0
  82. package/vendor/components/sha256/76bdb63c3e5e14fbb4816bc9f235490817bb5d7be990a826f5077aa08226702c/index.js +162 -0
  83. package/vendor/components/sha256/7a5adf73fc053b9f2ca56643b5683b42589edb0f63c845ecb7ae7e6b87eccc30/README.en.md +51 -0
  84. package/vendor/components/sha256/7a5adf73fc053b9f2ca56643b5683b42589edb0f63c845ecb7ae7e6b87eccc30/index.js +230 -0
  85. package/vendor/components/sha256/7ab483e7fb05f646b062340d70f2749d070b4f64fed7acc0b8a7754d9ef9fded/README.en.md +26 -0
  86. package/vendor/components/sha256/7ab483e7fb05f646b062340d70f2749d070b4f64fed7acc0b8a7754d9ef9fded/index.js +322 -0
  87. package/vendor/components/sha256/7af6e5e6dffb618b39f27d883c691ca128f3af06040ee505e75c79c678bfdcfe/README.en.md +18 -0
  88. package/vendor/components/sha256/7af6e5e6dffb618b39f27d883c691ca128f3af06040ee505e75c79c678bfdcfe/index.js +103 -0
  89. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/ABCJS-ADAPTER.md +101 -0
  90. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/LICENSE-abcjs.txt +21 -0
  91. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/chords.json +89 -0
  92. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/doremi.json +261 -0
  93. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/extras.json +192 -0
  94. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/kaeru.json +521 -0
  95. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/rhythm.json +248 -0
  96. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/ties.json +360 -0
  97. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/index.js +508 -0
  98. package/vendor/components/sha256/832556ea9c82c292a3ba9e1b332f2405c5c2f969ff8157c91ed80226ec8ac62e/README.en.md +22 -0
  99. package/vendor/components/sha256/832556ea9c82c292a3ba9e1b332f2405c5c2f969ff8157c91ed80226ec8ac62e/index.js +145 -0
  100. package/vendor/components/sha256/8a4b6dce84d7a69aaafeb75c1c572fe7904fd49e3169c1c85851ccaeae2a7b11/index.js +41 -0
  101. package/vendor/components/sha256/8bb511cb90902bc7721e59ca08685b26adbf33539e36a4a45172485d6d3d455b/index.js +250 -0
  102. package/vendor/components/sha256/8db9c936c36b79b9e3b2be37639487b15502a6937f411ed714621a8091437e9b/README.en.md +21 -0
  103. package/vendor/components/sha256/8db9c936c36b79b9e3b2be37639487b15502a6937f411ed714621a8091437e9b/index.js +108 -0
  104. package/vendor/components/sha256/8e5e90c90cb6b06a790b0420e43d79d7da663f1cc19ff06d381ec849b4a8fc57/index.js +312 -0
  105. package/vendor/components/sha256/a1c2b2fa06e4229815ab82a9202c266ec887a67632a175854c7d136a92389ca3/index.js +69 -0
  106. package/vendor/components/sha256/a7c4282db79d46557bdbaf84ca519606dc46f3c23455db4a26f663453f85813c/README.en.md +38 -0
  107. package/vendor/components/sha256/a7c4282db79d46557bdbaf84ca519606dc46f3c23455db4a26f663453f85813c/index.js +414 -0
  108. package/vendor/components/sha256/aac2f8a23cb1b606e9635061cb288f006588c80a7258540cae846ae677f55ff5/index.js +238 -0
  109. package/vendor/components/sha256/ace7e82e866b577ad42bbc4b64e11bae18982e3236aadceb6c2e6c20f41234cf/README.en.md +45 -0
  110. package/vendor/components/sha256/ace7e82e866b577ad42bbc4b64e11bae18982e3236aadceb6c2e6c20f41234cf/index.js +211 -0
  111. package/vendor/components/sha256/aeb0b9b5991a5c1df7191c397780a699f2c7310123ca210a58486c0a23e44006/index.js +342 -0
  112. package/vendor/components/sha256/af3355efd6739a56c6cb53990100f41703361c475c123b9b2762421c68509036/index.js +315 -0
  113. package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/LICENSE-tabler.txt +21 -0
  114. package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/index.js +4868 -0
  115. package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/names.txt +4808 -0
  116. package/vendor/components/sha256/b348ea64cc19632df96a91dfd7c435e4a62095aede72b504d03537be70d6d930/index.js +606 -0
  117. package/vendor/components/sha256/b53bfa03d1e9feb3cb492f440bf9d100c96eb4fe6b76c42b512a56e9158829cd/index.js +351 -0
  118. package/vendor/components/sha256/b9443e1cdac4850b1ead9f8449a3061678bbb77fbc53eb9b23d01e1cf50750c3/index.js +619 -0
  119. package/vendor/components/sha256/bc1e2a02c959ac203819d03c0d25b3776a6a9a4290aae860b26cbbe3d29e876d/index.js +268 -0
  120. package/vendor/components/sha256/beeb180c0e2250bb04490b092c0a235cae47fca2ed1de2d9ef078a5c14b1a963/index.js +429 -0
  121. package/vendor/components/sha256/c5fd7713e55e96d75824a21146c0251896d7d9dd028b4d169191433135a97981/index.js +200 -0
  122. package/vendor/components/sha256/c61987e9994940fc668ed8a010e575ee52027b54ed9c5dd1cc9fdf67649092b3/index.js +404 -0
  123. package/vendor/components/sha256/ccc8bfe174b6903ec254dfef4f5d1c614271ea39963649add7fcb8d83c081eba/index.js +278 -0
  124. package/vendor/components/sha256/da267bc65fde0a9279127d5a82f6c253ad74984da6fb11391f00604ad9ffe80d/index.js +93 -0
  125. package/vendor/components/sha256/dea36cd7010991a572ef394ee32b5e17564aeff09d3ec4ed3820d7e43c9a58be/index.js +484 -0
  126. package/vendor/components/sha256/df3fdb2aed487d4f6e60a8abab1fe0d1e9fa2a4193fd162edf3c384ea8db5a1b/index.js +180 -0
  127. package/vendor/components/sha256/e27d517f39eb554c7a9ecea7b59fcf1d347c4deeb3fe2250797aa233bfb7e2b0/index.js +747 -0
  128. package/vendor/components/sha256/e31f6b058503f7980597c89b3e964c512ee08de7cba3fa99904d499abbb5d0e8/README.en.md +20 -0
  129. package/vendor/components/sha256/e31f6b058503f7980597c89b3e964c512ee08de7cba3fa99904d499abbb5d0e8/index.js +310 -0
  130. package/vendor/components/sha256/f4100076a37dbde6046d85969d651feffc925bd984ffe9f333ea9bd2b6816918/README.en.md +30 -0
  131. package/vendor/components/sha256/f4100076a37dbde6046d85969d651feffc925bd984ffe9f333ea9bd2b6816918/index.js +192 -0
  132. package/vendor/components/sha256/fa6442fa3c5082cf161c29308fe0ecbd85fa33e8e4bad08c12e7961b46b1365b/README.en.md +24 -0
  133. package/vendor/components/sha256/fa6442fa3c5082cf161c29308fe0ecbd85fa33e8e4bad08c12e7961b46b1365b/index.js +214 -0
  134. package/vendor/components-2/manifest-2.16.0.json +2919 -0
  135. package/vendor/components-2/manifest-2.17.0.json +2852 -0
  136. package/vendor/components-2/manifest-2.18.0.json +3182 -0
  137. package/vendor/egatari-spec/SOURCE.json +2 -2
@@ -0,0 +1,306 @@
1
+ // m-scatter:散布図。点の組(系列)を段階ごとに出し、そのあと傾向の線を引く
2
+ // <m-scatter xr="[20,36]" yr="[0,800]" xl="最高気温(℃)" yl="売上(個)" style="height:420px">
3
+ // <script type="application/json">{"series": [{"label": "晴れ", "points": [[24, 210], [31, 560]]}], "trend": "linear"}
4
+ // (JSON の終わり)</m-scatter>
5
+ // 段階:既定は系列 1 つ = 1 段階、そのあと傾向の線(全部で 1 段階)。系列・線の step で直接
6
+ // 軸の属性(xr yr xt yt xf yf xl yl)は m-curves と同じ名前と意味。xr / yr を書かなければデータから切りのよい範囲を決め、
7
+ // xt / yt を書かなければ目盛りも決める
8
+ // 見せ方(docs/conventions.md §1):fade(点がフェードして現れる、既定)・sweep(左から右へ順に現れる)・grow(点が小さい点から
9
+ // 大きくなる)。傾向の線は fade では薄く現れ、sweep では左から引き、grow では真ん中から両側へ伸びる。段階の数・長さ・最後の中身は同じ
10
+ // 2.0(Egatari spec §6.1 の部品):base の MotionElement・el・mtext・prog・lerp・variant・previewOpacity と plot の Plot を使い、
11
+ // プレイヤーのグローバルは使わない。名前の置き場がない・傾向の線が軸の外・上の名前が図より広い、は ctx.report で知らせる
12
+ // (1.x は console.warn)
13
+ egatariParts.define({name: "scatter", version: "2.1.0", requires: {base: "1.3.0", plot: "1.1.3"}, element: "m-scatter"}, function(deps){
14
+ "use strict";
15
+ var base = deps.base, plot = deps.plot;
16
+ return class extends base.MotionElement {
17
+ static partName = "scatter"; // the registry name (define meta name), for report prefixes
18
+ static variants = ["fade", "sweep", "grow"];
19
+ // データの形(kit/shape.js)
20
+ static shape = (function(){
21
+ // 傾向の線の 2 点:ちょうど 2 つの [x, y]
22
+ var PTS = {type: "array", minItems: 2, maxItems: 2, items: {type: "array", minItems: 2, maxItems: 2, items: {type: "number"}}};
23
+ return {
24
+ schema: {type: "object", additionalProperties: false, required: ["series"], properties: {
25
+ series: {type: "array", minItems: 1, items: {type: "object", additionalProperties: false, required: ["points"], properties: {
26
+ label: {type: "string"}, tone: {type: "string"}, step: {type: "integer"}, at: {type: "number"},
27
+ points: {type: "array", items: {type: ["array", "object"], items: {type: "number"}, minItems: 2, maxItems: 2, required: ["x", "y"],
28
+ properties: {x: {type: "number"}, y: {type: "number"}, label: {type: "string"}, anchor: {enum: ["right", "left", "above", "below", "top", "bottom"]}, tone: {type: "string"}}}}}}},
29
+ trend: {type: ["string", "object", "array"], properties: {fit: {enum: ["linear"]}, pts: PTS, series: {type: ["integer", "array"]},
30
+ label: {type: "string"}, tone: {type: "string"}, dash: {type: "boolean"}, step: {type: "integer"}, at: {type: "number"}, digits: {type: "integer"}},
31
+ items: {type: "object", properties: {fit: {enum: ["linear"]}, pts: PTS, series: {type: ["integer", "array"]},
32
+ label: {type: "string"}, tone: {type: "string"}, dash: {type: "boolean"}, step: {type: "integer"}, at: {type: "number"}, digits: {type: "integer"}}}}}},
33
+ example: {series: [{label: "晴れ", points: [[24, 210], [28, 380], [31, 560], {x: 34, y: 690, label: "猛暑日"}]}], trend: "linear"},
34
+ note: {en: "points are [x, y] or {\"x\", \"y\", \"label\"}; axes go in attributes (xr=\"[0,10]\" xl=\"…\"); trend is \"linear\" or {\"fit\": \"linear\", \"label\": \"…\"} or {\"pts\": [[x0, y0], [x1, y1]]}",
35
+ ja: "点は [x, y] か {\"x\", \"y\", \"label\"}。軸は属性に書く(xr=\"[0,10]\" xl=\"…\")。trend は \"linear\" か {\"fit\": \"linear\", \"label\": \"…\"} か {\"pts\": [[x0, y0], [x1, y1]]}"},
36
+ };
37
+ })();
38
+ static props = {
39
+ xr: {type: "json", default: null, doc: "横軸の範囲(書かなければデータから)"}, yr: {type: "json", default: null, doc: "縦軸の範囲(書かなければデータから)"},
40
+ xt: {type: "json", default: null, doc: "横軸の目盛り(書かなければ自動)"}, yt: {type: "json", default: null, doc: "縦軸の目盛り(書かなければ自動)"},
41
+ xf: {type: "number", default: undefined, doc: "横軸の目盛りの小数桁"}, yf: {type: "number", default: undefined, doc: "縦軸の目盛りの小数桁"},
42
+ xl: {type: "string", default: ""}, yl: {type: "string", default: ""},
43
+ r: {type: "number", default: 9, doc: "点の半径(px)"},
44
+ dur: {type: "number", default: 1.0, doc: "1 ステップの動きの秒数"},
45
+ };
46
+ get steps(){
47
+ if (this.getAttribute("steps") !== null) return +this.getAttribute("steps");
48
+ var m = 0, pl = this.plan();
49
+ pl.series.forEach(function(s){ m = Math.max(m, s.step); });
50
+ pl.trends.forEach(function(s){ m = Math.max(m, s.step); });
51
+ return m;
52
+ }
53
+ // 系列と傾向の線の段階(mount の前にも steps が要るので、データだけから決める)
54
+ plan(){
55
+ if (this._plan) return this._plan;
56
+ var d = this.data || {}, last = 0;
57
+ var series = (d.series || []).map(function(s, i){
58
+ var step = s.step !== undefined ? s.step : i + 1;
59
+ last = Math.max(last, step);
60
+ return {s: s, i: i, step: step, at: s.at || 0};
61
+ });
62
+ var tr = d.trend === undefined || d.trend === null || d.trend === false ? [] : Array.isArray(d.trend) ? d.trend : [d.trend];
63
+ var trends = tr.map(function(t, i){
64
+ if (typeof t === "string") t = {fit: t}; // "linear" のほかは mount で知らせる(steps の計算では投げない)
65
+ return {t: t, i: i, step: t.step !== undefined ? t.step : last + 1, at: t.at || 0};
66
+ });
67
+ return (this._plan = {series: series, trends: trends});
68
+ }
69
+ mount(ctx){
70
+ var P = this.props, D = base, self = this, pl = this.plan();
71
+ this.variant = base.variant(this);
72
+ this.classList.add("plot"); this.style.display = "block";
73
+ // 字の幅(base の textWidth:テーマの字で測った幅。mtext の *_^ は数えない)
74
+ var est = function(s, size){ return D.textWidth(s, size, {font: self, mark: true}); };
75
+ var colorOf = function(c, i){
76
+ if (!c) return "var(--series-" + (i % 4 + 1) + ")";
77
+ return /^(term|emph|muted|accent2|fg|series-[1-4])$/.test(c) ? "var(--" + c + ")" : "var(--series-" + (i % 4 + 1) + ")";
78
+ };
79
+ // 点を {x, y, label, anchor, tone} にそろえる
80
+ var all = [];
81
+ pl.series.forEach(function(o){
82
+ o.pts = (o.s.points || []).map(function(q){ var p = Array.isArray(q) ? {x: +q[0], y: +q[1]} : {x: +q.x, y: +q.y, label: q.label, anchor: q.anchor, tone: q.tone}; all.push(p); return p; });
83
+ });
84
+ // 軸の範囲と目盛り:書かれていなければデータから切りのよい数に
85
+ var auto = function(vals, pad){
86
+ var lo = Math.min.apply(null, vals), hi = Math.max.apply(null, vals);
87
+ if (!isFinite(lo)) return [0, 1];
88
+ if (hi === lo){ hi += 1; lo -= 1; }
89
+ var st = tickStep((hi - lo) * (1 + 2 * pad)), a = Math.floor((lo - (hi - lo) * pad) / st) * st, b = Math.ceil((hi + (hi - lo) * pad) / st) * st;
90
+ if (lo >= 0 && a < 0) a = 0;
91
+ return [+a.toFixed(10), +b.toFixed(10)];
92
+ };
93
+ // 書かれた範囲は [小, 大] の 2 つの数のときだけ使う(1 つの数・逆向き・数でない、は知らせてデータから決める)
94
+ var range = function(name){
95
+ var v = P[name];
96
+ if (v === null || v === undefined) return null;
97
+ if (Array.isArray(v) && v.length === 2 && v.every(function(x){ return typeof x === "number" && isFinite(x); }) && v[0] < v[1]) return v;
98
+ ctx.report("attr", "[scatter] " + name + "=\"" + self.getAttribute(name) + "\" is not a range [low, high] of two numbers with low < high (the range is taken from the data)");
99
+ return null;
100
+ };
101
+ var xr = range("xr") || auto(all.map(function(p){ return p.x; }), 0.04), yr = range("yr") || auto(all.map(function(p){ return p.y; }), 0.06);
102
+ // 範囲の外の点は描かない(軸の外や枠の外に出さない)。系列ごとにまとめて知らせる
103
+ pl.series.forEach(function(o){
104
+ var outs = o.pts.filter(function(q){ return !(q.x >= xr[0] && q.x <= xr[1] && q.y >= yr[0] && q.y <= yr[1]); });
105
+ outs.forEach(function(q){ q.out = true; });
106
+ if (outs.length) ctx.report("data", "[scatter] " + outs.length + " point" + (outs.length > 1 ? "s" : "") + (o.s.label ? " of \"" + o.s.label + "\"" : " of series " + (o.i + 1)) + " lie outside xr/yr and are not drawn: " +
107
+ outs.slice(0, 3).map(function(q){ return "(" + q.x + ", " + q.y + ")"; }).join(", ") + (outs.length > 3 ? ", …" : "") + " (widen xr/yr or leave them out)");
108
+ });
109
+ var ticks = function(r){ var st = tickStep(r[1] - r[0]), out = []; for (var v = Math.ceil(r[0] / st - 1e-9) * st; v <= r[1] + st * 1e-6; v += st) out.push(+v.toFixed(10)); return out; };
110
+ var xt = P.xt || ticks(xr), yt = P.yt || ticks(yr);
111
+ var fmt = function(v, f){ return f !== undefined ? v.toFixed(f) : String(v); };
112
+ var named = pl.series.some(function(o){ return o.s.label; }) || pl.trends.some(function(o){ return o.t.label; });
113
+ var yw = Math.max.apply(null, yt.map(function(v){ return est(fmt(v, P.yf), 24); }).concat([0]));
114
+ var m = {l: Math.max(64, yw + 22 + (P.yl ? 40 : 0)), r: 24, t: named ? 72 : 20, b: P.xl ? 66 : 42};
115
+ var p = this.p = plot.Plot(this, {xr: xr, yr: yr, xt: xt, yt: yt, xf: P.xf, yf: P.yf, xl: P.xl, yl: P.yl, m: m});
116
+ p.svg.setAttribute("aria-hidden", "true");
117
+ // 軸の線(横軸と縦軸。目盛りの短い線は除く)に印を付ける(tools/test-components.mjs が字との交差を見る)
118
+ var axl = p.svg.querySelectorAll("g.axes > line");
119
+ for (var a = 0; a < Math.min(2, axl.length); a++) axl[a].setAttribute("class", "axis");
120
+ var W = p.W, H = p.H, x0 = m.l, x1 = W - m.r, y0 = m.t, y1 = H - m.b;
121
+ var gT = D.el("g", {}, p.svg), gP = D.el("g", {}, p.svg), gL = D.el("g", {}, p.svg);
122
+ var R = P.r;
123
+ if (!(typeof R === "number" && isFinite(R) && R > 0)){
124
+ ctx.report("attr", "[scatter] r=\"" + this.getAttribute("r") + "\" is not a positive number (the default radius 9 is used)");
125
+ R = 9;
126
+ }
127
+ // 系列の印の形:丸・四角・三角・ひし形(色だけに頼らない)
128
+ var shapes = [
129
+ function(r){ return "M" + r + ",0A" + r + "," + r + " 0 1,1 " + (-r) + ",0A" + r + "," + r + " 0 1,1 " + r + ",0Z"; },
130
+ function(r){ var s = r * 0.86; return "M" + (-s) + "," + (-s) + "H" + s + "V" + s + "H" + (-s) + "Z"; },
131
+ function(r){ var s = r * 1.2; return "M0," + (-s) + "L" + (s * 0.95).toFixed(2) + "," + (s * 0.62).toFixed(2) + "H" + (-s * 0.95).toFixed(2) + "Z"; },
132
+ function(r){ var s = r * 1.2; return "M0," + (-s) + "L" + s + ",0L0," + s + "L" + (-s) + ",0Z"; }];
133
+ // 置いた字と点の箱(重なりを避ける)
134
+ var boxes = [];
135
+ all.forEach(function(q){ if (!q.out) boxes.push({l: p.x(q.x) - R - 2, r: p.x(q.x) + R + 2, t: p.y(q.y) - R - 2, b: p.y(q.y) + R + 2, pt: q}); });
136
+ var hits = function(b, self2){ return boxes.some(function(o){ return o.pt !== self2 && b.l < o.r && o.l < b.r && b.t < o.b && o.t < b.b; }); };
137
+ this.series = pl.series.map(function(o){
138
+ var col = colorOf(o.s.tone, o.i), path = shapes[o.i % 4](R);
139
+ // marks for the geometry check (spec §8.4): each point is a mark, its name a label outside it; a trend line is an edge
140
+ var marks = o.pts.filter(function(q){ return !q.out; }).map(function(q, j){
141
+ var g = D.el("g", {"data-part": "mark", "data-part-id": "@s" + (o.i + 1) + "p" + (j + 1), transform: "translate(" + p.x(q.x).toFixed(1) + " " + p.y(q.y).toFixed(1) + ")", opacity: 0}, gP);
142
+ var c = q.tone ? colorOf(q.tone, o.i) : col;
143
+ var sh = D.el("path", {d: path, fill: c, "fill-opacity": 0.85, stroke: "var(--bg)", "stroke-width": 1.5}, g);
144
+ return {q: q, g: g, sh: sh, cx: p.x(q.x), cy: p.y(q.y)};
145
+ });
146
+ // 左から右の順(sweep)
147
+ var order = marks.slice().sort(function(u, v){ return u.cx - v.cx; });
148
+ order.forEach(function(mk, j){ mk.rank = order.length > 1 ? j / (order.length - 1) : 0; });
149
+ // 名前のある点:右 → 左 → 上 → 下(anchor があればそれを先に)の順に、点・字・軸と重ならず枠に収まる所へ
150
+ var labels = marks.filter(function(mk){ return mk.q.label; }).map(function(mk){
151
+ var w = est(mk.q.label, 24), cands = {
152
+ right: {x: mk.cx + R + 8, y: mk.cy + 8, a: "start", b: {l: mk.cx + R + 6, r: mk.cx + R + 10 + w, t: mk.cy - 14, b: mk.cy + 12}},
153
+ left: {x: mk.cx - R - 8, y: mk.cy + 8, a: "end", b: {l: mk.cx - R - 10 - w, r: mk.cx - R - 6, t: mk.cy - 14, b: mk.cy + 12}},
154
+ above: {x: mk.cx, y: mk.cy - R - 10, a: "middle", b: {l: mk.cx - w / 2 - 2, r: mk.cx + w / 2 + 2, t: mk.cy - R - 34, b: mk.cy - R - 4}},
155
+ below: {x: mk.cx, y: mk.cy + R + 28, a: "middle", b: {l: mk.cx - w / 2 - 2, r: mk.cx + w / 2 + 2, t: mk.cy + R + 4, b: mk.cy + R + 34}}};
156
+ var pref = ["right", "left", "above", "below"];
157
+ var an = {top: "above", bottom: "below"}[mk.q.anchor] || mk.q.anchor; // top / bottom は above / below の別名
158
+ if (an) pref = [an].concat(pref.filter(function(x){ return x !== an; }));
159
+ var inPlot = function(b){ return b.l >= x0 + 4 && b.r <= x1 && b.t >= y0 && b.b <= y1 - 4; };
160
+ var inBox = function(b){ return b.l >= 0 && b.r <= W && b.t >= 0 && b.b <= H; };
161
+ var pick = pref.filter(function(k){ return inPlot(cands[k].b) && !hits(cands[k].b, mk.q); })[0]
162
+ || pref.filter(function(k){ return inBox(cands[k].b) && !hits(cands[k].b, mk.q); })[0];
163
+ if (!pick){ pick = pref.filter(function(k){ return inBox(cands[k].b); })[0] || pref[0]; ctx.report("layout", "[scatter] the label \"" + mk.q.label + "\" has no free place (it may overlap)"); }
164
+ var c = cands[pick];
165
+ boxes.push({l: c.b.l, r: c.b.r, t: c.b.t, b: c.b.b, pt: mk.q});
166
+ return D.mtext(gL, c.x, c.y, mk.q.label, {"data-part": "label", "data-part-id": mk.g.getAttribute("data-part-id"), "data-part-of": "mark", "data-part-at": "outside", "text-anchor": c.a, "font-size": 24, fill: mk.q.tone ? colorOf(mk.q.tone, o.i) : "var(--fg)", opacity: 0});
167
+ });
168
+ return {o: o, col: col, path: path, marks: marks, labels: labels};
169
+ });
170
+ // 傾向の線:最小二乗の直線(fit: "linear")か、2 点(pts)
171
+ this.trends = pl.trends.map(function(o, ti){
172
+ var t = o.t, a, b, r = null, xa, xb;
173
+ var ya, yb;
174
+ if (t.pts){
175
+ if (t.pts.length !== 2 || !t.pts.every(function(q){ return Array.isArray(q) && q.length === 2 && q.every(isFinite); }))
176
+ throw new Error("trend.pts: write two points [[x0, y0], [x1, y1]]");
177
+ xa = +t.pts[0][0]; xb = +t.pts[1][0]; ya = +t.pts[0][1]; yb = +t.pts[1][1];
178
+ if (xa === xb && ya === yb) throw new Error("trend.pts: the two points are the same (write two different points)");
179
+ // 書いた 2 点をそのまま端にする(縦の線なら傾きと切片はない)
180
+ if (xb !== xa){ a = (yb - ya) / (xb - xa); b = ya - a * xa; } else { a = null; b = null; }
181
+ } else {
182
+ if (t.fit !== undefined && t.fit !== "linear") throw new Error('trend: "' + t.fit + '" is not "linear" (write "linear", {"fit": "linear"} or {"pts": [[x0, y0], [x1, y1]]})');
183
+ var use = t.series === undefined ? pl.series : [].concat(t.series).map(function(i){ return pl.series[i]; }).filter(Boolean);
184
+ var q = [].concat.apply([], use.map(function(s){ return s.pts; }));
185
+ if (q.length < 2) throw new Error("trend: a linear fit needs two or more points");
186
+ var n = q.length, sx = 0, sy = 0;
187
+ q.forEach(function(v){ sx += v.x; sy += v.y; });
188
+ var mx = sx / n, my = sy / n, sxx = 0, sxy = 0, syy = 0;
189
+ q.forEach(function(v){ sxx += (v.x - mx) * (v.x - mx); sxy += (v.x - mx) * (v.y - my); syy += (v.y - my) * (v.y - my); });
190
+ a = sxx ? sxy / sxx : 0; b = my - a * mx;
191
+ r = sxx && syy ? sxy / Math.sqrt(sxx * syy) : 0;
192
+ xa = Math.min.apply(null, q.map(function(v){ return v.x; })); xb = Math.max.apply(null, q.map(function(v){ return v.x; }));
193
+ ya = a * xa + b; yb = a * xb + b;
194
+ }
195
+ var col = t.tone ? colorOf(t.tone, 0) : "var(--fg)";
196
+ var A = [p.x(xa), p.y(ya)], B = [p.x(xb), p.y(yb)], out = false;
197
+ // 図の枠の中に切る(Liang–Barsky。clip-path は使わない)
198
+ var u0 = 0, u1 = 1, dx = B[0] - A[0], dy = B[1] - A[1];
199
+ [[-dx, A[0] - x0], [dx, x1 - A[0]], [-dy, A[1] - y0], [dy, y1 - A[1]]].forEach(function(c){
200
+ if (c[0] === 0){ if (c[1] < 0) u1 = -1; return; }
201
+ var u = c[1] / c[0];
202
+ if (c[0] < 0) u0 = Math.max(u0, u); else u1 = Math.min(u1, u);
203
+ });
204
+ // 枠の外の線は描かない(名前も図の上に出さない)
205
+ if (u1 <= u0){ out = true; ctx.report("range", "[scatter] the trend line is outside the axes (it is not drawn)"); }
206
+ else { B = [A[0] + dx * u1, A[1] + dy * u1]; A = [A[0] + dx * u0, A[1] + dy * u0]; }
207
+ var line = D.el("path", {"data-part-line": "", d: "M0,0", fill: "none", stroke: col, "stroke-width": 3.5, "stroke-linecap": "round", opacity: 0},
208
+ D.el("g", {"data-part": "edge", "data-part-id": "trend" + (ti + 1), "data-part-from": "@trend", "data-part-to": "@trend"}, gT));
209
+ if (t.dash) line.setAttribute("stroke-dasharray", "12 9");
210
+ // 名前:{r} {a} {b} を相関係数・傾き・切片に置き換える(digits 桁、既定 2)
211
+ var dg = t.digits !== undefined ? t.digits : 2, num = function(v){ return v === null ? "" : (v < 0 ? "−" : "") + Math.abs(v).toFixed(dg); };
212
+ var text = String(t.label || "").replace(/\{r\}/g, num(r)).replace(/\{a\}/g, num(a)).replace(/\{b\}/g, num(b));
213
+ var len = Math.hypot(B[0] - A[0], B[1] - A[1]);
214
+ return {o: o, line: line, text: out ? "" : text, col: col, A: A, B: B, len: len, dash: !!t.dash, out: out, a: a};
215
+ });
216
+ // 系列と傾向の線の名前:図の上(右寄せ)に印と一緒に並べる(凡例の箱は作らない。点や線と重ならない)
217
+ var lx = x1, entries = this.series.filter(function(se){ return se.o.s.label; }).map(function(se){ return {it: se, text: se.o.s.label, col: se.col, path: se.path}; })
218
+ .concat(this.trends.filter(function(tr){ return tr.text; }).map(function(tr){ return {it: tr, text: tr.text, col: tr.col, line: true, dash: tr.dash}; }));
219
+ // 印を左、字をその右に置く(字の幅は見積もりなので、ずれは右端に出る)
220
+ entries.reverse().forEach(function(en){
221
+ var w = est(en.text, 24), sw = en.line ? 40 : 2 * R, sx = lx - w - 10 - sw;
222
+ var g = D.el("g", {opacity: 0}, gL);
223
+ if (en.line){
224
+ var ln = D.el("line", {x1: sx, x2: sx + sw, y1: 26, y2: 26, stroke: en.col, "stroke-width": 3.5, "stroke-linecap": "round"}, g);
225
+ if (en.dash) ln.setAttribute("stroke-dasharray", "10 7");
226
+ } else D.el("path", {d: en.path, fill: en.col, "fill-opacity": 0.85, transform: "translate(" + (sx + R).toFixed(1) + " 26)"}, g);
227
+ D.mtext(g, sx + sw + 10, 34, en.text, {"font-size": 24, "font-weight": 700, fill: en.col});
228
+ en.it.leg = g;
229
+ lx = sx - 32;
230
+ });
231
+ if (lx + 32 < 0) ctx.report("size", "[scatter] the names above the figure are wider than the figure");
232
+ // 読み上げ:最後の形(描いた点と傾向の線)を 1 文で。作者の aria-label があればそれを使う(上書きしない)
233
+ if (this._aria === undefined) this._aria = this.getAttribute("aria-label");
234
+ this.setAttribute("role", "img");
235
+ if (!this._aria) this.setAttribute("aria-label", this.summary(/^ja\b/i.test(ctx.lang || "ja")));
236
+ function tickStep(span){ var r = span / 5, e = Math.pow(10, Math.floor(Math.log10(r))), x = r / e;
237
+ return (x <= 1 ? 1 : x <= 2 ? 2 : x <= 2.5 ? 2.5 : x <= 5 ? 5 : 10) * e; }
238
+ }
239
+ // 最後の形を 1 文で(読み上げの名前):「散布図(横:最高気温、縦:売上):12 点(晴れ 8 点、雨 4 点)、横 24〜34、縦 210〜690、
240
+ // 猛暑日 (34, 690)、傾向の線は右上がり(r = 0.93)」。範囲の外で描かない点は数えない
241
+ summary(ja){
242
+ var P = this.props, self = this, one = function(s){ return String(s || "").replace(/\s*\n\s*/g, " ").replace(/[*_^]/g, ""); };
243
+ var ax = [P.xl ? (ja ? "横:" : "x: ") + one(P.xl) : "", P.yl ? (ja ? "縦:" : "y: ") + one(P.yl) : ""].filter(Boolean).join(ja ? "、" : ", ");
244
+ var pts = [], ss = this.series.map(function(se){ se.marks.forEach(function(mk){ pts.push(mk.q); }); return {l: se.o.s.label, n: se.marks.length}; });
245
+ var cnt = function(n){ return ja ? n + " 点" : n + (n === 1 ? " point" : " points"); };
246
+ var out = [cnt(pts.length) + (ss.length > 1 && ss.some(function(x){ return x.l; }) ? (ja ? "(" : " (") + ss.map(function(x){ return (x.l ? one(x.l) + " " : "") + cnt(x.n); }).join(ja ? "、" : ", ") + (ja ? ")" : ")") : "")];
247
+ if (pts.length){
248
+ var mm = function(f){ var v = pts.map(f), lo = Math.min.apply(null, v), hi = Math.max.apply(null, v); return lo === hi ? String(lo) : lo + (ja ? "〜" : " to ") + hi; };
249
+ out.push((ja ? "横 " : "x ") + mm(function(q){ return q.x; }), (ja ? "縦 " : "y ") + mm(function(q){ return q.y; }));
250
+ }
251
+ pts.filter(function(q){ return q.label; }).slice(0, 6).forEach(function(q){ out.push(one(q.label) + " (" + q.x + ", " + q.y + ")"); });
252
+ this.trends.forEach(function(tr){
253
+ if (tr.out) return;
254
+ var dir = tr.a === null ? (ja ? "垂直" : "vertical") : tr.a > 0 ? (ja ? "右上がり" : "rising") : tr.a < 0 ? (ja ? "右下がり" : "falling") : (ja ? "水平" : "flat");
255
+ var ts = tr.o.t.series, sn = !tr.o.t.pts && ts !== undefined && [].concat(ts).length === 1 && self.series[[].concat(ts)[0]] ? self.series[[].concat(ts)[0]].o.s.label : "";
256
+ out.push((sn ? one(sn) + (ja ? "の" : ": ") : "") + (ja ? "傾向の線は" : "the trend line is ") + dir + (tr.text ? (ja ? "(" : " (") + one(tr.text) + (ja ? ")" : ")") : ""));
257
+ });
258
+ return (ja ? "散布図" : "Scatter plot") + (ax ? (ja ? "(" + ax + ")" : " (" + ax + ")") : "") + (ja ? ":" : ": ") + out.join(ja ? "、" : ", ");
259
+ }
260
+ duration(k){
261
+ var P = this.props, d = 0, pl = this.plan();
262
+ pl.series.forEach(function(o){ if (o.step === k) d = Math.max(d, o.at + P.dur); });
263
+ pl.trends.forEach(function(o){ if (o.step === k) d = Math.max(d, o.at + P.dur); });
264
+ return d;
265
+ }
266
+ cues(k){
267
+ var c = [], pl = this.plan();
268
+ pl.series.concat(pl.trends).forEach(function(o){ if (o.step === k && o.at > 0 && c.indexOf(o.at) < 0) c.push(o.at); });
269
+ return c.length ? c.sort(function(a, b){ return a - b; }) : null;
270
+ }
271
+ render(k, t, ctx){
272
+ var P = this.props, D = base, vr = this.variant, dur = P.dur, lecture = !!ctx.preview, FAINT = 0.45;
273
+ if (lecture) FAINT = base.previewOpacity(this); // 先の段階の薄さ:テーマの --preview-opacity(ないときは 0.45)
274
+ // この部品の段階の中の時刻(-1 = まだ。授業の表示では先の段階を薄く見せる)
275
+ var local = function(o){ return o.step < k ? Infinity : o.step > k ? -1 : t - o.at; };
276
+ var faint = function(o){ return lecture && o.step > k; };
277
+ this.series.forEach(function(se){
278
+ var o = se.o, tt = local(o), f = faint(o), span = dur * 0.7;
279
+ se.marks.forEach(function(mk){
280
+ var op, sc = 1;
281
+ if (f){ op = FAINT; }
282
+ else if (tt < 0){ op = 0; }
283
+ else if (vr === "sweep"){ op = D.prog(tt, mk.rank * (span - 0.2), 0.2); }
284
+ else if (vr === "grow"){ sc = D.prog(tt, 0, span); op = sc > 0 ? Math.min(1, sc * 3) : 0; }
285
+ else { op = D.prog(tt, 0, span); }
286
+ mk.g.setAttribute("opacity", op.toFixed(3));
287
+ mk.g.setAttribute("transform", "translate(" + mk.cx.toFixed(1) + " " + mk.cy.toFixed(1) + ")" + (sc < 1 ? " scale(" + Math.max(0.001, sc).toFixed(4) + ")" : ""));
288
+ });
289
+ var lo = f ? FAINT : tt < 0 ? 0 : D.prog(tt, dur * 0.6, dur * 0.4);
290
+ se.labels.forEach(function(l){ l.setAttribute("opacity", lo.toFixed(3)); });
291
+ if (se.leg) se.leg.setAttribute("opacity", (f ? FAINT : tt < 0 ? 0 : D.prog(tt, 0, dur * 0.5)).toFixed(3));
292
+ });
293
+ this.trends.forEach(function(tr){
294
+ var o = tr.o, tt = local(o), f = faint(o), span = dur * 0.7, A = tr.A, B = tr.B, e = f ? 1 : tt < 0 ? 0 : D.prog(tt, 0, span);
295
+ var s0 = 0, s1 = 1, op = e > 0 ? 1 : 0;
296
+ if (!f && vr === "sweep"){ s1 = e; }
297
+ else if (!f && vr === "grow"){ s0 = 0.5 - e / 2; s1 = 0.5 + e / 2; }
298
+ else op = e;
299
+ tr.line.setAttribute("d", "M" + D.lerp(A[0], B[0], s0).toFixed(1) + "," + D.lerp(A[1], B[1], s0).toFixed(1) + "L" + D.lerp(A[0], B[0], s1).toFixed(1) + "," + D.lerp(A[1], B[1], s1).toFixed(1));
300
+ if (tr.dash) tr.line.setAttribute("stroke-dashoffset", (s0 * tr.len).toFixed(1));
301
+ tr.line.setAttribute("opacity", (tr.out ? 0 : f ? FAINT : op).toFixed(3));
302
+ if (tr.leg) tr.leg.setAttribute("opacity", (f ? FAINT : tt < 0 ? 0 : D.prog(tt, span, dur * 0.3)).toFixed(3));
303
+ });
304
+ }
305
+ };
306
+ });
@@ -0,0 +1,54 @@
1
+ ---
2
+ summary: Bars grow from 0 by step (vertical, horizontal, grouped, stacked); the axis max can widen by step
3
+ steps: max group/scale step (default 1 group = 1 step)
4
+ props:
5
+ orient: v or h
6
+ max: axis max (0 = auto)
7
+ unit: value unit
8
+ digits: decimals
9
+ per-step: groups per step (0 = all)
10
+ dur: grow seconds
11
+ stagger: group offset (s)
12
+ count: count values up
13
+ ticks: ticks and grid
14
+ zoom: scale-change seconds
15
+ al: axis title
16
+ stack: stack values; "percent" = 100 %
17
+ mark: bar or dot (a point with its error bar)
18
+ example: {"series": [{"label": "Sales"}], "groups": [{"label": "Year 1", "value": 1.2}, {"label": "Year 2", "value": 3.4}]}
19
+ ---
20
+
21
+ For quantities shown and compared one at a time: yearly sales, ranked answers, before/after.
22
+
23
+ Child JSON: `{"series": [...], "groups": [...], "scale": [...], "sig": [...]}`.
24
+
25
+ - group: `label` (`\n` = 2 lines), `value` or `values` (one per series), `step`, `at` (start s), `tone` (bar and value colour)
26
+ - err: ± number or `[low, high]`; per series for `values`
27
+ - sig: `[{"from": 0, "to": 2, "label": "**"}]` brackets groups 0 and 2 (`group`: series in a group); vertical, unstacked only
28
+ <!-- llm: omit -->
29
+ - Error bars and values appear once a bar is grown; values sit beyond the error bar's end. `mark="dot"` points appear without growing. Brackets stack from the shortest
30
+ <!-- llm: end -->
31
+ - series: `label` (2+ series: on the first group's bars; no legend), `tone` (default `--series-1..4`)
32
+ - scale: `[{"step": 3, "max": 27, "at": 0.4}]`: the max moves to `max` over `zoom` s; the old range stays as a faint band; taller bars stop at the top and grow as it widens
33
+ <!-- llm: omit -->
34
+ - Auto max: 1.12 × the largest value (before the first scale), rounded
35
+ <!-- llm: end -->
36
+ - `orient="h"`: names left, values right; `ticks="false"` for ranks
37
+ - `stack="true"` (`"percent"` = 100 %): a group's `values` in one bar; total at the end, values inside segments; values ≥ 0
38
+ <!-- llm: omit -->
39
+ - Values: `digits` decimals, thousands separators, `unit` appended
40
+ - Negatives (not stacked): the axis includes 0; bars grow down/left from a `--fg` baseline; values outside the bar end
41
+ - `stack="percent"`: axis 0–100 %, no `max`/`scale`, segment values in % when they fit, no total
42
+ - Show later steps faintly (`ctx.preview`): later bars fully grown at `--preview-opacity`; no axis change or over-max bar shown ahead
43
+ <!-- llm: end -->
44
+
45
+ The demo is `demo.html`. All numbers are fictional.
46
+
47
+ Notes
48
+
49
+ - Values appear once a bar is fully grown; `count="true"` counts them up
50
+ - Series names sit on the first group's bars: keep to 2–3 series
51
+
52
+ <!-- llm: omit -->
53
+ - `examples/tmlr2026-calibration` keeps its own deck-local `components/bars/`
54
+ <!-- llm: end -->