Ship data
The vessel's own data in one panel, with the compass at the center, the heading figures and position at the left, and the wind and current at the right.
On this page
Own ship data
Wind
Current
Code
import { ShipData, type ShipDataLabels } from "@bosunkit/components/ship-data";
import type { ReactElement } from "react";
export const description: string =
"Althea under way: heading 270°, course over ground 259° and no rate of turn, a position off the Norwegian coast, wind " +
"4.5 kn from 051° and a 2.0 kn current setting from 045°, the compass drawing each of them.";
export const LABELS: ShipDataLabels = {
heading: "HDG",
courseOverGround: "COG",
rateOfTurn: "ROT",
wind: "Wind",
current: "Current",
speed: "Speed",
direction: "Direction",
};
export default function Showcase(): ReactElement {
return (
<div style={{ width: "100%", maxWidth: 640 }}>
<ShipData
title="Own ship data"
labels={LABELS}
heading={270}
courseOverGround={259}
rateOfTurn={0}
position={{ latitude: 62.45983, longitude: 6.19923 }}
wind={{ speedKnots: 4.5, fromDirection: 51 }}
current={{ speedKnots: 2, fromDirection: 45 }}
/>
</div>
);
}
Ship data is a panel that answers the questions a watchkeeper asks first: where the bow points, where the vessel is going, how fast it is turning, where it is, and what the wind and the water are doing. It draws nothing of its own. It is a card holding the compass with the wind and the current drawn on it, the heading, course over ground and rate of turn as readouts, the wind and the current as two groups of readouts under section headings, and the position as text.
The panel lays out in three columns where it has room and in one where it has not. A value no sensor reports shows a dash, and the position a dash, so the layout does not move when a sensor returns. Every word is passed in, translated, and the units are symbols: degrees, degrees per minute and knots.
Examples
No data
Own ship data
Wind
Current
Code
import { ShipData } from "@bosunkit/components/ship-data";
import type { ReactElement } from "react";
import { LABELS } from "./showcase";
export const description: string =
"With no compass, no fix and no wind sensor the panel keeps its shape: every readout shows a dash and the position a dash, so nothing moves when a sensor returns.";
export default function NoData(): ReactElement {
return (
<div style={{ width: "100%", maxWidth: 640 }}>
<ShipData
title="Own ship data"
labels={LABELS}
heading={null}
courseOverGround={null}
rateOfTurn={null}
position={null}
wind={null}
current={null}
/>
</div>
);
}
Trust
A value the caller gives its trust is drawn as a reading: a stale or lost value
shows its age, a degraded one its reason, and one with a source opens it from the value. A value given no trust is a
plain readout, and a missing one a dash.
Own ship data
Wind
Current
Code
import { ShipData } from "@bosunkit/components/ship-data";
import type { ReactElement } from "react";
import { LABELS } from "./showcase";
export const description: string =
"The heading from a compass that stopped 3 min ago, and a position last fixed 8 min ago: each value the caller gives its trust is drawn as a reading, with its age, and the position says when it was last seen.";
export default function Trust(): ReactElement {
return (
<div style={{ width: "100%", maxWidth: 640 }}>
<ShipData
title="Own ship data"
labels={LABELS}
heading={270}
courseOverGround={259}
rateOfTurn={0}
position={{ latitude: 62.45983, longitude: 6.19923 }}
wind={{ speedKnots: 4.5, fromDirection: 51 }}
current={{ speedKnots: 2, fromDirection: 45 }}
trust={{
heading: { integrity: "stale", ageSeconds: 190, source: "Fluxgate compass" },
courseOverGround: { integrity: "fresh", source: "GPS" },
position: { integrity: "invalid", ageSeconds: 480 },
}}
/>
</div>
);
}
Small face
Own ship data
Wind
Current
Code
import { ShipData } from "@bosunkit/components/ship-data";
import type { ReactElement } from "react";
import { LABELS } from "./showcase";
export const description: string =
"`faceDiameter` of 140 for a panel in a narrower column, with the title one level down under a page heading.";
export default function SmallFace(): ReactElement {
return (
<div style={{ width: "100%", maxWidth: 520 }}>
<ShipData
title="Own ship data"
labels={LABELS}
headingLevel={3}
faceDiameter={140}
heading={47}
courseOverGround={52}
rateOfTurn={8}
position={{ latitude: 50.1421, longitude: -5.0517 }}
wind={{ speedKnots: 14, fromDirection: 310 }}
current={{ speedKnots: 1.2, fromDirection: 190 }}
/>
</div>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| titlerequired | string | – | The panel's title ("Own ship data"), translated by the caller. |
| labelsrequired | ShipDataLabels | – | The words the readouts and the two groups carry. |
| headingrequired | number | null | – | The vessel's heading in degrees true, or null when no compass reports it. |
| courseOverGroundrequired | number | null | – | The course over ground in degrees true, or null. |
| rateOfTurnrequired | number | null | – | The rate of turn in degrees per minute, positive to starboard, or null. |
| positionrequired | Position | null | – | The vessel's position, or null when no fix is held. |
| windrequired | ShipDataFlow | null | – | The wind the vessel feels, as it is measured, or null when there is no wind sensor. |
| currentrequired | ShipDataFlow | null | – | The current under the vessel, or null when none is known. |
| trust | Partial<Record<ShipDataValue, ShipDataTrust>> | undefined | – | How far each value can be trusted. A value given its trust is drawn as a Reading, with its age and its integrity treatment; a value without one is a plain readout, and a missing one a dash. |
| faceDiameter | number | undefined | 200 | The compass face's diameter in pixels; 200 by default. |
| headingLevel | NestedHeadingLevel | undefined | – | The heading level of the title, as the card sets it. |
| className | string | undefined | – | Added to the panel's classes. |
| testId | string | undefined | – | Becomes data-testid on the panel. |
| ref | Ref<HTMLElement> | undefined | – | The panel element. |