mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-22 15:54:47 -07:00
global: multiple fixes
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
* @property {string} id
|
||||
* @property {Signal<boolean>} active
|
||||
* @property {Signal<boolean>} hasData
|
||||
* @property {Signal<string | null>} url
|
||||
* @property {VoidFunction} remove
|
||||
*/
|
||||
|
||||
@@ -128,7 +129,7 @@ export default import("./v5.0.7-treeshaked/script.js").then((lc) => {
|
||||
}
|
||||
: {}),
|
||||
// ..._options,
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
ichart.priceScale("right").applyOptions({
|
||||
@@ -160,7 +161,7 @@ export default import("./v5.0.7-treeshaked/script.js").then((lc) => {
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
let timeScaleSet = false;
|
||||
@@ -172,12 +173,12 @@ export default import("./v5.0.7-treeshaked/script.js").then((lc) => {
|
||||
index === /** @satisfies {MonthIndex} */ (7)
|
||||
? 1
|
||||
: index === /** @satisfies {QuarterIndex} */ (19)
|
||||
? 3
|
||||
: index === /** @satisfies {YearIndex} */ (23)
|
||||
? 12
|
||||
: index === /** @satisfies {DecadeIndex} */ (1)
|
||||
? 120
|
||||
: 0.5;
|
||||
? 3
|
||||
: index === /** @satisfies {YearIndex} */ (23)
|
||||
? 12
|
||||
: index === /** @satisfies {DecadeIndex} */ (1)
|
||||
? 120
|
||||
: 0.5;
|
||||
|
||||
ichart.applyOptions({
|
||||
timeScale: {
|
||||
@@ -200,12 +201,12 @@ export default import("./v5.0.7-treeshaked/script.js").then((lc) => {
|
||||
activeResources.forEach((v) => {
|
||||
v.fetch();
|
||||
});
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
if (fitContent) {
|
||||
new ResizeObserver(() => ichart.timeScale().fitContent()).observe(
|
||||
chartDiv
|
||||
chartDiv,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -234,7 +235,7 @@ export default import("./v5.0.7-treeshaked/script.js").then((lc) => {
|
||||
const children = Array.from(parent.childNodes).filter(
|
||||
(element) =>
|
||||
/** @type {HTMLElement} */ (element).dataset.position ===
|
||||
position
|
||||
position,
|
||||
);
|
||||
|
||||
if (children.length === 1) {
|
||||
@@ -256,7 +257,7 @@ export default import("./v5.0.7-treeshaked/script.js").then((lc) => {
|
||||
|
||||
fieldset.append(createChild(pane));
|
||||
}),
|
||||
paneIndex ? 50 : 0
|
||||
paneIndex ? 50 : 0,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -336,13 +337,11 @@ export default import("./v5.0.7-treeshaked/script.js").then((lc) => {
|
||||
|
||||
const hasData = signals.createSignal(false);
|
||||
|
||||
let url = /** @type {string | undefined} */ (undefined);
|
||||
|
||||
signals.createEffect(active, (active) =>
|
||||
// Or remove ?
|
||||
iseries.applyOptions({
|
||||
visible: active,
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
iseries.setSeriesOrder(order);
|
||||
@@ -356,6 +355,7 @@ export default import("./v5.0.7-treeshaked/script.js").then((lc) => {
|
||||
active,
|
||||
hasData,
|
||||
id,
|
||||
url: signals.createSignal(/** @type {string | null} */ (null)),
|
||||
remove() {
|
||||
dispose();
|
||||
// @ts-ignore
|
||||
@@ -372,14 +372,15 @@ export default import("./v5.0.7-treeshaked/script.js").then((lc) => {
|
||||
index,
|
||||
index === /** @satisfies {Height} */ (5)
|
||||
? "timestamp-fixed"
|
||||
: "timestamp"
|
||||
: "timestamp",
|
||||
);
|
||||
timeResource.fetch();
|
||||
|
||||
const valuesResource = vecsResources.getOrCreate(index, vecId);
|
||||
_valuesResource = valuesResource;
|
||||
|
||||
url = valuesResource.url;
|
||||
series.url.set(() => valuesResource.url);
|
||||
|
||||
signals.createEffect(active, (active) => {
|
||||
if (active) {
|
||||
valuesResource.fetch();
|
||||
@@ -478,7 +479,7 @@ export default import("./v5.0.7-treeshaked/script.js").then((lc) => {
|
||||
}
|
||||
});
|
||||
timeScaleSet = true;
|
||||
}
|
||||
},
|
||||
);
|
||||
} else {
|
||||
activeResources.delete(valuesResource);
|
||||
@@ -505,7 +506,6 @@ export default import("./v5.0.7-treeshaked/script.js").then((lc) => {
|
||||
series,
|
||||
name,
|
||||
colors,
|
||||
url,
|
||||
order,
|
||||
});
|
||||
|
||||
@@ -574,7 +574,7 @@ export default import("./v5.0.7-treeshaked/script.js").then((lc) => {
|
||||
borderVisible: false,
|
||||
visible: defaultActive !== false,
|
||||
},
|
||||
paneIndex
|
||||
paneIndex,
|
||||
)
|
||||
);
|
||||
|
||||
@@ -630,7 +630,7 @@ export default import("./v5.0.7-treeshaked/script.js").then((lc) => {
|
||||
color: color(),
|
||||
...options,
|
||||
},
|
||||
paneIndex
|
||||
paneIndex,
|
||||
)
|
||||
);
|
||||
|
||||
@@ -698,7 +698,7 @@ export default import("./v5.0.7-treeshaked/script.js").then((lc) => {
|
||||
topFillColor2: "transparent",
|
||||
lineVisible: true,
|
||||
},
|
||||
paneIndex
|
||||
paneIndex,
|
||||
)
|
||||
);
|
||||
|
||||
@@ -790,9 +790,8 @@ function createLegend({ signals, utils }) {
|
||||
* @param {string} args.name
|
||||
* @param {number} args.order
|
||||
* @param {Color[]} args.colors
|
||||
* @param {string} [args.url]
|
||||
*/
|
||||
addOrReplace({ series, name, colors, url, order }) {
|
||||
addOrReplace({ series, name, colors, order }) {
|
||||
const div = window.document.createElement("div");
|
||||
|
||||
const prev = legends[order];
|
||||
@@ -868,7 +867,7 @@ function createLegend({ signals, utils }) {
|
||||
} else {
|
||||
spanColor.style.backgroundColor = tameColor(color);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -897,14 +896,17 @@ function createLegend({ signals, utils }) {
|
||||
}
|
||||
});
|
||||
|
||||
if (url) {
|
||||
const anchor = window.document.createElement("a");
|
||||
anchor.href = url;
|
||||
anchor.target = "_blank";
|
||||
anchor.rel = "noopener noreferrer";
|
||||
anchor.title = "Click to view data";
|
||||
div.append(anchor);
|
||||
}
|
||||
const anchor = window.document.createElement("a");
|
||||
|
||||
signals.createEffect(series.url, (url) => {
|
||||
if (url) {
|
||||
anchor.href = url;
|
||||
anchor.target = "_blank";
|
||||
anchor.rel = "noopener noreferrer";
|
||||
anchor.title = "Click to view data";
|
||||
div.append(anchor);
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
* @param {number} start
|
||||
@@ -1025,17 +1027,17 @@ function numberToShortUSFormat(value, digits) {
|
||||
if (modulused === 0) {
|
||||
return `${numberToUSFormat(
|
||||
value / (1_000_000 * 1_000 ** letterIndex),
|
||||
3
|
||||
3,
|
||||
)}${letter}`;
|
||||
} else if (modulused === 1) {
|
||||
return `${numberToUSFormat(
|
||||
value / (1_000_000 * 1_000 ** letterIndex),
|
||||
2
|
||||
2,
|
||||
)}${letter}`;
|
||||
} else {
|
||||
return `${numberToUSFormat(
|
||||
value / (1_000_000 * 1_000 ** letterIndex),
|
||||
1
|
||||
1,
|
||||
)}${letter}`;
|
||||
}
|
||||
}
|
||||
@@ -1085,7 +1087,7 @@ function createOklchToRGBA() {
|
||||
return rgb.map((c) =>
|
||||
Math.abs(c) > 0.0031308
|
||||
? (c < 0 ? -1 : 1) * (1.055 * Math.abs(c) ** (1 / 2.4) - 0.055)
|
||||
: 12.92 * c
|
||||
: 12.92 * c,
|
||||
);
|
||||
}
|
||||
/**
|
||||
@@ -1097,7 +1099,7 @@ function createOklchToRGBA() {
|
||||
1, 0.3963377773761749, 0.2158037573099136, 1, -0.1055613458156586,
|
||||
-0.0638541728258133, 1, -0.0894841775298119, -1.2914855480194092,
|
||||
]),
|
||||
lab
|
||||
lab,
|
||||
);
|
||||
const LMS = /** @type {[number, number, number]} */ (
|
||||
LMSg.map((val) => val ** 3)
|
||||
@@ -1108,7 +1110,7 @@ function createOklchToRGBA() {
|
||||
-0.0405757452148008, 1.112286803280317, -0.0717110580655164,
|
||||
-0.0763729366746601, -0.4214933324022432, 1.5869240198367816,
|
||||
]),
|
||||
LMS
|
||||
LMS,
|
||||
);
|
||||
}
|
||||
/**
|
||||
@@ -1121,7 +1123,7 @@ function createOklchToRGBA() {
|
||||
-0.9692436362808796, 1.8759675015077202, 0.04155505740717559,
|
||||
0.05563007969699366, -0.20397695888897652, 1.0569715142428786,
|
||||
],
|
||||
xyz
|
||||
xyz,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1144,8 +1146,8 @@ function createOklchToRGBA() {
|
||||
});
|
||||
const rgb = srgbLinear2rgb(
|
||||
xyz2rgbLinear(
|
||||
oklab2xyz(oklch2oklab(/** @type {[number, number, number]} */ (lch)))
|
||||
)
|
||||
oklab2xyz(oklch2oklab(/** @type {[number, number, number]} */ (lch))),
|
||||
),
|
||||
).map((v) => {
|
||||
return Math.max(Math.min(Math.round(v * 255), 255), 0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user