@lightdash/common 0.1372.0 → 0.1372.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler/translator.js +8 -0
- package/dist/schemas/json/lightdash-dbt-2.0.json +21 -0
- package/dist/types/dbt.d.ts +4 -0
- package/dist/types/table.d.ts +5 -0
- package/dist/utils/item.d.ts +4 -0
- package/dist/visualizations/CartesianChartDataModel.d.ts +1 -0
- package/dist/visualizations/CartesianChartDataModel.js +18 -0
- package/package.json +1 -1
@@ -333,6 +333,14 @@ const convertTable = (adapterType, model, dbtMetrics, startOfWeek) => {
|
|
333
333
|
requiredFilters: (0, filterGrammar_1.parseFilters)(meta.required_filters),
|
334
334
|
requiredAttributes: meta.required_attributes,
|
335
335
|
groupDetails,
|
336
|
+
...(meta.default_time_dimension
|
337
|
+
? {
|
338
|
+
defaultTimeDimension: {
|
339
|
+
field: meta.default_time_dimension.field,
|
340
|
+
interval: meta.default_time_dimension.interval,
|
341
|
+
},
|
342
|
+
}
|
343
|
+
: {}),
|
336
344
|
};
|
337
345
|
};
|
338
346
|
exports.convertTable = convertTable;
|
@@ -165,6 +165,27 @@
|
|
165
165
|
"required": ["type", "sql"]
|
166
166
|
}
|
167
167
|
}
|
168
|
+
},
|
169
|
+
"default_time_dimension": {
|
170
|
+
"type": "object",
|
171
|
+
"description": "Specifies the default time dimension field and interval to use for time-based analysis (on any metric in the model). If specified, both field and interval are required.",
|
172
|
+
"properties": {
|
173
|
+
"field": {
|
174
|
+
"type": "string",
|
175
|
+
"description": "The name of the field to use as the default time dimension"
|
176
|
+
},
|
177
|
+
"interval": {
|
178
|
+
"type": "string",
|
179
|
+
"enum": [
|
180
|
+
"DAY",
|
181
|
+
"WEEK",
|
182
|
+
"MONTH",
|
183
|
+
"YEAR"
|
184
|
+
],
|
185
|
+
"description": "The default time interval to use when analyzing this time dimension"
|
186
|
+
}
|
187
|
+
},
|
188
|
+
"required": ["field", "interval"]
|
168
189
|
}
|
169
190
|
}
|
170
191
|
},
|
package/dist/types/dbt.d.ts
CHANGED
@@ -60,6 +60,10 @@ type DbtModelLightdashConfig = {
|
|
60
60
|
}[];
|
61
61
|
required_attributes?: Record<string, string | string[]>;
|
62
62
|
group_details?: Record<string, DbtModelGroup>;
|
63
|
+
default_time_dimension?: {
|
64
|
+
field: string;
|
65
|
+
interval: TimeFrames;
|
66
|
+
};
|
63
67
|
};
|
64
68
|
export type DbtModelGroup = {
|
65
69
|
label: string;
|
package/dist/types/table.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { type MetricFilterRule } from './filter';
|
2
|
+
import type { TimeFrames } from './timeFrames';
|
2
3
|
export declare enum OrderFieldsByStrategy {
|
3
4
|
LABEL = "LABEL",
|
4
5
|
INDEX = "INDEX"
|
@@ -22,4 +23,8 @@ export type TableBase = {
|
|
22
23
|
hidden?: boolean;
|
23
24
|
requiredAttributes?: Record<string, string | string[]>;
|
24
25
|
groupDetails?: Record<string, GroupType>;
|
26
|
+
defaultTimeDimension?: {
|
27
|
+
field: string;
|
28
|
+
interval: TimeFrames;
|
29
|
+
};
|
25
30
|
};
|
package/dist/utils/item.d.ts
CHANGED
@@ -30,6 +30,10 @@ export declare const replaceDimensionInExplore: (explore: Explore, dimension: Co
|
|
30
30
|
hidden?: boolean | undefined;
|
31
31
|
requiredAttributes?: Record<string, string | string[]> | undefined;
|
32
32
|
groupDetails?: Record<string, import("..").GroupType> | undefined;
|
33
|
+
defaultTimeDimension?: {
|
34
|
+
field: string;
|
35
|
+
interval: import("..").TimeFrames;
|
36
|
+
} | undefined;
|
33
37
|
metrics: Record<string, import("../types/field").CompiledMetric>;
|
34
38
|
lineageGraph: import("..").LineageGraph;
|
35
39
|
source?: import("../types/field").Source | undefined;
|
@@ -17,6 +17,7 @@ export declare class CartesianChartDataModel {
|
|
17
17
|
type?: CartesianChartKind;
|
18
18
|
});
|
19
19
|
static getTooltipFormatter(format: Format | undefined): ((value: number) => string) | undefined;
|
20
|
+
static getValueFormatter(format: Format | undefined): ((params: any) => string) | undefined;
|
20
21
|
mergeConfig(chartKind: CartesianChartKind, existingConfig: VizCartesianChartConfig | undefined): VizCartesianChartConfig;
|
21
22
|
getChartOptions(): VizCartesianChartOptions;
|
22
23
|
getDefaultLayout(): PivotChartLayout | undefined;
|
@@ -27,6 +27,7 @@ class CartesianChartDataModel {
|
|
27
27
|
this.fieldConfig = args.fieldConfig ?? defaultFieldConfig;
|
28
28
|
this.type = args.type ?? savedCharts_1.ChartKind.VERTICAL_BAR;
|
29
29
|
}
|
30
|
+
// Get the formatter for the tooltip, which has a simple callback signature
|
30
31
|
static getTooltipFormatter(format) {
|
31
32
|
if (format === field_1.Format.PERCENT) {
|
32
33
|
return (value) => (0, formatting_1.applyCustomFormat)(value, {
|
@@ -35,6 +36,20 @@ class CartesianChartDataModel {
|
|
35
36
|
}
|
36
37
|
return undefined;
|
37
38
|
}
|
39
|
+
// Get the formatter for the value label,
|
40
|
+
// which has more complex inputs
|
41
|
+
static getValueFormatter(format) {
|
42
|
+
if (format === field_1.Format.PERCENT) {
|
43
|
+
// Echarts doesn't export the types for this function
|
44
|
+
return (params) => {
|
45
|
+
const value = params.value[params.dimensionNames[params.encode.y[0]]];
|
46
|
+
return (0, formatting_1.applyCustomFormat)(value, {
|
47
|
+
type: field_1.CustomFormatType.PERCENT,
|
48
|
+
});
|
49
|
+
};
|
50
|
+
}
|
51
|
+
return undefined;
|
52
|
+
}
|
38
53
|
mergeConfig(chartKind, existingConfig) {
|
39
54
|
const newDefaultLayout = this.getDefaultLayout();
|
40
55
|
const someFieldsMatch = existingConfig?.fieldConfig?.x?.reference ===
|
@@ -314,6 +329,9 @@ class CartesianChartDataModel {
|
|
314
329
|
? {
|
315
330
|
show: seriesValueLabelPosition !== 'hidden',
|
316
331
|
position: seriesValueLabelPosition,
|
332
|
+
formatter: seriesFormat
|
333
|
+
? CartesianChartDataModel.getValueFormatter(seriesFormat)
|
334
|
+
: undefined,
|
317
335
|
}
|
318
336
|
: undefined,
|
319
337
|
labelLayout: {
|