Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/helpers/figures/charts/smart_chart_engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function buildSingleColumnChart(column: ColumnInfo, getters: Getters): ChartDefi
* columns left to right, and is as follows:
* - any type + percentage columns: pie chart
* - number + number columns: scatter chart
* - date + number columns: line chart
* - date + number columns: calendar chart
* - text + number columns: treemap if repetition in labels
* - any other combination: bar chart
*/
Expand Down Expand Up @@ -198,14 +198,16 @@ function buildTwoColumnChart(columns: ColumnInfo[], getters: Getters): ChartDefi
};
}

// TODO: Handle date + number with calendar chart when implemented (and change the docstring)
if (columns[0].type === "date" && columns[1].type === "number") {
return {
...DEFAULT_LINE_CHART_CONFIG,
type: "line",
type: "calendar",
dataSets: [{ dataRange: getUnboundRange(getters, columns[1].zone) }],
labelRange: getUnboundRange(getters, columns[0].zone),
dataSetsHaveTitle: isDatasetTitled(getters, columns[0]),
title: {},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functionally speaking, I am not convinced at all. If I want to see a day-to-day evolution of the sales of my shop, I would not be happy seeing a calendar chart which would make 0 sense.
Assuming that we want that feature, it should at least look for dates that span over several days, otherwise it becomes really pointless

legendPosition: "none",
horizontalGroupBy: "day_of_week",
verticalGroupBy: "month_number",
};
}

Expand Down
2 changes: 1 addition & 1 deletion tests/figures/chart/menu_item_insert_chart.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ describe("Smart chart type detection", () => {
[["number", "percentage"], { type: "pie" }],
[["date", "percentage"], { type: "pie" }],
[["number", "number"], { type: "scatter" }],
[["date", "number"], { type: "line" }],
[["date", "number"], { type: "calendar" }],
[["text", "number"], { type: "bar" }],
[["text_repeated", "number"], { type: "treemap" }],
[["text", "date"], { type: "bar" }],
Expand Down