Collection
Industry / Factory · v0.2.0Validated
Compare production lines against the shift’s targets and see which factor is holding effectiveness back.
Production Line OEE · Preview
Loading widget…
Preparing source code…
Idle
Industry / Factory · v0.2.0Validated
Compare production lines against the shift’s targets and see which factor is holding effectiveness back.
Loading widget…
Preparing source code…
Load the Lumo theme once in your app entry point. The example uses the local Lumo workspace packages.
import "@lumo/tokens/tokens.css";
import { OeeRingWidget } from "@lumo/widgets/catalog/factory/oee-ring";
export default function Example() {
return <OeeRingWidget />;
}Props for integrating the React component in your app.
snapshotOeeSnapshot | null (optional){
"snapshot": {
"period": "06:00–14:00 shift",
"target": 0.82,
"factorTargets": {
"performance": 0.92
},
"lines": [
{
"id": "label-a",
"name": "Label line A",
"area": "Finishing",
"availability": 0.92,
"performance": 0.84,
"quality": 0.994,
"loss": "Short stops"
}
]
}
}"use client";
import { ArrowDown, Gauge } from "lucide-react";
import { useState } from "react";
import { useHorizontalSwipe } from "@lumo/hooks";
import { AnimatedNumber, Badge, WidgetCard, WidgetPagination } from "@lumo/ui";
import { MetricRings } from "../../shared/MetricRings";
import shared from "../../shared/operations-list.module.css";
import styles from "./oee-ring.module.css";
import { factors, oeeDemo } from "./oee-ring.constants";
import type { OeeSnapshot } from "./oee-ring.types";
export type { OeeSnapshot, OeeLine } from "./oee-ring.types";
const ratio = (value: number | null | undefined): value is number =>
typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
export function OeeRingWidget({ snapshot = oeeDemo }: { index?: number; snapshot?: OeeSnapshot | null } = {}) {
const [selected, setSelected] = useState<string>();
const lines = snapshot?.lines ?? [];
const page = Math.max(0, lines.findIndex(line => line.id === selected));
const line = lines[page];
const select = (next: number) => { if (lines[next]) setSelected(lines[next].id); };
const swipe = useHorizontalSwipe(direction => select(page + (direction === "left" ? 1 : -1)), lines.length > 1);
const pct = line && ratio(line.availability) && ratio(line.performance) && ratio(line.quality)
? line.availability * line.performance * line.quality * 100 : null;
const target = snapshot?.target;
const delta = pct !== null && ratio(target) ? pct - target * 100 : null;
const readings = line ? factors.map(factor => {
const value = line[factor.key];
const goal = snapshot?.factorTargets?.[factor.key];
return { ...factor, value: ratio(value) ? value : null, below: ratio(value) && ratio(goal) && value < goal };
}) : [];
return <WidgetCard title="OEE Rings" label="Overall equipment effectiveness" description={snapshot?.period} size="small"
icon={<Gauge />} className={shared.smallCard}>
{line ? <div {...swipe} data-studio-swipe-ignore className={styles.content}>
<div className={styles.headline}>
<MetricRings animateOnMount rings={readings.map(item => ({ id: item.key, progress: item.value ?? 0,
color: item.value === null ? "var(--text-muted)" : item.below ? "var(--warning)" : item.color }))} />
<div className={styles.reading}>
<strong>{line.name}</strong><span>{line.area}</span>
<div>{pct === null ? "Unavailable" : <><AnimatedNumber value={pct} decimals={1} blur={false} /><small>%</small></>}</div>
{delta !== null && <Badge tone={delta < 0 ? "warning" : "success"} size="sm">
{delta < 0 ? "" : "+"}{delta.toFixed(1)} pts vs target
</Badge>}
</div>
</div>
<dl className={styles.factors} data-widget-list>{readings.map(item => <div key={item.key} className={styles.factor}>
<dt>{item.name}{item.below && <span className={styles.srOnly}> below target</span>}</dt>
<dd data-below={item.below || undefined}>
{item.below && <ArrowDown size={11} aria-hidden="true" />}
{item.value === null ? "—" : <><AnimatedNumber value={item.value * 100} blur={false} decimals={1} />%</>}
</dd>
</div>)}</dl>
<span className={shared.muted}>{line.loss ? `Main loss · ${line.loss}` : "Main loss not reported"}</span>
<WidgetPagination page={page} count={lines.length} onChange={select} label="Production lines" pageLabel="Line"
pageLabels={lines.map(({ name }) => name)} />
</div> : <p className={shared.muted}>{snapshot ? "No production lines reported" : "Production data unavailable"}</p>}
</WidgetCard>;
}
lucide-reactmotionreactreact-dom