mirror of
https://github.com/samsonjs/spirit-tracker.git
synced 2026-03-25 09:25:51 +00:00
feat: UX Changes
This commit is contained in:
parent
6d737d7c22
commit
f912ce1ccc
1 changed files with 22 additions and 16 deletions
|
|
@ -914,10 +914,7 @@ export async function renderItem($app, skuInput) {
|
|||
// --- Compute marker values ---
|
||||
// Province medians: per-store mean over time, then median across stores (>=3 stores)
|
||||
const storeMeans = seriesSorted
|
||||
.map((s) => ({
|
||||
label: s.label,
|
||||
mean: weightedMeanByDuration(s.points, labels), // duration-weighted
|
||||
}))
|
||||
.map((s) => ({ label: s.label, mean: weightedMeanByDuration(s.points, labels) }))
|
||||
.filter((x) => Number.isFinite(x.mean));
|
||||
|
||||
const bcMeans = storeMeans.filter((x) => isBcStoreLabel(x.label));
|
||||
|
|
@ -936,15 +933,24 @@ export async function renderItem($app, skuInput) {
|
|||
}
|
||||
|
||||
// Target price: pick 3 lowest per-store mins (distinct stores), then average (>=3 stores)
|
||||
// Only show if there are at least 6 total unique price points (finite) across the chart.
|
||||
const uniquePricePoints = new Set(
|
||||
allVals
|
||||
.filter((v) => Number.isFinite(v))
|
||||
.map((v) => Math.round(v * 100)) // cents to avoid float noise
|
||||
);
|
||||
const hasEnoughUniquePoints = uniquePricePoints.size >= 6;
|
||||
|
||||
const storeMins = seriesSorted
|
||||
.map((s) => ({ label: s.label, min: minFinite(s.values) }))
|
||||
.filter((x) => Number.isFinite(x.min))
|
||||
.sort((a, b) => a.min - b.min);
|
||||
|
||||
if (storeMins.length >= 3) {
|
||||
if (hasEnoughUniquePoints && storeMins.length >= 3) {
|
||||
const t = (storeMins[0].min + storeMins[1].min + storeMins[2].min) / 3;
|
||||
if (Number.isFinite(t)) markers.push({ y: Math.round(t), text: "Target" });
|
||||
}
|
||||
|
||||
const markerYs = markers.map((m) => Number(m.y)).filter(Number.isFinite);
|
||||
|
||||
// helper: approximate font px size from a CSS font string (Chart uses one)
|
||||
|
|
|
|||
Loading…
Reference in a new issue