svgchrt
Version:
A way to easily create SVG-based charts without having to worry about positioning of titles, subtitles or legends.
152 lines • 4.09 kB
TypeScript
export interface PaddingandMargin extends Record<string, number> {
top: number;
right: number;
bottom: number;
left: number;
}
export interface Points extends Record<string, unknown> {
x1: number;
x2: number;
y1: number;
y2: number;
}
export interface CanvasLayout extends Record<string, unknown> {
height: number;
padding: PaddingandMargin;
width: number;
}
export interface ChartArea extends Record<string, unknown> {
height: number;
points: Points;
width: number;
}
export interface ChartLayout extends ChartArea {
margin: PaddingandMargin;
}
export declare type LegendLayout = ChartLayout;
export declare type SubtitleLayout = ChartLayout;
export declare type TitleLayout = ChartLayout;
export interface LayoutObject extends Record<string, unknown> {
get: () => LayoutObject;
set: (propChain: string, newState: unknown) => void;
canvas: CanvasLayout;
chart: ChartLayout;
legend: LegendLayout;
subtitle: SubtitleLayout;
title: TitleLayout;
}
export declare enum LegendItemIconShape {
Circle = "circle",
Ellipse = "ellipse",
Line = "line",
Path = "path",
Polygon = "polygon",
Polyline = "polyline",
Rect = "rect"
}
export interface LegendItemIcon extends Record<string, unknown> {
cx?: number;
cy?: number;
d?: string;
display: boolean;
height?: number;
r?: number;
rx?: number;
ry?: number;
shape: LegendItemIconShape;
width?: number;
}
export interface LegendItem extends Record<string, unknown> {
class?: string;
displayName: string;
icon?: LegendItemIcon;
id?: string;
}
export interface LegendBackground extends Record<string, unknown> {
display: boolean;
colour?: string;
r?: number;
rx?: number;
ry?: number;
}
export declare enum LegendOrientation {
Horizontal = "horizontal",
Vertical = "vertical"
}
export declare enum LegendPosition {
TopLeft = "top-left",
Top = "top",
TopRight = "top-right",
Right = "right",
BottomRight = "bottom-right",
Bottom = "bottom",
BottomLeft = "bottom-left",
Left = "left"
}
export interface LegendSettings extends Record<string, unknown> {
background: LegendBackground;
displaceTitle: boolean;
display: boolean;
icons: LegendItemIcon;
itemMargin: PaddingandMargin;
items: LegendItem[];
layOverChart: boolean;
margin: PaddingandMargin;
orientation: LegendOrientation;
padding: PaddingandMargin;
position: LegendPosition;
title: string;
}
export interface CanvasSettings extends Record<string, unknown> {
height: number;
padding: PaddingandMargin;
viewBox: string;
width: number;
}
export interface ChartSettings extends Record<string, unknown> {
margin: PaddingandMargin;
}
export interface TitleSettings extends Record<string, unknown> {
display: boolean;
margin: PaddingandMargin;
text: string;
}
export interface TitleAppendage extends Record<string, unknown> {
append: boolean;
join: string;
}
export interface SubtitleSettings extends TitleSettings {
appendToTitle: TitleAppendage;
}
export interface SettingsObject extends Record<string, unknown> {
background: boolean;
canvas: CanvasSettings;
chart: ChartSettings;
description: string;
id: string;
legend: LegendSettings;
subtitle: SubtitleSettings;
target: string;
title: TitleSettings;
}
export interface ReturnedCanvas {
canvas: SVGElement;
chartArea: SVGGraphicsElement;
}
export interface Caller {
layout: LayoutObject;
settings: SettingsObject;
target: HTMLElement;
}
export declare type Datum<T> = Record<string, T>;
export interface SCInterface {
canvas: SVGElement | null;
chartArea: SVGGraphicsElement | null;
defaultSettings: SettingsObject;
layout: LayoutObject;
settings: SettingsObject;
target: HTMLElement;
data: Record<string, unknown>[];
plot: (caller: SCInterface, settings: SettingsObject, data: Datum<unknown>[]) => void;
}
//# sourceMappingURL=interfaces.d.ts.map