@lincyaw/aegis-ui 0.9.2 → 0.9.3
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/dist/components/ui/LineChart.cjs +1 -1
- package/dist/components/ui/LineChart.cjs.map +1 -1
- package/dist/components/ui/LineChart.d.ts +2 -1
- package/dist/components/ui/LineChart.js +138 -107
- package/dist/components/ui/LineChart.js.map +1 -1
- package/dist/components/ui/SeriesLabel.cjs +1 -1
- package/dist/components/ui/SeriesLabel.cjs.map +1 -1
- package/dist/components/ui/SeriesLabel.d.ts +3 -2
- package/dist/components/ui/SeriesLabel.js +34 -16
- package/dist/components/ui/SeriesLabel.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/lib/chart.cjs +1 -1
- package/dist/lib/chart.cjs.map +1 -1
- package/dist/lib/chart.d.ts +2 -0
- package/dist/lib/chart.js +22 -14
- package/dist/lib/chart.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,28 +1,46 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { chartColorValue as
|
|
1
|
+
import { jsxs as m, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { chartLineDash as t, chartColorValue as c } from "../../lib/chart.js";
|
|
3
3
|
/* empty css */
|
|
4
|
-
import { DefaultLink as
|
|
5
|
-
function
|
|
4
|
+
import { DefaultLink as d } from "./linkComponent.js";
|
|
5
|
+
function g({
|
|
6
6
|
name: s,
|
|
7
7
|
detail: a,
|
|
8
|
-
color:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
color: r,
|
|
9
|
+
lineStyle: i,
|
|
10
|
+
to: l,
|
|
11
|
+
linkComponent: n = d,
|
|
12
|
+
className: o
|
|
12
13
|
}) {
|
|
13
|
-
return /* @__PURE__ */
|
|
14
|
+
return /* @__PURE__ */ m(
|
|
14
15
|
"span",
|
|
15
16
|
{
|
|
16
|
-
className: ["aegis-series-label",
|
|
17
|
+
className: ["aegis-series-label", o ?? ""].filter(Boolean).join(" "),
|
|
17
18
|
style: {
|
|
18
|
-
"--aegis-series-label-color":
|
|
19
|
+
"--aegis-series-label-color": c(r)
|
|
19
20
|
},
|
|
20
21
|
children: [
|
|
21
|
-
/* @__PURE__ */ e("span", { className: "aegis-series-label__dot", "aria-hidden": "true" })
|
|
22
|
-
|
|
23
|
-
r,
|
|
22
|
+
i === void 0 ? /* @__PURE__ */ e("span", { className: "aegis-series-label__dot", "aria-hidden": "true" }) : /* @__PURE__ */ e(
|
|
23
|
+
"svg",
|
|
24
24
|
{
|
|
25
|
-
|
|
25
|
+
className: "aegis-series-label__line",
|
|
26
|
+
"aria-hidden": "true",
|
|
27
|
+
viewBox: "0 0 32 10",
|
|
28
|
+
children: /* @__PURE__ */ e(
|
|
29
|
+
"line",
|
|
30
|
+
{
|
|
31
|
+
x1: 0,
|
|
32
|
+
x2: 32,
|
|
33
|
+
y1: 5,
|
|
34
|
+
y2: 5,
|
|
35
|
+
style: { strokeDasharray: t(i) }
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
),
|
|
40
|
+
l === void 0 ? /* @__PURE__ */ e("span", { className: "aegis-series-label__name", children: s }) : /* @__PURE__ */ e(
|
|
41
|
+
n,
|
|
42
|
+
{
|
|
43
|
+
to: l,
|
|
26
44
|
className: "aegis-series-label__name aegis-series-label__name--link",
|
|
27
45
|
children: s
|
|
28
46
|
}
|
|
@@ -33,6 +51,6 @@ function b({
|
|
|
33
51
|
);
|
|
34
52
|
}
|
|
35
53
|
export {
|
|
36
|
-
|
|
54
|
+
g as SeriesLabel
|
|
37
55
|
};
|
|
38
56
|
//# sourceMappingURL=SeriesLabel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SeriesLabel.js","sources":["../../../src/components/ui/SeriesLabel.tsx"],"sourcesContent":["import type { CSSProperties, ReactElement, ReactNode } from 'react';\n\nimport {
|
|
1
|
+
{"version":3,"file":"SeriesLabel.js","sources":["../../../src/components/ui/SeriesLabel.tsx"],"sourcesContent":["import type { CSSProperties, ReactElement, ReactNode } from 'react';\n\nimport {\n type ChartColor,\n type ChartLineStyle,\n chartColorValue,\n chartLineDash,\n} from '../../lib/chart';\nimport './SeriesLabel.css';\nimport { DefaultLink, type LinkComponent } from './linkComponent';\n\nexport interface SeriesLabelProps {\n /** The series, e.g. a model's name. */\n name: ReactNode;\n /** A muted second part, e.g. the harness it ran with. */\n detail?: ReactNode;\n /** The series' colour, the same as its marks on the page's charts. */\n color: ChartColor;\n lineStyle?: ChartLineStyle;\n /** Makes the name a link. */\n to?: string;\n /** Renders the link. Defaults to an `<a href>`; routed apps pass their Link adapter. */\n linkComponent?: LinkComponent;\n className?: string;\n}\n\n/**\n * A series named in its colour, for charts that label their marks directly\n * instead of using a legend, and for the lists and tables around them.\n */\nexport function SeriesLabel({\n name,\n detail,\n color,\n lineStyle,\n to,\n linkComponent: Link = DefaultLink,\n className,\n}: SeriesLabelProps): ReactElement {\n return (\n <span\n className={['aegis-series-label', className ?? '']\n .filter(Boolean)\n .join(' ')}\n style={\n {\n '--aegis-series-label-color': chartColorValue(color),\n } as CSSProperties\n }\n >\n {lineStyle === undefined ? (\n <span className=\"aegis-series-label__dot\" aria-hidden=\"true\" />\n ) : (\n <svg\n className=\"aegis-series-label__line\"\n aria-hidden=\"true\"\n viewBox=\"0 0 32 10\"\n >\n <line\n x1={0}\n x2={32}\n y1={5}\n y2={5}\n style={{ strokeDasharray: chartLineDash(lineStyle) }}\n />\n </svg>\n )}\n {to === undefined ? (\n <span className=\"aegis-series-label__name\">{name}</span>\n ) : (\n <Link\n to={to}\n className=\"aegis-series-label__name aegis-series-label__name--link\"\n >\n {name}\n </Link>\n )}\n {detail !== undefined && (\n <span className=\"aegis-series-label__detail\">{detail}</span>\n )}\n </span>\n );\n}\n"],"names":["SeriesLabel","name","detail","color","lineStyle","to","Link","DefaultLink","className","jsxs","chartColorValue","jsx","chartLineDash"],"mappings":";;;;AA8BO,SAASA,EAAY;AAAA,EAC1B,MAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,IAAAC;AAAA,EACA,eAAeC,IAAOC;AAAA,EACtB,WAAAC;AACF,GAAmC;AACjC,SACE,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,CAAC,sBAAsBD,KAAa,EAAE,EAC9C,OAAO,OAAO,EACd,KAAK,GAAG;AAAA,MACX,OACE;AAAA,QACE,8BAA8BE,EAAgBP,CAAK;AAAA,MAAA;AAAA,MAItD,UAAA;AAAA,QAAAC,MAAc,SACb,gBAAAO,EAAC,QAAA,EAAK,WAAU,2BAA0B,eAAY,QAAO,IAE7D,gBAAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,eAAY;AAAA,YACZ,SAAQ;AAAA,YAER,UAAA,gBAAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,IAAI;AAAA,gBACJ,IAAI;AAAA,gBACJ,IAAI;AAAA,gBACJ,IAAI;AAAA,gBACJ,OAAO,EAAE,iBAAiBC,EAAcR,CAAS,EAAA;AAAA,cAAE;AAAA,YAAA;AAAA,UACrD;AAAA,QAAA;AAAA,QAGHC,MAAO,SACN,gBAAAM,EAAC,UAAK,WAAU,4BAA4B,aAAK,IAEjD,gBAAAA;AAAA,UAACL;AAAA,UAAA;AAAA,YACC,IAAAD;AAAA,YACA,WAAU;AAAA,YAET,UAAAJ;AAAA,UAAA;AAAA,QAAA;AAAA,QAGJC,MAAW,UACV,gBAAAS,EAAC,QAAA,EAAK,WAAU,8BAA8B,UAAAT,EAAA,CAAO;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAI7D;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type { RelativeTimePreset, TimeRange } from './lib/timeRange';
|
|
|
7
7
|
export { replaceTokenAtCursor, tokenizeAtCursor } from './lib/luceneQuery';
|
|
8
8
|
export type { CursorToken } from './lib/luceneQuery';
|
|
9
9
|
export { chartColorValue, niceTicks, stageProgress, staggeredProgress, zeroAnchoredDomain, } from './lib/chart';
|
|
10
|
-
export type { ChartColor, ChartPaletteColor } from './lib/chart';
|
|
10
|
+
export type { ChartColor, ChartLineStyle, ChartPaletteColor, } from './lib/chart';
|
|
11
11
|
export { PageWrapper } from './layouts/PageWrapper';
|
|
12
12
|
export type { PageWrapperProps } from './layouts/PageWrapper';
|
|
13
13
|
export { SiteAnchorNav, SiteFooter, SiteLayout, SiteNav, SiteSection, SiteSectionHeader, } from './layouts/site';
|
package/dist/lib/chart.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M={seq:"var(--data-seq)","cat-1":"var(--data-cat-1)","cat-2":"var(--data-cat-2)","cat-3":"var(--data-cat-3)","cat-4":"var(--data-cat-4)","cat-5":"var(--data-cat-5)","cat-6":"var(--data-cat-6)",unknown:"var(--bg-muted)"};function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(t){return{solid:void 0,dashed:"var(--space-2) var(--space-1)",dotted:"var(--size-hairline) var(--space-1)"}[t]}const M={seq:"var(--data-seq)","cat-1":"var(--data-cat-1)","cat-2":"var(--data-cat-2)","cat-3":"var(--data-cat-3)","cat-4":"var(--data-cat-4)","cat-5":"var(--data-cat-5)","cat-6":"var(--data-cat-6)",unknown:"var(--bg-muted)"};function m(t){return t.startsWith("var(")?t:M[t]}function f(t,n){const a=Math.min(0,...t),e=n??Math.max(0,...t);return e<=a?[a,a+1]:[a,e]}function h(t){if(!(t>0)||!Number.isFinite(t))return 1;const n=10**Math.floor(Math.log10(t)),a=t/n;return(a<=1?1:a<=2?2:a<=5?5:10)*n}const v=50;function p(t,n,a=5){if(!(n>t))return[];const e=h((n-t)/a),s=1e-9,u=Math.ceil(t/e-s),d=Math.floor(n/e+s),l=Math.max(0,-Math.floor(Math.log10(e))),r=[];for(let c=u;c<=d&&r.length<v;c+=1){const o=Number((c*e).toFixed(l));r.push(o===0?0:o)}return r}const i=.12;function S(t,n,a){const e=1+i*Math.max(a-1,0);return Math.min(1,Math.max(0,t*e-i*n))}function T(t,n,a){return Math.min(1,Math.max(0,(t-n)/(a-n)))}exports.chartColorValue=m;exports.chartLineDash=g;exports.niceStep=h;exports.niceTicks=p;exports.stageProgress=T;exports.staggeredProgress=S;exports.zeroAnchoredDomain=f;
|
|
2
2
|
//# sourceMappingURL=chart.cjs.map
|
package/dist/lib/chart.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart.cjs","sources":["../../src/lib/chart.ts"],"sourcesContent":["/** Colours of the data palette in theme.css. */\nexport type ChartPaletteColor =\n | 'seq'\n | 'cat-1'\n | 'cat-2'\n | 'cat-3'\n | 'cat-4'\n | 'cat-5'\n | 'cat-6'\n | 'unknown';\n\n/**\n * How a chart colours a series: a palette colour (`seq` for one\n * magnitude, `cat-1`…`cat-6` to tell series apart, `unknown` a neutral\n * fill for a share not classified yet), or a `var(…)` reference to a\n * token, such as a `--series-*` vendor colour, so one vendor keeps its\n * colour on every chart.\n */\nexport type ChartColor = ChartPaletteColor | `var(--${string})`;\n\nconst PALETTE_VALUES: Record<ChartPaletteColor, string> = {\n seq: 'var(--data-seq)',\n 'cat-1': 'var(--data-cat-1)',\n 'cat-2': 'var(--data-cat-2)',\n 'cat-3': 'var(--data-cat-3)',\n 'cat-4': 'var(--data-cat-4)',\n 'cat-5': 'var(--data-cat-5)',\n 'cat-6': 'var(--data-cat-6)',\n unknown: 'var(--bg-muted)',\n};\n\n/** The CSS colour of a chart colour. */\nexport function chartColorValue(color: ChartColor): string {\n return color.startsWith('var(')\n ? color\n : PALETTE_VALUES[color as ChartPaletteColor];\n}\n\n/**\n * The span an axis covers: from 0 (or the smallest value, when negative)\n * to `max` when given, else to the largest value. A span of all zeros\n * becomes [0, 1] so the scale still divides.\n */\nexport function zeroAnchoredDomain(\n values: number[],\n max?: number,\n): [number, number] {\n const lo = Math.min(0, ...values);\n const hi = max ?? Math.max(0, ...values);\n return hi <= lo ? [lo, lo + 1] : [lo, hi];\n}\n\n/** The smallest 1, 2 or 5 × 10ⁿ step not below `raw`. */\nexport function niceStep(raw: number): number {\n if (!(raw > 0) || !Number.isFinite(raw)) {\n return 1;\n }\n const base = 10 ** Math.floor(Math.log10(raw));\n const normalized = raw / base;\n const nice =\n normalized <= 1 ? 1 : normalized <= 2 ? 2 : normalized <= 5 ? 5 : 10;\n return nice * base;\n}\n\nconst MAX_TICKS = 50;\n\n/**\n * Round values from `lo` to `hi`, about `count` of them. Ticks are\n * computed by index rather than by repeated addition, so a span far from\n * zero (nanosecond timestamps) neither drifts nor stalls, and each is\n * rounded to the step's decimals, so 0.6 stays 0.6 and an end that is a\n * multiple of the step is a tick.\n */\nexport function niceTicks(lo: number, hi: number, count = 5): number[] {\n if (!(hi > lo)) {\n return [];\n }\n const step = niceStep((hi - lo) / count);\n // Absorbs division error such as 0.6 / 0.2 = 2.9999999999999996.\n const epsilon = 1e-9;\n const first = Math.ceil(lo / step - epsilon);\n const last = Math.floor(hi / step + epsilon);\n const decimals = Math.max(0, -Math.floor(Math.log10(step)));\n const ticks: number[] = [];\n for (let i = first; i <= last && ticks.length < MAX_TICKS; i += 1) {\n const tick = Number((i * step).toFixed(decimals));\n ticks.push(tick === 0 ? 0 : tick);\n }\n return ticks;\n}\n\n/** How far later rows lag behind the first, as a share of the draw. */\nconst STAGGER = 0.12;\n\n/**\n * The share of row `index` (of `count`) that is drawn when the chart as a\n * whole is `progress` of the way in: rows start one after another and\n * all finish at 1.\n */\nexport function staggeredProgress(\n progress: number,\n index: number,\n count: number,\n): number {\n const span = 1 + STAGGER * Math.max(count - 1, 0);\n return Math.min(1, Math.max(0, progress * span - STAGGER * index));\n}\n\n/**\n * Where `progress` is within one stage, `from` to `to`, of a chart's draw:\n * 0 before the stage, 1 after it.\n */\nexport function stageProgress(\n progress: number,\n from: number,\n to: number,\n): number {\n return Math.min(1, Math.max(0, (progress - from) / (to - from)));\n}\n"],"names":["PALETTE_VALUES","chartColorValue","color","zeroAnchoredDomain","values","max","lo","hi","niceStep","raw","base","normalized","MAX_TICKS","niceTicks","count","step","epsilon","first","last","decimals","ticks","i","tick","STAGGER","staggeredProgress","progress","index","span","stageProgress","from","to"],"mappings":"
|
|
1
|
+
{"version":3,"file":"chart.cjs","sources":["../../src/lib/chart.ts"],"sourcesContent":["/** Colours of the data palette in theme.css. */\nexport type ChartPaletteColor =\n | 'seq'\n | 'cat-1'\n | 'cat-2'\n | 'cat-3'\n | 'cat-4'\n | 'cat-5'\n | 'cat-6'\n | 'unknown';\n\n/**\n * How a chart colours a series: a palette colour (`seq` for one\n * magnitude, `cat-1`…`cat-6` to tell series apart, `unknown` a neutral\n * fill for a share not classified yet), or a `var(…)` reference to a\n * token, such as a `--series-*` vendor colour, so one vendor keeps its\n * colour on every chart.\n */\nexport type ChartColor = ChartPaletteColor | `var(--${string})`;\n\nexport type ChartLineStyle = 'solid' | 'dashed' | 'dotted';\n\nexport function chartLineDash(style: ChartLineStyle): string | undefined {\n return {\n solid: undefined,\n dashed: 'var(--space-2) var(--space-1)',\n dotted: 'var(--size-hairline) var(--space-1)',\n }[style];\n}\n\nconst PALETTE_VALUES: Record<ChartPaletteColor, string> = {\n seq: 'var(--data-seq)',\n 'cat-1': 'var(--data-cat-1)',\n 'cat-2': 'var(--data-cat-2)',\n 'cat-3': 'var(--data-cat-3)',\n 'cat-4': 'var(--data-cat-4)',\n 'cat-5': 'var(--data-cat-5)',\n 'cat-6': 'var(--data-cat-6)',\n unknown: 'var(--bg-muted)',\n};\n\n/** The CSS colour of a chart colour. */\nexport function chartColorValue(color: ChartColor): string {\n return color.startsWith('var(')\n ? color\n : PALETTE_VALUES[color as ChartPaletteColor];\n}\n\n/**\n * The span an axis covers: from 0 (or the smallest value, when negative)\n * to `max` when given, else to the largest value. A span of all zeros\n * becomes [0, 1] so the scale still divides.\n */\nexport function zeroAnchoredDomain(\n values: number[],\n max?: number,\n): [number, number] {\n const lo = Math.min(0, ...values);\n const hi = max ?? Math.max(0, ...values);\n return hi <= lo ? [lo, lo + 1] : [lo, hi];\n}\n\n/** The smallest 1, 2 or 5 × 10ⁿ step not below `raw`. */\nexport function niceStep(raw: number): number {\n if (!(raw > 0) || !Number.isFinite(raw)) {\n return 1;\n }\n const base = 10 ** Math.floor(Math.log10(raw));\n const normalized = raw / base;\n const nice =\n normalized <= 1 ? 1 : normalized <= 2 ? 2 : normalized <= 5 ? 5 : 10;\n return nice * base;\n}\n\nconst MAX_TICKS = 50;\n\n/**\n * Round values from `lo` to `hi`, about `count` of them. Ticks are\n * computed by index rather than by repeated addition, so a span far from\n * zero (nanosecond timestamps) neither drifts nor stalls, and each is\n * rounded to the step's decimals, so 0.6 stays 0.6 and an end that is a\n * multiple of the step is a tick.\n */\nexport function niceTicks(lo: number, hi: number, count = 5): number[] {\n if (!(hi > lo)) {\n return [];\n }\n const step = niceStep((hi - lo) / count);\n // Absorbs division error such as 0.6 / 0.2 = 2.9999999999999996.\n const epsilon = 1e-9;\n const first = Math.ceil(lo / step - epsilon);\n const last = Math.floor(hi / step + epsilon);\n const decimals = Math.max(0, -Math.floor(Math.log10(step)));\n const ticks: number[] = [];\n for (let i = first; i <= last && ticks.length < MAX_TICKS; i += 1) {\n const tick = Number((i * step).toFixed(decimals));\n ticks.push(tick === 0 ? 0 : tick);\n }\n return ticks;\n}\n\n/** How far later rows lag behind the first, as a share of the draw. */\nconst STAGGER = 0.12;\n\n/**\n * The share of row `index` (of `count`) that is drawn when the chart as a\n * whole is `progress` of the way in: rows start one after another and\n * all finish at 1.\n */\nexport function staggeredProgress(\n progress: number,\n index: number,\n count: number,\n): number {\n const span = 1 + STAGGER * Math.max(count - 1, 0);\n return Math.min(1, Math.max(0, progress * span - STAGGER * index));\n}\n\n/**\n * Where `progress` is within one stage, `from` to `to`, of a chart's draw:\n * 0 before the stage, 1 after it.\n */\nexport function stageProgress(\n progress: number,\n from: number,\n to: number,\n): number {\n return Math.min(1, Math.max(0, (progress - from) / (to - from)));\n}\n"],"names":["chartLineDash","style","PALETTE_VALUES","chartColorValue","color","zeroAnchoredDomain","values","max","lo","hi","niceStep","raw","base","normalized","MAX_TICKS","niceTicks","count","step","epsilon","first","last","decimals","ticks","i","tick","STAGGER","staggeredProgress","progress","index","span","stageProgress","from","to"],"mappings":"gFAsBO,SAASA,EAAcC,EAA2C,CACvE,MAAO,CACL,MAAO,OACP,OAAQ,gCACR,OAAQ,qCAAA,EACRA,CAAK,CACT,CAEA,MAAMC,EAAoD,CACxD,IAAK,kBACL,QAAS,oBACT,QAAS,oBACT,QAAS,oBACT,QAAS,oBACT,QAAS,oBACT,QAAS,oBACT,QAAS,iBACX,EAGO,SAASC,EAAgBC,EAA2B,CACzD,OAAOA,EAAM,WAAW,MAAM,EAC1BA,EACAF,EAAeE,CAA0B,CAC/C,CAOO,SAASC,EACdC,EACAC,EACkB,CAClB,MAAMC,EAAK,KAAK,IAAI,EAAG,GAAGF,CAAM,EAC1BG,EAAKF,GAAO,KAAK,IAAI,EAAG,GAAGD,CAAM,EACvC,OAAOG,GAAMD,EAAK,CAACA,EAAIA,EAAK,CAAC,EAAI,CAACA,EAAIC,CAAE,CAC1C,CAGO,SAASC,EAASC,EAAqB,CAC5C,GAAI,EAAEA,EAAM,IAAM,CAAC,OAAO,SAASA,CAAG,EACpC,MAAO,GAET,MAAMC,EAAO,IAAM,KAAK,MAAM,KAAK,MAAMD,CAAG,CAAC,EACvCE,EAAaF,EAAMC,EAGzB,OADEC,GAAc,EAAI,EAAIA,GAAc,EAAI,EAAIA,GAAc,EAAI,EAAI,IACtDD,CAChB,CAEA,MAAME,EAAY,GASX,SAASC,EAAUP,EAAYC,EAAYO,EAAQ,EAAa,CACrE,GAAI,EAAEP,EAAKD,GACT,MAAO,CAAA,EAET,MAAMS,EAAOP,GAAUD,EAAKD,GAAMQ,CAAK,EAEjCE,EAAU,KACVC,EAAQ,KAAK,KAAKX,EAAKS,EAAOC,CAAO,EACrCE,EAAO,KAAK,MAAMX,EAAKQ,EAAOC,CAAO,EACrCG,EAAW,KAAK,IAAI,EAAG,CAAC,KAAK,MAAM,KAAK,MAAMJ,CAAI,CAAC,CAAC,EACpDK,EAAkB,CAAA,EACxB,QAASC,EAAIJ,EAAOI,GAAKH,GAAQE,EAAM,OAASR,EAAWS,GAAK,EAAG,CACjE,MAAMC,EAAO,QAAQD,EAAIN,GAAM,QAAQI,CAAQ,CAAC,EAChDC,EAAM,KAAKE,IAAS,EAAI,EAAIA,CAAI,CAClC,CACA,OAAOF,CACT,CAGA,MAAMG,EAAU,IAOT,SAASC,EACdC,EACAC,EACAZ,EACQ,CACR,MAAMa,EAAO,EAAIJ,EAAU,KAAK,IAAIT,EAAQ,EAAG,CAAC,EAChD,OAAO,KAAK,IAAI,EAAG,KAAK,IAAI,EAAGW,EAAWE,EAAOJ,EAAUG,CAAK,CAAC,CACnE,CAMO,SAASE,EACdH,EACAI,EACAC,EACQ,CACR,OAAO,KAAK,IAAI,EAAG,KAAK,IAAI,GAAIL,EAAWI,IAASC,EAAKD,EAAK,CAAC,CACjE"}
|
package/dist/lib/chart.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export type ChartPaletteColor = 'seq' | 'cat-1' | 'cat-2' | 'cat-3' | 'cat-4' |
|
|
|
8
8
|
* colour on every chart.
|
|
9
9
|
*/
|
|
10
10
|
export type ChartColor = ChartPaletteColor | `var(--${string})`;
|
|
11
|
+
export type ChartLineStyle = 'solid' | 'dashed' | 'dotted';
|
|
12
|
+
export declare function chartLineDash(style: ChartLineStyle): string | undefined;
|
|
11
13
|
/** The CSS colour of a chart colour. */
|
|
12
14
|
export declare function chartColorValue(color: ChartColor): string;
|
|
13
15
|
/**
|
package/dist/lib/chart.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
function v(t) {
|
|
2
|
+
return {
|
|
3
|
+
solid: void 0,
|
|
4
|
+
dashed: "var(--space-2) var(--space-1)",
|
|
5
|
+
dotted: "var(--size-hairline) var(--space-1)"
|
|
6
|
+
}[t];
|
|
7
|
+
}
|
|
8
|
+
const M = {
|
|
2
9
|
seq: "var(--data-seq)",
|
|
3
10
|
"cat-1": "var(--data-cat-1)",
|
|
4
11
|
"cat-2": "var(--data-cat-2)",
|
|
@@ -9,42 +16,43 @@ const d = {
|
|
|
9
16
|
unknown: "var(--bg-muted)"
|
|
10
17
|
};
|
|
11
18
|
function l(t) {
|
|
12
|
-
return t.startsWith("var(") ? t :
|
|
19
|
+
return t.startsWith("var(") ? t : M[t];
|
|
13
20
|
}
|
|
14
21
|
function g(t, n) {
|
|
15
22
|
const a = Math.min(0, ...t), c = n ?? Math.max(0, ...t);
|
|
16
23
|
return c <= a ? [a, a + 1] : [a, c];
|
|
17
24
|
}
|
|
18
|
-
function
|
|
25
|
+
function f(t) {
|
|
19
26
|
if (!(t > 0) || !Number.isFinite(t))
|
|
20
27
|
return 1;
|
|
21
28
|
const n = 10 ** Math.floor(Math.log10(t)), a = t / n;
|
|
22
29
|
return (a <= 1 ? 1 : a <= 2 ? 2 : a <= 5 ? 5 : 10) * n;
|
|
23
30
|
}
|
|
24
|
-
const
|
|
25
|
-
function
|
|
31
|
+
const m = 50;
|
|
32
|
+
function p(t, n, a = 5) {
|
|
26
33
|
if (!(n > t))
|
|
27
34
|
return [];
|
|
28
|
-
const c =
|
|
29
|
-
for (let
|
|
30
|
-
const
|
|
31
|
-
|
|
35
|
+
const c = f((n - t) / a), s = 1e-9, h = Math.ceil(t / c - s), u = Math.floor(n / c + s), d = Math.max(0, -Math.floor(Math.log10(c))), e = [];
|
|
36
|
+
for (let r = h; r <= u && e.length < m; r += 1) {
|
|
37
|
+
const o = Number((r * c).toFixed(d));
|
|
38
|
+
e.push(o === 0 ? 0 : o);
|
|
32
39
|
}
|
|
33
|
-
return
|
|
40
|
+
return e;
|
|
34
41
|
}
|
|
35
42
|
const i = 0.12;
|
|
36
43
|
function x(t, n, a) {
|
|
37
44
|
const c = 1 + i * Math.max(a - 1, 0);
|
|
38
45
|
return Math.min(1, Math.max(0, t * c - i * n));
|
|
39
46
|
}
|
|
40
|
-
function
|
|
47
|
+
function A(t, n, a) {
|
|
41
48
|
return Math.min(1, Math.max(0, (t - n) / (a - n)));
|
|
42
49
|
}
|
|
43
50
|
export {
|
|
44
51
|
l as chartColorValue,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
p as
|
|
52
|
+
v as chartLineDash,
|
|
53
|
+
f as niceStep,
|
|
54
|
+
p as niceTicks,
|
|
55
|
+
A as stageProgress,
|
|
48
56
|
x as staggeredProgress,
|
|
49
57
|
g as zeroAnchoredDomain
|
|
50
58
|
};
|
package/dist/lib/chart.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart.js","sources":["../../src/lib/chart.ts"],"sourcesContent":["/** Colours of the data palette in theme.css. */\nexport type ChartPaletteColor =\n | 'seq'\n | 'cat-1'\n | 'cat-2'\n | 'cat-3'\n | 'cat-4'\n | 'cat-5'\n | 'cat-6'\n | 'unknown';\n\n/**\n * How a chart colours a series: a palette colour (`seq` for one\n * magnitude, `cat-1`…`cat-6` to tell series apart, `unknown` a neutral\n * fill for a share not classified yet), or a `var(…)` reference to a\n * token, such as a `--series-*` vendor colour, so one vendor keeps its\n * colour on every chart.\n */\nexport type ChartColor = ChartPaletteColor | `var(--${string})`;\n\nconst PALETTE_VALUES: Record<ChartPaletteColor, string> = {\n seq: 'var(--data-seq)',\n 'cat-1': 'var(--data-cat-1)',\n 'cat-2': 'var(--data-cat-2)',\n 'cat-3': 'var(--data-cat-3)',\n 'cat-4': 'var(--data-cat-4)',\n 'cat-5': 'var(--data-cat-5)',\n 'cat-6': 'var(--data-cat-6)',\n unknown: 'var(--bg-muted)',\n};\n\n/** The CSS colour of a chart colour. */\nexport function chartColorValue(color: ChartColor): string {\n return color.startsWith('var(')\n ? color\n : PALETTE_VALUES[color as ChartPaletteColor];\n}\n\n/**\n * The span an axis covers: from 0 (or the smallest value, when negative)\n * to `max` when given, else to the largest value. A span of all zeros\n * becomes [0, 1] so the scale still divides.\n */\nexport function zeroAnchoredDomain(\n values: number[],\n max?: number,\n): [number, number] {\n const lo = Math.min(0, ...values);\n const hi = max ?? Math.max(0, ...values);\n return hi <= lo ? [lo, lo + 1] : [lo, hi];\n}\n\n/** The smallest 1, 2 or 5 × 10ⁿ step not below `raw`. */\nexport function niceStep(raw: number): number {\n if (!(raw > 0) || !Number.isFinite(raw)) {\n return 1;\n }\n const base = 10 ** Math.floor(Math.log10(raw));\n const normalized = raw / base;\n const nice =\n normalized <= 1 ? 1 : normalized <= 2 ? 2 : normalized <= 5 ? 5 : 10;\n return nice * base;\n}\n\nconst MAX_TICKS = 50;\n\n/**\n * Round values from `lo` to `hi`, about `count` of them. Ticks are\n * computed by index rather than by repeated addition, so a span far from\n * zero (nanosecond timestamps) neither drifts nor stalls, and each is\n * rounded to the step's decimals, so 0.6 stays 0.6 and an end that is a\n * multiple of the step is a tick.\n */\nexport function niceTicks(lo: number, hi: number, count = 5): number[] {\n if (!(hi > lo)) {\n return [];\n }\n const step = niceStep((hi - lo) / count);\n // Absorbs division error such as 0.6 / 0.2 = 2.9999999999999996.\n const epsilon = 1e-9;\n const first = Math.ceil(lo / step - epsilon);\n const last = Math.floor(hi / step + epsilon);\n const decimals = Math.max(0, -Math.floor(Math.log10(step)));\n const ticks: number[] = [];\n for (let i = first; i <= last && ticks.length < MAX_TICKS; i += 1) {\n const tick = Number((i * step).toFixed(decimals));\n ticks.push(tick === 0 ? 0 : tick);\n }\n return ticks;\n}\n\n/** How far later rows lag behind the first, as a share of the draw. */\nconst STAGGER = 0.12;\n\n/**\n * The share of row `index` (of `count`) that is drawn when the chart as a\n * whole is `progress` of the way in: rows start one after another and\n * all finish at 1.\n */\nexport function staggeredProgress(\n progress: number,\n index: number,\n count: number,\n): number {\n const span = 1 + STAGGER * Math.max(count - 1, 0);\n return Math.min(1, Math.max(0, progress * span - STAGGER * index));\n}\n\n/**\n * Where `progress` is within one stage, `from` to `to`, of a chart's draw:\n * 0 before the stage, 1 after it.\n */\nexport function stageProgress(\n progress: number,\n from: number,\n to: number,\n): number {\n return Math.min(1, Math.max(0, (progress - from) / (to - from)));\n}\n"],"names":["PALETTE_VALUES","chartColorValue","color","zeroAnchoredDomain","values","max","lo","hi","niceStep","raw","base","normalized","MAX_TICKS","niceTicks","count","step","epsilon","first","last","decimals","ticks","i","tick","STAGGER","staggeredProgress","progress","index","span","stageProgress","from","to"],"mappings":"
|
|
1
|
+
{"version":3,"file":"chart.js","sources":["../../src/lib/chart.ts"],"sourcesContent":["/** Colours of the data palette in theme.css. */\nexport type ChartPaletteColor =\n | 'seq'\n | 'cat-1'\n | 'cat-2'\n | 'cat-3'\n | 'cat-4'\n | 'cat-5'\n | 'cat-6'\n | 'unknown';\n\n/**\n * How a chart colours a series: a palette colour (`seq` for one\n * magnitude, `cat-1`…`cat-6` to tell series apart, `unknown` a neutral\n * fill for a share not classified yet), or a `var(…)` reference to a\n * token, such as a `--series-*` vendor colour, so one vendor keeps its\n * colour on every chart.\n */\nexport type ChartColor = ChartPaletteColor | `var(--${string})`;\n\nexport type ChartLineStyle = 'solid' | 'dashed' | 'dotted';\n\nexport function chartLineDash(style: ChartLineStyle): string | undefined {\n return {\n solid: undefined,\n dashed: 'var(--space-2) var(--space-1)',\n dotted: 'var(--size-hairline) var(--space-1)',\n }[style];\n}\n\nconst PALETTE_VALUES: Record<ChartPaletteColor, string> = {\n seq: 'var(--data-seq)',\n 'cat-1': 'var(--data-cat-1)',\n 'cat-2': 'var(--data-cat-2)',\n 'cat-3': 'var(--data-cat-3)',\n 'cat-4': 'var(--data-cat-4)',\n 'cat-5': 'var(--data-cat-5)',\n 'cat-6': 'var(--data-cat-6)',\n unknown: 'var(--bg-muted)',\n};\n\n/** The CSS colour of a chart colour. */\nexport function chartColorValue(color: ChartColor): string {\n return color.startsWith('var(')\n ? color\n : PALETTE_VALUES[color as ChartPaletteColor];\n}\n\n/**\n * The span an axis covers: from 0 (or the smallest value, when negative)\n * to `max` when given, else to the largest value. A span of all zeros\n * becomes [0, 1] so the scale still divides.\n */\nexport function zeroAnchoredDomain(\n values: number[],\n max?: number,\n): [number, number] {\n const lo = Math.min(0, ...values);\n const hi = max ?? Math.max(0, ...values);\n return hi <= lo ? [lo, lo + 1] : [lo, hi];\n}\n\n/** The smallest 1, 2 or 5 × 10ⁿ step not below `raw`. */\nexport function niceStep(raw: number): number {\n if (!(raw > 0) || !Number.isFinite(raw)) {\n return 1;\n }\n const base = 10 ** Math.floor(Math.log10(raw));\n const normalized = raw / base;\n const nice =\n normalized <= 1 ? 1 : normalized <= 2 ? 2 : normalized <= 5 ? 5 : 10;\n return nice * base;\n}\n\nconst MAX_TICKS = 50;\n\n/**\n * Round values from `lo` to `hi`, about `count` of them. Ticks are\n * computed by index rather than by repeated addition, so a span far from\n * zero (nanosecond timestamps) neither drifts nor stalls, and each is\n * rounded to the step's decimals, so 0.6 stays 0.6 and an end that is a\n * multiple of the step is a tick.\n */\nexport function niceTicks(lo: number, hi: number, count = 5): number[] {\n if (!(hi > lo)) {\n return [];\n }\n const step = niceStep((hi - lo) / count);\n // Absorbs division error such as 0.6 / 0.2 = 2.9999999999999996.\n const epsilon = 1e-9;\n const first = Math.ceil(lo / step - epsilon);\n const last = Math.floor(hi / step + epsilon);\n const decimals = Math.max(0, -Math.floor(Math.log10(step)));\n const ticks: number[] = [];\n for (let i = first; i <= last && ticks.length < MAX_TICKS; i += 1) {\n const tick = Number((i * step).toFixed(decimals));\n ticks.push(tick === 0 ? 0 : tick);\n }\n return ticks;\n}\n\n/** How far later rows lag behind the first, as a share of the draw. */\nconst STAGGER = 0.12;\n\n/**\n * The share of row `index` (of `count`) that is drawn when the chart as a\n * whole is `progress` of the way in: rows start one after another and\n * all finish at 1.\n */\nexport function staggeredProgress(\n progress: number,\n index: number,\n count: number,\n): number {\n const span = 1 + STAGGER * Math.max(count - 1, 0);\n return Math.min(1, Math.max(0, progress * span - STAGGER * index));\n}\n\n/**\n * Where `progress` is within one stage, `from` to `to`, of a chart's draw:\n * 0 before the stage, 1 after it.\n */\nexport function stageProgress(\n progress: number,\n from: number,\n to: number,\n): number {\n return Math.min(1, Math.max(0, (progress - from) / (to - from)));\n}\n"],"names":["chartLineDash","style","PALETTE_VALUES","chartColorValue","color","zeroAnchoredDomain","values","max","lo","hi","niceStep","raw","base","normalized","MAX_TICKS","niceTicks","count","step","epsilon","first","last","decimals","ticks","i","tick","STAGGER","staggeredProgress","progress","index","span","stageProgress","from","to"],"mappings":"AAsBO,SAASA,EAAcC,GAA2C;AACvE,SAAO;AAAA,IACL,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,EAAA,EACRA,CAAK;AACT;AAEA,MAAMC,IAAoD;AAAA,EACxD,KAAK;AAAA,EACL,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AACX;AAGO,SAASC,EAAgBC,GAA2B;AACzD,SAAOA,EAAM,WAAW,MAAM,IAC1BA,IACAF,EAAeE,CAA0B;AAC/C;AAOO,SAASC,EACdC,GACAC,GACkB;AAClB,QAAMC,IAAK,KAAK,IAAI,GAAG,GAAGF,CAAM,GAC1BG,IAAKF,KAAO,KAAK,IAAI,GAAG,GAAGD,CAAM;AACvC,SAAOG,KAAMD,IAAK,CAACA,GAAIA,IAAK,CAAC,IAAI,CAACA,GAAIC,CAAE;AAC1C;AAGO,SAASC,EAASC,GAAqB;AAC5C,MAAI,EAAEA,IAAM,MAAM,CAAC,OAAO,SAASA,CAAG;AACpC,WAAO;AAET,QAAMC,IAAO,MAAM,KAAK,MAAM,KAAK,MAAMD,CAAG,CAAC,GACvCE,IAAaF,IAAMC;AAGzB,UADEC,KAAc,IAAI,IAAIA,KAAc,IAAI,IAAIA,KAAc,IAAI,IAAI,MACtDD;AAChB;AAEA,MAAME,IAAY;AASX,SAASC,EAAUP,GAAYC,GAAYO,IAAQ,GAAa;AACrE,MAAI,EAAEP,IAAKD;AACT,WAAO,CAAA;AAET,QAAMS,IAAOP,GAAUD,IAAKD,KAAMQ,CAAK,GAEjCE,IAAU,MACVC,IAAQ,KAAK,KAAKX,IAAKS,IAAOC,CAAO,GACrCE,IAAO,KAAK,MAAMX,IAAKQ,IAAOC,CAAO,GACrCG,IAAW,KAAK,IAAI,GAAG,CAAC,KAAK,MAAM,KAAK,MAAMJ,CAAI,CAAC,CAAC,GACpDK,IAAkB,CAAA;AACxB,WAASC,IAAIJ,GAAOI,KAAKH,KAAQE,EAAM,SAASR,GAAWS,KAAK,GAAG;AACjE,UAAMC,IAAO,QAAQD,IAAIN,GAAM,QAAQI,CAAQ,CAAC;AAChD,IAAAC,EAAM,KAAKE,MAAS,IAAI,IAAIA,CAAI;AAAA,EAClC;AACA,SAAOF;AACT;AAGA,MAAMG,IAAU;AAOT,SAASC,EACdC,GACAC,GACAZ,GACQ;AACR,QAAMa,IAAO,IAAIJ,IAAU,KAAK,IAAIT,IAAQ,GAAG,CAAC;AAChD,SAAO,KAAK,IAAI,GAAG,KAAK,IAAI,GAAGW,IAAWE,IAAOJ,IAAUG,CAAK,CAAC;AACnE;AAMO,SAASE,EACdH,GACAI,GACAC,GACQ;AACR,SAAO,KAAK,IAAI,GAAG,KAAK,IAAI,IAAIL,IAAWI,MAASC,IAAKD,EAAK,CAAC;AACjE;"}
|