-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstatical.d.ts
More file actions
138 lines (128 loc) · 3.91 KB
/
Copy pathstatical.d.ts
File metadata and controls
138 lines (128 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import { ScaleLinear } from "d3";
import { ScaleTime, Selection } from "d3";
declare global {
interface Chart {
chart?: Selection<SVGElement, any, null, undefined>;
limit?: number;
style: {
width: number;
height: number;
marginTop?: number;
marginBottom?: number;
marginLeft?: number;
marginRight?: number;
};
x?: {
scale?: ScaleTime<number, number>;
axis?: Selection<SVGGElement, any, null, undefined>;
style?: {
fontSize?: string;
fontFamily?: string;
};
};
y?: {
scale?: ScaleLinear<number, number>;
axis?: Selection<SVGGElement, any, null, undefined>;
style?: {
fontSize?: string;
fontFamily?: string;
};
};
lines: Line | Line[];
[key: string]: any;
}
interface Line {
base?: Selection<SVGPathElement, any, null, undefined>;
data?: {
date: number;
count: number;
}[];
color: string;
style?: {
strokeWidth?: number;
opacity?: number;
};
}
type ValueType = (value: number, element: HTMLElement) => string;
type Charts<T> = keyof {
[key in keyof T]: T[key] extends Chart ? T[key] : never;
};
var statical: EventTarget;
var dates: number[];
var DPMS: number;
var index: number;
var pastIndex: number;
var charts: {
startIndex?: number;
interval?: number;
limit?: number;
} & Record<string, Chart>;
var valueTypes: Record<string, ValueType>;
/**
* Smoothly animate a value from `start` to `end`
* @param {string | HTMLElement} element The element to animate the text of
* @param {number} start The starting value
* @param {number} end The ending value
* @param {Object} options
* @param {string} options.type The type of value to animate
* @param {string} options.prefix The prefix to add to the value
* @param {string} options.suffix The suffix to add to the value
* @param {number} options.duration The duration of the animation in milliseconds
*/
function animateValue(
element: string | HTMLElement,
start: number,
end: number,
options?: {
type?: keyof typeof valueTypes;
prefix?: string;
suffix?: string;
duration?: number;
}
): void;
/**
* Abbreviate a number to a shorter string
* @example abbreviate(123456789) => "123M"
* @param {string} count The number to abbreviate
* @param {number?} digits The number of digits to keep
* @returns {string} The abbreviated string
*/
function abbreviate(count: number, digits?: number): string;
/**
* Updates a chart's lines and avatars
* @param {string} chart The chart to update
* @param {number | number[]} newCounts The new counts to add to the chart
* @param {((chart: string, index) => void | undefined)} update The function to call to update additional content, such as avatars
*/
function updateChart(
chart: Charts<typeof charts>,
newCounts: number | number[],
update?: (chart: Charts<typeof charts>, index: number) => void
): void;
/**
* Calculate a bar's width
* @param {number} count This bar's count
* @param {number} firstCount The first bar's count
* @param {number} maxWidth The maximum width of the bar
* @returns {number} The width of the bar
*/
function calculateBarWidth(
count: number,
firstCount: number,
maxWidth: number
): number;
/**
* Get the `textContent` of an element
* @param {string | HTMLElement} element The element to get the `textContent` of
* @returns {string} The text content of the element
*/
function getText(element: string | HTMLElement): string;
/**
* Change the `textContent` of an element
* @param {string | HTMLElement} element The element to change the `textContent` of
* @param {string} text The new text content
*/
function changeText(element: string | HTMLElement, text: string): void;
function update(): void;
function animateCharts(): void;
}