@dschz/solid-uplot
Version:
SolidJS wrapper for uPlot — ultra-fast, tiny time-series & charting library
81 lines (78 loc) • 2.4 kB
TypeScript
type CursorPosition = {
/**
* The cursor position left offset in CSS pixels (relative to plotting area)
*/
readonly left: number;
/**
* The cursor position top offset in CSS pixels (relative to plotting area)
*/
readonly top: number;
};
/**
* The cursor index data for a given uPlot instance.
*/
type CursorData = {
/**
* The id of the plot instance that the cursor message originates from.
*/
readonly plotId: string;
/**
* The closest x-axis data index to cursor (closestIdx)
*/
readonly idx: number;
/**
* The x-axis value of the cursor idx.
*/
readonly xValue: number;
/**
* The position of the cursor.
*/
readonly position: CursorPosition;
/**
* The visibility of the cursor.
*/
readonly visible: boolean;
};
/**
* Get the cursor index data for a given uPlot instance.
*
* @param u - The uPlot instance.
* @returns The cursor data.
*/
declare const getCursorData: (u: uPlot) => CursorData | undefined;
/**
* Summary data for a given series.
*/
type SeriesDatum = {
/** The index of the series if you were treating this as a zero-indexed array */
readonly idx: number;
/** The index of the series in the uPlot instance */
readonly seriesIdx: number;
/** The display label of the series */
readonly label: string;
/** The series stroke color */
readonly stroke: string | CanvasGradient | CanvasPattern;
/** The fill color */
readonly fill: string | CanvasGradient | CanvasPattern;
/** The stroke width of the series line */
readonly width?: number;
/** The dash pattern used for the line */
readonly dash?: number[];
/** The name of the associated scale (e.g. "y", "y2") */
readonly scale?: string;
/** Whether the series is shown */
readonly visible?: boolean;
};
type GetSeriesDataOptions = {
/** The function to transform the series label */
readonly labelTransform?: (label?: string | HTMLElement) => string;
};
/**
* Get the y-series data for a given uPlot instance.
*
* @param u - The uPlot instance.
* @param options - The options for the series data.
* @returns The series data.
*/
declare const getSeriesData: (u: uPlot, options?: GetSeriesDataOptions) => SeriesDatum[];
export { type CursorData as C, type SeriesDatum as S, getSeriesData as a, getCursorData as g };