This library is great, but it was a struggle to get going with TS. Here is what I have so far:
declare module 'svg-gauge' {
export interface Instance {
setMaxValue: (max: number) => void
setValue: (val: number) => void
setValueAnimated: (val: number, duration: number) => void
getValue: () => number
}
export interface Opts {
viewBox: string
/**
* The angle in degrees to start the dial
* @default 135
*/
dialStartAngle?: number
/** The angle in degrees to end the dial. This MUST be less than dialStartAngle
* @default 45
*/
dialEndAngle?: number
/** The radius of the gauge
* @default 40
*/
radius?: number
/** The minimum value for the gauge. This can be a negative value
* @default 0
*/
min?: number
/** The maximum value for the gauge
* @default 100
*/
max?: number
/** Getter for the label that will be rendered in the center. */
label?: (currentValue: number) => string
/** Whether to show the value at the center of the gauge
* @default true
*/
showValue?: boolean
/** The CSS class of the gauge
* @default 'gauge'
*/
gaugeClass?: string
/** The CSS class of the gauge's dial
* @default 'dial'
*/
dialClass?: string
/** The CSS class of the gauge's fill
* @default 'value'
*/
valueDialClass?: string
/** The CSS class of the gauge's text
* @default '(value-text)'
*/
valueClass?: string
/**
* An optional function that can return a color for current value
*/
color?: (currentValue: number) => string
/** An optional string that specifies the crop region
* @default '(0 0 100 100)'
*/
viewBox?: string
}
export = (element: HTMLDivElement, props: Partial<Opts>) => Instance
}
Then for usage, the provided React example converted to use these types
This library is great, but it was a struggle to get going with TS. Here is what I have so far:
Then for usage, the provided React example converted to use these types
I'm rather unfamiliar with the library, so i could be way off. This is just what I have so far and is working for my simplistic use case.