Add date granularity and timezone and first day of the week to graphs (#15543)
- Allow users to choose the date granularity of the x axis and the group by of the y axis on a bar chart - Display those options conditionally - Store timezones in graphs: each graph has its own timezone, defaults to the user timezone. There will be a picker in the v2 to choose the timezone. For now the timezone is not used by the backend, but it will be used in filters and in group by queries. - Store first day of the week https://github.com/user-attachments/assets/66a5d156-dd93-4ebe-8c8f-d172f93e25be
This commit is contained in:
@@ -16,6 +16,8 @@ import { type GraphWidgetFieldSelection } from '@/page-layout/types/GraphWidgetF
|
||||
const createDefaultGraphConfiguration = (
|
||||
graphType: GraphType,
|
||||
fieldSelection?: GraphWidgetFieldSelection,
|
||||
timezone?: string,
|
||||
firstDayOfTheWeek?: number,
|
||||
): WidgetConfiguration | null => {
|
||||
switch (graphType) {
|
||||
case GraphType.AGGREGATE:
|
||||
@@ -28,6 +30,8 @@ const createDefaultGraphConfiguration = (
|
||||
aggregateFieldMetadataId: fieldSelection.aggregateFieldMetadataId,
|
||||
aggregateOperation: AggregateOperations.COUNT,
|
||||
displayDataLabel: true,
|
||||
timezone,
|
||||
firstDayOfTheWeek,
|
||||
};
|
||||
|
||||
case GraphType.PIE:
|
||||
@@ -51,6 +55,8 @@ const createDefaultGraphConfiguration = (
|
||||
aggregateOperation: AggregateOperations.SUM,
|
||||
primaryAxisOrderBy: GraphOrderBy.FIELD_ASC,
|
||||
axisNameDisplay: AxisNameDisplay.NONE,
|
||||
timezone,
|
||||
firstDayOfTheWeek,
|
||||
};
|
||||
|
||||
case GraphType.HORIZONTAL_BAR:
|
||||
@@ -71,6 +77,8 @@ const createDefaultGraphConfiguration = (
|
||||
aggregateOperation: AggregateOperations.SUM,
|
||||
primaryAxisOrderBy: GraphOrderBy.FIELD_ASC,
|
||||
axisNameDisplay: AxisNameDisplay.NONE,
|
||||
timezone,
|
||||
firstDayOfTheWeek,
|
||||
};
|
||||
|
||||
case GraphType.LINE:
|
||||
@@ -92,6 +100,8 @@ type CreateDefaultGraphWidgetParams = {
|
||||
gridPosition: GridPosition;
|
||||
objectMetadataId?: string | null;
|
||||
fieldSelection?: GraphWidgetFieldSelection;
|
||||
timezone?: string;
|
||||
firstDayOfTheWeek?: number;
|
||||
};
|
||||
|
||||
export const createDefaultGraphWidget = ({
|
||||
@@ -102,6 +112,8 @@ export const createDefaultGraphWidget = ({
|
||||
gridPosition,
|
||||
objectMetadataId,
|
||||
fieldSelection,
|
||||
timezone,
|
||||
firstDayOfTheWeek,
|
||||
}: CreateDefaultGraphWidgetParams): PageLayoutWidget => {
|
||||
const resolvedObjectMetadataId =
|
||||
fieldSelection?.objectMetadataId ?? objectMetadataId ?? null;
|
||||
@@ -109,6 +121,8 @@ export const createDefaultGraphWidget = ({
|
||||
const configuration = createDefaultGraphConfiguration(
|
||||
graphType,
|
||||
fieldSelection,
|
||||
timezone,
|
||||
firstDayOfTheWeek,
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user