egatari 0.6.10 → 0.6.11-rc.1
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.
- package/README.ja.md +22 -22
- package/README.md +1 -1
- package/bin/egatari.mjs +1 -1
- package/components.lock.json +288 -144
- package/components2.lock.json +657 -1
- package/kit/build.mjs +3 -2
- package/kit/check-messages.mjs +46 -12
- package/kit/check.mjs +54 -19
- package/kit/core/article-messages.mjs +5 -4
- package/kit/core/attachments.mjs +2 -1
- package/kit/core/build-core.mjs +2 -1
- package/kit/core/check-parity.mjs +3 -1
- package/kit/core/check-result.mjs +2 -1
- package/kit/core/check-rules.mjs +132 -0
- package/kit/core/colab-core.mjs +2 -2
- package/kit/core/geometry-check.mjs +302 -0
- package/kit/core/layout-scan.mjs +9 -2
- package/kit/core/live-results.mjs +1 -1
- package/kit/core/llm-fix.mjs +3 -2
- package/kit/core/llm-outline.mjs +3 -2
- package/kit/core/llm-pack-data.mjs +114 -114
- package/kit/core/narration-lint.mjs +37 -0
- package/kit/core/new-deck-pack.mjs +2 -1
- package/kit/core/new-deck.mjs +1 -1
- package/kit/core/plural.mjs +5 -0
- package/kit/core/portable.mjs +6 -5
- package/kit/core/sample-layout.mjs +14 -0
- package/kit/core/text-band.mjs +37 -0
- package/kit/core/tier-a.mjs +2 -1
- package/kit/instruction-version.json +1 -1
- package/kit/player.json +1 -1
- package/kit/player.lock.json +2 -2
- package/kit/render-compare.mjs +5 -4
- package/kit/tools.js +2 -2
- package/package.json +3 -2
- package/server/editor-ui.js +2 -2
- package/vendor/components/CATALOG.md +12 -12
- package/vendor/components/sha256/00d9072cb279a1a68166787f53395c747072388971d916c082a106844dbf888f/index.js +315 -0
- package/vendor/components/sha256/03e20fb6803de0d94e93de7c01d7d00cede57b0b2604b449daa4cb156367500d/README.en.md +23 -0
- package/vendor/components/sha256/03e20fb6803de0d94e93de7c01d7d00cede57b0b2604b449daa4cb156367500d/index.js +289 -0
- package/vendor/components/sha256/0e5458deb63e32aefdbf8722fa156fd44cd90d5d8f9d6a25a636007b4b599450/README.en.md +40 -0
- package/vendor/components/sha256/0e5458deb63e32aefdbf8722fa156fd44cd90d5d8f9d6a25a636007b4b599450/index.js +341 -0
- package/vendor/components/sha256/1073e03374f0fe65d2691f160bfd8c092986c168d0bd6a6094ebd444d4b89c27/index.js +592 -0
- package/vendor/components/sha256/12b1b32eb3a75e9f11eff407b7876473674ae996d7ce276e2ab6ffaf41ad4376/README.en.md +48 -0
- package/vendor/components/sha256/12b1b32eb3a75e9f11eff407b7876473674ae996d7ce276e2ab6ffaf41ad4376/index.js +384 -0
- package/vendor/components/sha256/147987bd84722249dab609293d4fafa93f0a2aac25b8517fda1710840b575d00/index.js +341 -0
- package/vendor/components/sha256/170e9072285213a2b4e79d7c2e4ddb882d1501e60b5da63c59b1679643163005/README.en.md +23 -0
- package/vendor/components/sha256/170e9072285213a2b4e79d7c2e4ddb882d1501e60b5da63c59b1679643163005/index.js +120 -0
- package/vendor/components/sha256/17da8ef5ce58354df54ebb52c8a9b0726e69d06ac28cc8e78f807ec338002782/README.en.md +32 -0
- package/vendor/components/sha256/17da8ef5ce58354df54ebb52c8a9b0726e69d06ac28cc8e78f807ec338002782/index.js +222 -0
- package/vendor/components/sha256/1b30dfd9b366ff07556024eb8ce75cca2eac8001fa392eed4e1232047001ec74/index.js +404 -0
- package/vendor/components/sha256/37846655693f8dd869d11d3d4cddb43be57f848037d0e49564b2250401448ab5/README.en.md +66 -0
- package/vendor/components/sha256/37846655693f8dd869d11d3d4cddb43be57f848037d0e49564b2250401448ab5/index.js +920 -0
- package/vendor/components/sha256/3fdd15756f779a16362dd854f143ca4343154059882d88d44adf64745c7876e3/README.en.md +50 -0
- package/vendor/components/sha256/3fdd15756f779a16362dd854f143ca4343154059882d88d44adf64745c7876e3/index.js +171 -0
- package/vendor/components/sha256/435c3f8e0c0abc123866e57ae2c7f3409e19d14a2eb67b1fde84c4da5d95f14c/README.en.md +31 -0
- package/vendor/components/sha256/435c3f8e0c0abc123866e57ae2c7f3409e19d14a2eb67b1fde84c4da5d95f14c/index.js +232 -0
- package/vendor/components/sha256/43740da51de85c1b7ec1eaf688f93fd9ea25b15977ab075e6abac196f08643a6/index.js +122 -0
- package/vendor/components/sha256/4817f77bd021ec5c77d5a15ee56e2e34d31d1d98630e86225eb20f2f9bf095e9/index.js +812 -0
- package/vendor/components/sha256/4e4bf3b2968c36a334dc997e32e36f22ecbc4f5dfe1c76bb7a5beef002fe8899/index.js +228 -0
- package/vendor/components/sha256/553e132d1f84caad648bb7175a206d4c5d18c005b5ca17989f5e8a5e3f5cdfa1/index.js +75 -0
- package/vendor/components/sha256/5b02d8a81a41f4d1658f1972f3fc91de3cc431b2c71bb6b92601d58f734de9ec/README.en.md +34 -0
- package/vendor/components/sha256/5b02d8a81a41f4d1658f1972f3fc91de3cc431b2c71bb6b92601d58f734de9ec/index.js +244 -0
- package/vendor/components/sha256/5c72414df5a948a7cbb882be1e5bdd4113d188e357d4a0f01fabda15781417eb/LICENSE-tabler.txt +21 -0
- package/vendor/components/sha256/5c72414df5a948a7cbb882be1e5bdd4113d188e357d4a0f01fabda15781417eb/index.js +4868 -0
- package/vendor/components/sha256/5c72414df5a948a7cbb882be1e5bdd4113d188e357d4a0f01fabda15781417eb/names.txt +4808 -0
- package/vendor/components/sha256/636f47e955f5550f046cfc7a3de8de70c4b97aa77771bde2ee0e31d706bb032e/index.js +278 -0
- package/vendor/components/sha256/65ddc34bd9c75e073f4c2cd283369417fe88769521809670c6b8730852d4f647/index.js +97 -0
- package/vendor/components/sha256/6b0c75b0f697fe451197301de82a113f1c2548b67f7a8d2b56576d2bae8e240c/index.js +607 -0
- package/vendor/components/sha256/6cdf432d3e61be3ff15e80910369324ac7ea0e8b9f62c32ef37bf09a5bfe93b9/README.en.md +33 -0
- package/vendor/components/sha256/6cdf432d3e61be3ff15e80910369324ac7ea0e8b9f62c32ef37bf09a5bfe93b9/index.js +390 -0
- package/vendor/components/sha256/6d648d0e5c96ec680c04a14b7c3d672010d3b9f101197689e9672ec00174383d/README.en.md +31 -0
- package/vendor/components/sha256/6d648d0e5c96ec680c04a14b7c3d672010d3b9f101197689e9672ec00174383d/index.js +267 -0
- package/vendor/components/sha256/71208afc5c8ea1ed6d2180f46de7385e43990cfb046ba350eefb917eca5d92fe/README.en.md +22 -0
- package/vendor/components/sha256/71208afc5c8ea1ed6d2180f46de7385e43990cfb046ba350eefb917eca5d92fe/index.js +145 -0
- package/vendor/components/sha256/7552a029f30f9c2f2ec8c5af4f144b63eeffc9172b53e35a925821f69a738b64/README.en.md +44 -0
- package/vendor/components/sha256/7552a029f30f9c2f2ec8c5af4f144b63eeffc9172b53e35a925821f69a738b64/index.js +203 -0
- package/vendor/components/sha256/781a45d97f1325cfb40aa98d00e1db9600949158fdb2749b0223b019c67a80f2/index.js +919 -0
- package/vendor/components/sha256/850944419734168be3dc202057de128131869c471cb8ab3baec2cfe789d56493/index.js +465 -0
- package/vendor/components/sha256/863d4d42075fbae1084089730f10da943c88d3e3e655235f28c24b9a3cf95c88/README.en.md +37 -0
- package/vendor/components/sha256/863d4d42075fbae1084089730f10da943c88d3e3e655235f28c24b9a3cf95c88/index.js +424 -0
- package/vendor/components/sha256/8a892d25d0bb6105ba31ea690b465876ce3af1fbaf18e2a9ce44ad2fee81260e/index.js +162 -0
- package/vendor/components/sha256/8acec8f299510287fbad6a69311ec58a39b0e99647dd03609c818e053b3b6087/index.js +484 -0
- package/vendor/components/sha256/8ef66bd1e800bcbedef436585469d308665aaa1ab6011aee699544302d0a8ad0/index.js +312 -0
- package/vendor/components/sha256/8fa5ed6ab12a27542e077ff965bea626ff9450b330609304dc1148fc8dbb68b0/README.en.md +40 -0
- package/vendor/components/sha256/8fa5ed6ab12a27542e077ff965bea626ff9450b330609304dc1148fc8dbb68b0/index.js +348 -0
- package/vendor/components/sha256/a0c71874d83045baaef70285bd00d87a7c6c43219fa5630dfff60d5cb08509be/index.js +250 -0
- package/vendor/components/sha256/a31f39625d7d1087d06a72b644cec417372f98add940288257ef07f812d8395a/index.js +747 -0
- package/vendor/components/sha256/ae04a57be4a26b7443796a93c58adcf1cbcf746120eba619bf9c2bcdce53c640/README.en.md +38 -0
- package/vendor/components/sha256/ae04a57be4a26b7443796a93c58adcf1cbcf746120eba619bf9c2bcdce53c640/index.js +289 -0
- package/vendor/components/sha256/ae06622a328da2a01260bc68b28bb632c391e8d62a4e8387638e5a944525a418/index.js +521 -0
- package/vendor/components/sha256/b490139e9afa84164054738532d5ec4985bf071e40791d903012fe3b850bae43/README.en.md +24 -0
- package/vendor/components/sha256/b490139e9afa84164054738532d5ec4985bf071e40791d903012fe3b850bae43/index.js +103 -0
- package/vendor/components/sha256/b756c66d5c6e6ace90912ab467dea3031f2c9b291d8b2a786ca660faa0e8ac84/index.js +121 -0
- package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/ABCJS-ADAPTER.md +101 -0
- package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/LICENSE-abcjs.txt +21 -0
- package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/chords.json +89 -0
- package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/doremi.json +261 -0
- package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/extras.json +192 -0
- package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/kaeru.json +521 -0
- package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/rhythm.json +248 -0
- package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/ties.json +360 -0
- package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/index.js +508 -0
- package/vendor/components/sha256/bea7cb344f55677d5756c9711b90cc971126830ec5f66a03f71f13dbfadc401e/index.js +351 -0
- package/vendor/components/sha256/c08b25a2f7be68c36634cdee180aa617fd018d80b7ddf2a484a2edb4acffdbe0/README.en.md +42 -0
- package/vendor/components/sha256/c08b25a2f7be68c36634cdee180aa617fd018d80b7ddf2a484a2edb4acffdbe0/index.js +268 -0
- package/vendor/components/sha256/cbe8bb4b2fd0845a9333bc2064d86758ea6465992ad86a99167ba17f57f3e382/README.en.md +51 -0
- package/vendor/components/sha256/cbe8bb4b2fd0845a9333bc2064d86758ea6465992ad86a99167ba17f57f3e382/index.js +228 -0
- package/vendor/components/sha256/d2df3d70fc7c6e07e3cad7332a7e5501e84abeb24653786e567f57046adebcba/index.js +268 -0
- package/vendor/components/sha256/d386f2b94cd9fbed765ad301aa7009228599edb2859efe7f37a98d7aaa44b9bb/README.en.md +35 -0
- package/vendor/components/sha256/d386f2b94cd9fbed765ad301aa7009228599edb2859efe7f37a98d7aaa44b9bb/index.js +179 -0
- package/vendor/components/sha256/e6d219f67d241fdf00a40d4cec261d9dd3c09ad3110d3418d4e843d0f2b8c196/index.js +429 -0
- package/vendor/components/sha256/ef60e6c089f5f6e909f439af8fc0c9c0a2d7a1aafad5e65be6328ba993b990a0/index.js +354 -0
- package/vendor/components/sha256/f6f47601c90f0195353e94b76d57499591d6330a7e35714958a2c41229f70da2/index.js +198 -0
- package/vendor/components/sha256/f9159c87fa998487787f738fdfab52aa2483f52f170fc258840b127f6ed06051/README.en.md +44 -0
- package/vendor/components/sha256/f9159c87fa998487787f738fdfab52aa2483f52f170fc258840b127f6ed06051/index.js +304 -0
- package/vendor/components/sha256/fb482cbe2ca1da07d08f41880e03fe75ff3f1d29842ff40946541e63030219b8/README.en.md +42 -0
- package/vendor/components/sha256/fb482cbe2ca1da07d08f41880e03fe75ff3f1d29842ff40946541e63030219b8/index.js +481 -0
- package/vendor/components/sha256/fdcea28e27638d8bfe234016672375e14de8bb97c32f7b6840d1b7b10ac4b1cd/index.js +233 -0
- package/vendor/components/sha256/ff5eaa083a46db6aefc13d97b27c9487f9fc318805f5c89b05a12e63703b7a72/LICENSE-strokesvg.txt +115 -0
- package/vendor/components/sha256/ff5eaa083a46db6aefc13d97b27c9487f9fc318805f5c89b05a12e63703b7a72/OFL.txt +93 -0
- package/vendor/components/sha256/ff5eaa083a46db6aefc13d97b27c9487f9fc318805f5c89b05a12e63703b7a72/index.js +749 -0
- package/vendor/components/sha256/ff5eaa083a46db6aefc13d97b27c9487f9fc318805f5c89b05a12e63703b7a72/strokes-CHANGES.md +20 -0
- package/vendor/components-2/manifest-2.7.0.json +2118 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// m-curves:同じ座標軸に線を 1 本ずつ引く。線の名前は凡例でなく線の端に直接書く
|
|
2
|
+
// <m-curves xr="[-3,3]" yr="[0,0.5]" xt="[-2,0,2]" yt="[0,0.2,0.4]" xl="*y*" yl="密度" style="height:380px">
|
|
3
|
+
// <script type="application/json">[{"label":"予測分布","f":"N(x,0,1)"},{"label":"中央値","pts":[[0,0],[0,0.4]],"dash":true}]
|
|
4
|
+
// (JSON の終わり)</m-curves>
|
|
5
|
+
// 1 系列 = 1 段階(書いた順。系列の step で変えられ、同じ step の系列は一緒に引く)。f は x の式(Math の関数と N(x,平均,標準偏差) が使える)、pts は点列
|
|
6
|
+
// 2.0(Egatari spec §6.1 の部品):base の MotionElement・el・mtext・prog・previewOpacity、plot の Plot、expr の compile を使い、
|
|
7
|
+
// プレイヤーのグローバルは使わない(1.x は式の評価器 egatari-expr を写して持っていた)。破線の mask の id は
|
|
8
|
+
// curves-2-2-1-<n>m<系列>:このパーツの名前と版に、このパーツだけの数え(1.x は mc<n>m<系列> で、DECK.Plot の数えを進めていた)
|
|
9
|
+
egatariParts.define({name: "curves", version: "2.2.1", requires: {base: "1.2.0", expr: "1.0.0", plot: "1.1.2"}, element: "m-curves"}, function(deps){
|
|
10
|
+
"use strict";
|
|
11
|
+
var base = deps.base, plot = deps.plot, expr = deps.expr;
|
|
12
|
+
var ID = "curves-2-2-1-"; // name and version of this part, dots replaced (spec §6.1 Identifiers)
|
|
13
|
+
var count = 0; // this part's own counter for its ids (deterministic: the order of mounting)
|
|
14
|
+
// 線の名前(26px)の下付き・上付きの分の高さ(px)。base 1.1.0 で mtext の下付き・上付きは 24px 以上になり、下付きの字の下端は基線から
|
|
15
|
+
// 添字の 0.75 倍まで、上付きの字の上端は 1.4 倍まで届く(Source Sans 3 で測った値。BIZ UDPGothic ではそれぞれ 0.5 倍と 1.2 倍)。
|
|
16
|
+
// 字の下の余白(字の 0.12 倍)・上の高さ(0.88 倍)を超える分。記法がなければ 0
|
|
17
|
+
function subX(s, fs){ var ss = Math.max(24, Math.round(fs * 0.75)); return /_./.test(s) ? Math.max(0, 0.75 * ss - 0.12 * fs) : 0; }
|
|
18
|
+
function supX(s, fs){ var ss = Math.max(24, Math.round(fs * 0.75)); return /\^./.test(s) ? Math.max(0, 1.4 * ss - 0.88 * fs) : 0; }
|
|
19
|
+
return class extends base.MotionElement {
|
|
20
|
+
static partName = "curves"; // the registry name (define meta name), for report prefixes
|
|
21
|
+
// データの形(kit/shape.js):線の配列。軸(xr yr xt yt xl yl)は属性に書く(JSON の中ではない)
|
|
22
|
+
static shape = {
|
|
23
|
+
schema: {type: "array", items: {type: "object", additionalProperties: false, anyOf: [{required: ["f"]}, {required: ["pts"]}],
|
|
24
|
+
properties: {label: {type: "string"}, f: {type: "string"}, pts: {type: "array", items: {type: "array", items: {type: "number"}, minItems: 2, maxItems: 2}},
|
|
25
|
+
tone: {type: "string"}, step: {type: "integer"}, labelAt: {type: "number"},
|
|
26
|
+
color: {type: "string"}, dash: {type: "boolean"}, xr: {type: "array", items: {type: "number"}, minItems: 2, maxItems: 2},
|
|
27
|
+
area: {type: "array"}, areaLabel: {type: ["string", "array"]},
|
|
28
|
+
at: {type: "number"}, anchor: {enum: ["right", "left", "above", "below", "top", "bottom", "start", "middle", "end"]}, dx: {type: "number"}, dy: {type: "number"}, ly: {type: "number"}}}},
|
|
29
|
+
example: [{label: "需要 D", f: "10 - x"}, {label: "供給 S", f: "2 + x"}, {label: "均衡", pts: [[4, 0], [4, 6]], dash: true}],
|
|
30
|
+
// よくある書き違い(指示の部品の一覧に書く)
|
|
31
|
+
note: {en: "the data is the array itself, not {\"series\": […]}; axes go in attributes (xr=\"[0,10]\" xl=\"…\"); the expression field is f in x (not fn, not u)",
|
|
32
|
+
ja: "データは配列そのもの({\"series\": […]} ではない)。軸は属性に書く(xr=\"[0,10]\" xl=\"…\")。式の欄は f で、変数は x(fn・u ではない)"},
|
|
33
|
+
};
|
|
34
|
+
static props = {
|
|
35
|
+
xr: {type: "json", default: [0, 1], doc: "横軸の範囲"}, yr: {type: "json", default: [0, 1], doc: "縦軸の範囲"},
|
|
36
|
+
xt: {type: "json", default: []}, yt: {type: "json", default: []},
|
|
37
|
+
xf: {type: "number", default: undefined, doc: "横軸の目盛りの小数桁"}, yf: {type: "number", default: undefined, doc: "縦軸の目盛りの小数桁"},
|
|
38
|
+
xl: {type: "string", default: ""}, yl: {type: "string", default: ""},
|
|
39
|
+
n: {type: "number", default: 300, doc: "f を描く分割数"},
|
|
40
|
+
dur: {type: "number", default: 1.0, doc: "1 本を引く秒数"},
|
|
41
|
+
lw: {type: "number", default: 3.5, doc: "線の太さ"},
|
|
42
|
+
size: {type: "number", default: 0, doc: "字の大きさ(24 以上。0 = 既定)"},
|
|
43
|
+
};
|
|
44
|
+
// 系列 i の段階:step(書いてあれば)、なければ i + 1。段階の数はその最大(step がなければ系列の数で、今までと同じ)
|
|
45
|
+
stepOf(s, i){ return s && s.step !== undefined ? s.step : i + 1; }
|
|
46
|
+
get steps(){
|
|
47
|
+
if (this.getAttribute("steps") !== null) return +this.getAttribute("steps");
|
|
48
|
+
var self = this, m = 0;
|
|
49
|
+
(this.data || []).forEach(function(s, i){ m = Math.max(m, self.stepOf(s, i)); });
|
|
50
|
+
return m;
|
|
51
|
+
}
|
|
52
|
+
mount(ctx){
|
|
53
|
+
var P = this.props, D = base, self = this, S = this.data || [];
|
|
54
|
+
this.classList.add("plot"); this.style.display = "block";
|
|
55
|
+
// size:字の大きさ(24 未満は 24 にして知らせる)。0 なら 2.0 と同じ大きさと余白
|
|
56
|
+
var SZ = P.size > 0 ? Math.max(24, P.size) : 0, K = SZ ? SZ / 26 : 1, F = SZ || 26;
|
|
57
|
+
if (P.size > 0 && P.size < 24) ctx.report("attr", "[curves] size " + P.size + " is under 24 px; 24 is used");
|
|
58
|
+
var p = this.p = plot.Plot(this, {xr: P.xr, yr: P.yr, xt: P.xt, yt: P.yt, xf: P.xf, yf: P.yf, xl: P.xl, yl: P.yl, fs: SZ || undefined, m: {l: Math.round(86 * K), r: 24, t: Math.round(24 * K), b: Math.round(64 * K)}});
|
|
59
|
+
var uid = ID + (++count), defs = D.el("defs", {}, p.svg);
|
|
60
|
+
var N = function(x, m, s){ return Math.exp(-0.5 * Math.pow((x - m) / s, 2)) / (s * Math.sqrt(2 * Math.PI)); };
|
|
61
|
+
var x0 = p.m.l, x1 = p.W - p.m.r, y0 = p.m.t, y1 = p.H - p.m.b;
|
|
62
|
+
// 系列ごとに:点列、線、(破線なら)描く範囲の mask、端の名前
|
|
63
|
+
this.items = S.map(function(s, i){
|
|
64
|
+
var pts;
|
|
65
|
+
if (s.pts) pts = s.pts.map(function(q){ return [p.x(q[0]), p.y(q[1])]; });
|
|
66
|
+
else {
|
|
67
|
+
// 式は木にしてから計算する(コードとしては実行しない。Egatari spec §6)。書けない式は SyntaxError で、base が受け止めて札を出す(spec §6.1 Containment)
|
|
68
|
+
var g = expr.compile(s.f, {name: "[" + i + "].f", vars: ["x"], funcs: {N: N}, bareMath: true}), a = s.xr ? s.xr[0] : P.xr[0], b = s.xr ? s.xr[1] : P.xr[1];
|
|
69
|
+
pts = [];
|
|
70
|
+
for (var j = 0; j <= P.n; j++){ var v = a + (b - a) * j / P.n; pts.push([p.x(v), p.y(g(v))]); }
|
|
71
|
+
}
|
|
72
|
+
// 有限でない点(NaN・±Infinity)は線を切り、有限な区間ごとに M から引き直す(1 つの NaN で線全体が消えない)
|
|
73
|
+
var d = "", pen = false, gap = false;
|
|
74
|
+
pts.forEach(function(q){
|
|
75
|
+
if (isFinite(q[0]) && isFinite(q[1])){ d += (pen ? "L" : "M") + q[0].toFixed(1) + "," + q[1].toFixed(1); pen = true; }
|
|
76
|
+
else { pen = false; gap = true; }
|
|
77
|
+
});
|
|
78
|
+
if (gap) ctx.report("data", "[curves] series " + i + " (" + JSON.stringify(s.label || "") + ") has points that are not finite numbers (NaN or ±Infinity, e.g. log or division by zero); the line is broken there");
|
|
79
|
+
pts = pts.filter(function(q){ return isFinite(q[0]) && isFinite(q[1]); });
|
|
80
|
+
var col = colorOf(s.tone || s.color, i);
|
|
81
|
+
var it = {step: self.stepOf(s, i)};
|
|
82
|
+
if (s.dash){
|
|
83
|
+
// 破線は dasharray を描画に使えないので、同じ線を mask にして引く
|
|
84
|
+
var mk = D.el("mask", {id: uid + "m" + i, maskUnits: "userSpaceOnUse", x: 0, y: 0, width: p.W, height: p.H}, defs);
|
|
85
|
+
it.mpath = D.el("path", {d: d, fill: "none", stroke: "#fff", "stroke-width": P.lw + 6, pathLength: 1, "stroke-dasharray": "1 2"}, mk);
|
|
86
|
+
var gg = D.el("g", {mask: "url(#" + uid + "m" + i + ")", "clip-path": p.clip}, p.svg);
|
|
87
|
+
it.path = D.el("path", {d: d, fill: "none", stroke: col, "stroke-width": P.lw, "stroke-dasharray": "10 8", "stroke-linecap": "butt"}, gg);
|
|
88
|
+
it.draw = it.mpath;
|
|
89
|
+
} else {
|
|
90
|
+
it.path = D.el("path", {d: d, fill: "none", stroke: col, "stroke-width": P.lw, "clip-path": p.clip, pathLength: 1, "stroke-dasharray": "1 2", "stroke-linejoin": "round"}, p.svg);
|
|
91
|
+
it.draw = it.path;
|
|
92
|
+
}
|
|
93
|
+
// 面積(area:[a, b] か [[a, b], …]。null は軸の端):線と横軸(y = 0、範囲の外なら下の端)のあいだを、その区間だけ薄く塗る。
|
|
94
|
+
// 棄却域・p 値・信頼区間・確率など。線が引き終わってから出る(名前と同じ時に)。areaLabel は区間ごとに中に書く(字の列なら区間の順に)
|
|
95
|
+
if (s.area !== undefined){
|
|
96
|
+
var A = Array.isArray(s.area) && s.area.length && Array.isArray(s.area[0]) ? s.area : [s.area];
|
|
97
|
+
var yb = p.y(Math.max(Math.min(P.yr[0], P.yr[1]), Math.min(Math.max(P.yr[0], P.yr[1]), 0))), ad = "", segs = [];
|
|
98
|
+
A.forEach(function(r){
|
|
99
|
+
if (!Array.isArray(r) || r.length !== 2 || r.some(function(v){ return v !== null && !(typeof v === "number" && isFinite(v)); })){ ctx.report("data", "[curves] series " + i + ": area " + JSON.stringify(r) + " is not [from, to] (numbers, or null for the edge)"); return; }
|
|
100
|
+
var la = p.x(r[0] === null ? P.xr[0] : r[0]), lb = p.x(r[1] === null ? P.xr[1] : r[1]);
|
|
101
|
+
if (la > lb){ var tt = la; la = lb; lb = tt; }
|
|
102
|
+
var seg = pts.filter(function(q){ return isFinite(q[0]) && isFinite(q[1]) && q[0] >= la - 0.01 && q[0] <= lb + 0.01; });
|
|
103
|
+
if (seg.length < 2){ ctx.report("data", "[curves] series " + i + ": area " + JSON.stringify(r) + " has no part of the line in it"); return; }
|
|
104
|
+
ad += "M" + seg[0][0].toFixed(1) + "," + yb.toFixed(1) + seg.map(function(q){ return "L" + q[0].toFixed(1) + "," + q[1].toFixed(1); }).join("") + "L" + seg[seg.length - 1][0].toFixed(1) + "," + yb.toFixed(1) + "Z";
|
|
105
|
+
segs.push({w: seg[seg.length - 1][0] - seg[0][0], seg: seg});
|
|
106
|
+
});
|
|
107
|
+
if (ad){
|
|
108
|
+
it.area = D.el("path", {d: ad, fill: col, "fill-opacity": 0.28, stroke: "none", "clip-path": p.clip, opacity: 0}, p.svg);
|
|
109
|
+
p.svg.insertBefore(it.area, s.dash ? it.path.parentNode : it.path); // 線の下に
|
|
110
|
+
// 区間の名前:区間の真ん中の上(線より上、字の高さぶん離す)。細い区間でも読めるように線の上に置き、背景色で縁取る
|
|
111
|
+
it.areaLabs = [];
|
|
112
|
+
segs.forEach(function(o, j){
|
|
113
|
+
var t = Array.isArray(s.areaLabel) ? s.areaLabel[j] : s.areaLabel;
|
|
114
|
+
if (!t) return;
|
|
115
|
+
var mid = o.seg[Math.floor(o.seg.length / 2)], top = Math.min.apply(null, o.seg.map(function(q){ return q[1]; }));
|
|
116
|
+
var tx = Math.max(x0 + 4, Math.min(x1 - 4, mid[0])), ty = Math.max(y0 + F, top - 10);
|
|
117
|
+
it.areaLabs.push(D.mtext(p.svg, tx, ty, t, {"text-anchor": "middle", fill: col, stroke: "var(--bg)", "stroke-width": 6, "paint-order": "stroke", "font-size": F, "font-weight": 700, opacity: 0}));
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// 名前の位置:labelAt(横軸の値)の点、なければ描画範囲の中の最後の点。at は labelAt の古い名前(labelAt がないときだけ)
|
|
122
|
+
var inside = pts.filter(function(q){ return q[0] >= x0 - .5 && q[0] <= x1 + .5 && q[1] >= y0 - .5 && q[1] <= y1 + .5; });
|
|
123
|
+
var end = inside.length ? inside[inside.length - 1] : pts[pts.length - 1];
|
|
124
|
+
var lat = s.labelAt !== undefined ? s.labelAt : s.at;
|
|
125
|
+
if (!end){ it.lx = it.ly = it.x0 = it.x1 = 0; it.anchor = "start"; it.col = col; it.label = ""; return it; } // 有限な点がない:名前は書かない
|
|
126
|
+
if (lat !== undefined){
|
|
127
|
+
var ax = p.x(lat), best = pts[0];
|
|
128
|
+
pts.forEach(function(q){ if (Math.abs(q[0] - ax) < Math.abs(best[0] - ax)) best = q; });
|
|
129
|
+
end = best;
|
|
130
|
+
}
|
|
131
|
+
// anchor:right(点の右から書く)・left(点の左で終わる)・above / below(点の上・下に中央そろえ、約 0.9 字ぶん離す)。
|
|
132
|
+
// start / middle / end は古い書き方(text-anchor そのもの)で、今までどおり
|
|
133
|
+
var an = {top: "above", bottom: "below"}[s.anchor] || s.anchor; // top / bottom は above / below の別名
|
|
134
|
+
var side = {right: "start", left: "end", above: "middle", below: "middle"}, anchor = side[an] || an || (end[0] > x1 - 160 ? "end" : "start");
|
|
135
|
+
var ly0 = an === "above" ? end[1] - Math.round(14 * K) : an === "below" ? end[1] + Math.round(32 * K) : end[1] - Math.round(12 * K);
|
|
136
|
+
if (an === "below" && ly0 > y1 - 4) ly0 = end[1] - Math.round(14 * K); // 下に入らなければ上へ
|
|
137
|
+
it.lx = end[0] + (anchor === "end" ? -8 : anchor === "start" ? 10 : 0) + (s.dx || 0);
|
|
138
|
+
it.ly = (s.ly !== undefined ? p.y(s.ly) : ly0) + (s.dy || 0);
|
|
139
|
+
// 字の幅の見積もり(26px。base の textWidth:テーマの字で測った幅。記法の * _ ^ を除く)
|
|
140
|
+
var w = D.textWidth(s.label || "", F, {font: self, mark: true});
|
|
141
|
+
it.x0 = anchor === "end" ? it.lx - w : anchor === "middle" ? it.lx - w / 2 : it.lx; it.x1 = it.x0 + w;
|
|
142
|
+
it.anchor = anchor; it.col = col; it.label = s.label || "";
|
|
143
|
+
return it;
|
|
144
|
+
});
|
|
145
|
+
// 名前どうしが重ならないように、横に重なる名前を下へずらす。先に描く高さ(上は 26、下は横軸の 6 px 上)に収めてから離し、
|
|
146
|
+
// 下に収まらなければ下から上へ押し戻す(目盛りの数字にかからない)。上付きのある名前は上端を、下付きのある名前は下端を
|
|
147
|
+
// その分だけ内に、上の名前の下付き・下の名前の上付きの分だけ間を広げる(記法がなければ今までと同じ)
|
|
148
|
+
var min = Math.round(32 * K), lo = F, hi = y1 - 6, ov = function(u, v){ return u.x0 < v.x1 && v.x0 < u.x1; };
|
|
149
|
+
var loOf = function(it){ return lo + supX(it.label, F); }, hiOf = function(it){ return hi - subX(it.label, F); };
|
|
150
|
+
var gap = function(u, v){ return min + subX(u.label, F) + supX(v.label, F); }; // u が上、v が下
|
|
151
|
+
var g = self.items.filter(function(it){ return it.label; });
|
|
152
|
+
g.forEach(function(it){ it.ly = Math.min(hiOf(it), Math.max(loOf(it), it.ly)); });
|
|
153
|
+
g.sort(function(u, v){ return u.ly - v.ly; });
|
|
154
|
+
g.forEach(function(it, j){
|
|
155
|
+
for (var q = 0; q < j; q++){
|
|
156
|
+
var o = g[q];
|
|
157
|
+
if (ov(it, o) && it.ly - o.ly < gap(o, it)) it.ly = o.ly + gap(o, it);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
for (var j = g.length - 1; j >= 0; j--){
|
|
161
|
+
var it = g[j];
|
|
162
|
+
it.ly = Math.min(hiOf(it), it.ly);
|
|
163
|
+
for (var q = j + 1; q < g.length; q++) if (ov(it, g[q]) && g[q].ly - it.ly < gap(it, g[q])) it.ly = g[q].ly - gap(it, g[q]);
|
|
164
|
+
}
|
|
165
|
+
g.forEach(function(it){ it.ly = Math.max(loOf(it), it.ly); });
|
|
166
|
+
this.items.forEach(function(it){
|
|
167
|
+
it.lab = D.mtext(p.svg, it.lx, it.ly, it.label, {"text-anchor": it.anchor, fill: it.col, "font-size": F, "font-weight": 700, opacity: 0});
|
|
168
|
+
});
|
|
169
|
+
// tone:テーマの色の名前か var(--…)。知らない名前は既定の色(series-1..4 の順)にして知らせる
|
|
170
|
+
function colorOf(c, i){
|
|
171
|
+
var def = "var(--series-" + (i % 4 + 1) + ")";
|
|
172
|
+
if (!c) return def;
|
|
173
|
+
if (c.indexOf("var(") === 0) return c;
|
|
174
|
+
var nm = c.replace(/^--/, "");
|
|
175
|
+
if (/^(term|emph|accent2|muted|fg|line|series-[1-4])$/.test(nm)) return "var(--" + nm + ")";
|
|
176
|
+
ctx.report("attr", "[curves] series " + i + ": tone " + JSON.stringify(c) + " is not term, emph, accent2, muted, fg or series-1..4 (" + def.slice(6, -1) + " is used)");
|
|
177
|
+
return def;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
duration(k){ return k >= 1 ? this.props.dur * 0.7 + 0.6 : 0; }
|
|
181
|
+
render(k, t, ctx){
|
|
182
|
+
var dur = this.props.dur, preview = !!ctx.preview, PV = preview ? base.previewOpacity(this) : 0;
|
|
183
|
+
// 先を薄く見せる表示:後の段階の線と名前を、引き終えた形のままテーマの --preview-opacity(なければ 0.45)で描く
|
|
184
|
+
this.items.forEach(function(it){
|
|
185
|
+
if (preview && it.step > k){
|
|
186
|
+
it.draw.setAttribute("stroke-dashoffset", (0).toFixed(4));
|
|
187
|
+
it.path.setAttribute("opacity", PV);
|
|
188
|
+
it.lab.setAttribute("opacity", PV.toFixed(3));
|
|
189
|
+
if (it.area) it.area.setAttribute("opacity", PV.toFixed(3));
|
|
190
|
+
(it.areaLabs || []).forEach(function(e){ e.setAttribute("opacity", PV.toFixed(3)); });
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
var pd = it.step < k ? 1 : it.step === k ? base.prog(t, 0, dur) : 0;
|
|
194
|
+
var pl = it.step < k ? 1 : it.step === k ? base.prog(t, dur * 0.7, 0.6) : 0;
|
|
195
|
+
it.draw.setAttribute("stroke-dashoffset", (1 - pd).toFixed(4));
|
|
196
|
+
it.path.setAttribute("opacity", pd > 0 ? 1 : 0);
|
|
197
|
+
it.lab.setAttribute("opacity", pl.toFixed(3));
|
|
198
|
+
if (it.area) it.area.setAttribute("opacity", pl.toFixed(3));
|
|
199
|
+
(it.areaLabs || []).forEach(function(e){ e.setAttribute("opacity", pl.toFixed(3)); });
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
});
|