/
index.d.ts
249 lines (212 loc) · 7.28 KB
/
index.d.ts
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
import React from "react";
import * as OlapClient from "@datawheel/olap-client";
import * as I18N from "@datawheel/use-translation";
// tslint:disable-next-line:export-just-namespace
export = VizBldr;
export as namespace VizBldr;
declare namespace VizBldr {
const Vizbuilder: React.FC<VizbuilderProps>;
function buildQueryParams(
query: OlapClient.Query,
formatters?: ((measure: OlapClient.Measure | string) => Formatter) | Record<string, Formatter>
): QueryParams;
interface VizbuilderProps {
allowedChartTypes?: ChartType[];
chartLimits?: Optional<ChartLimits>;
className?: string;
datacap?: number;
defaultLocale?: string;
downloadFormats?: string[];
measureConfig?: Record<string, D3plusConfig> | ((measure: OlapClient.Measure) => D3plusConfig);
nonIdealState?: React.ComponentType,
queries: QueryResult | QueryResult[];
showConfidenceInt?: boolean;
toolbar?: React.ReactNode;
topojsonConfig?: Record<string, D3plusConfig> | ((level: OlapClient.Level) => D3plusConfig);
translations?: Record<string, Translation>;
userConfig?: D3plusConfig;
}
type Formatter = (value: number, locale: string) => string;
type D3plusConfig = {[key: string]: any};
interface ChartLimits {
/** Maximum number of bars in barchart */
BARCHART_MAX_BARS: number;
/** Maximum number of bars in a year barchart */
BARCHART_YEAR_MAX_BARS: number;
/** Max number of groups to be rendered in a donut or pie chart */
DONUT_SHAPE_MAX: number;
/** Minimum number of data points in groupto render a line in lineplot */
LINEPLOT_LINE_POINT_MIN: number;
/** Max number of lines to render in lineplot */
LINEPLOT_LINE_MAX: number;
/** Max shapes to render in stacked chart */
STACKED_SHAPE_MAX: number;
/** Min number of data members in the time dimension (e.g. number of years) required to render stacked area chart */
STACKED_TIME_MEMBER_MIN: number;
/** Max number of shapes to render in tree map */
TREE_MAP_SHAPE_MAX: number;
}
type ChartType =
| "barchart"
| "barchartyear"
| "donut"
| "geomap"
| "histogram"
| "lineplot"
| "pie"
| "stacked"
| "treemap";
interface QueryResult {
cube: OlapClient.PlainCube;
dataset: any[];
params: QueryParams;
}
interface QueryParams {
booleans: Record<string, boolean | undefined>;
cuts: Struct.CutItem[];
drilldowns: Struct.DrilldownItem[];
filters: Struct.FilterItem[];
locale: string;
measures: Struct.MeasureItem[];
}
interface Translation extends I18N.TranslationDict {
"action_close": string;
"action_download": string;
"action_enlarge": string;
"action_retry": string;
"action_fileissue": string;
"aggregators": {
"avg": string,
"max": string,
"min": string
};
"chart_labels": {
"ci": string;
"collection": string;
"moe": string;
"source": string;
};
"error": {
"detail": string;
"message": string;
"title": string;
};
"nonidealstate_msg"?: string;
"sentence_connectors": {
"and": string;
};
"title": {
"of_selected_cut_members": string;
"top_drilldowns": string;
"by_drilldowns": string;
"over_time": string;
"measure_and_modifier": string;
"total": string;
}
}
namespace Struct {
interface CutItem {
dimension?: string;
hierarchy?: string;
level: string;
members: string[];
exclude?: boolean;
}
interface DrilldownItem {
dimension?: string;
hierarchy?: string;
level: string;
properties?: string[];
caption?: string;
}
interface FilterItem {
constraint1: [OlapClient.Comparison, number];
constraint2?: [OlapClient.Comparison, number] | undefined;
formatter?: Formatter;
joint?: "and" | "or" | undefined;
measure: string;
}
interface MeasureItem {
collection?: string;
formatter?: Formatter;
lci?: string;
measure: string;
moe?: string;
source?: string;
uci?: string;
}
interface Datagroup {
cube: OlapClient.Cube;
cuts: Map<string, string[]>;
cutLevels: Map<string, OlapClient.Level>;
datacap: number;
dataset: any[];
drilldowns: OlapClient.Level[];
filters: FilterSet[];
geoDrilldown: OlapClient.Level | undefined;
locale: string;
maxPeriod: number | undefined;
measureSets: MeasureSet[];
members: Record<string, number[]> | Record<string, string[]>;
membersCount: Record<string, number>;
params: QueryParams;
stdDrilldowns: OlapClient.Level[];
timeDrilldown: OlapClient.Level | undefined;
topojsonConfig: D3plusConfig | undefined;
}
interface Chart {
chartType: ChartType;
/** The Datagroup object where this Chart comes from. */
dg: Datagroup;
/** Indicates if this Chart is intended to be presented as a map. */
isMap: boolean;
/** Indicates if this Chart has a dimension that shows variations over a period of time. Charts with a time axis don't count. */
isTimeline: boolean;
/** Indicates if this Chart only presents a few selected items from a much longer list, to simplify the interpretation. */
isTopTen?: boolean;
/** A string that uniquely identifies this chart in the context of the query it belongs to. */
key: string;
/** A list of the Levels shown in this Chart. */
levels: OlapClient.Level[];
/** The measure (and its associated error measures) shown in this chart. */
measureSet: MeasureSet;
}
interface FilterSet {
/** The measure set directly by the user. */
measure: OlapClient.Measure;
/** A formatting function to display values. */
formatter: Formatter;
/** Main constraint for the filter */
constraint1: [OlapClient.Comparison, number];
/** Additional constraint for the filter, associated to the same measure. */
constraint2?: [OlapClient.Comparison, number];
/** The joint condition for the constraints, only valid when both are defined. */
joint?: "and" | "or";
}
interface MeasureSet {
/** The measure set directly by the user. */
measure: OlapClient.Measure;
/** A formatting function to display values. */
formatter: Formatter;
/** */
collection: OlapClient.Measure | undefined;
/** */
source: OlapClient.Measure | undefined;
/** Margin of Error measure for the current measure. */
moe?: OlapClient.Measure;
/** The Lower Confidence Interval measure for the current measure. */
lci?: OlapClient.Measure;
/** The Upper Confidence Interval measure for the current measure. */
uci?: OlapClient.Measure;
}
}
interface UIParams {
currentChart: string;
isSingleChart: boolean;
isUniqueChart: boolean;
measureConfig: (measure: OlapClient.Measure) => D3plusConfig;
showConfidenceInt: boolean;
translate: I18N.TranslateFunction;
userConfig: D3plusConfig;
}
}