Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: show start to end for datetimes in col summary (#4637)

Shahmir Varqha935eaa210560
diff --git a/frontend/src/components/data-table/__tests__/__snapshots__/chart-spec-model.test.ts.snap b/frontend/src/components/data-table/__tests__/__snapshots__/chart-spec-model.test.ts.snap
index afaa4de6d9..97a479ef27 100644
--- a/frontend/src/components/data-table/__tests__/__snapshots__/chart-spec-model.test.ts.snap
+++ b/frontend/src/components/data-table/__tests__/__snapshots__/chart-spec-model.test.ts.snap
@@ -317,10 +317,21 @@ exports[`ColumnChartSpecModel > snapshot > url data 1`] = `
},
"tooltip": [
{
- "bin": true,
- "field": "date",
+ "bin": {
+ "binned": true,
+ },
+ "field": "bin_maxbins_10_date",
+ "format": "%Y-%m-%d",
+ "title": "date (start)",
+ "type": "temporal",
+ },
+ {
+ "bin": {
+ "binned": true,
+ },
+ "field": "bin_maxbins_10_date_end",
"format": "%Y-%m-%d",
- "title": "date",
+ "title": "date (end)",
"type": "temporal",
},
{
diff --git a/frontend/src/components/data-table/chart-spec-model.tsx b/frontend/src/components/data-table/chart-spec-model.tsx
index a2d2da167c..05738a3ba8 100644
--- a/frontend/src/components/data-table/chart-spec-model.tsx
+++ b/frontend/src/components/data-table/chart-spec-model.tsx
@@ -109,7 +109,14 @@ export class ColumnChartSpecModel<T> {
switch (type) {
case "date":
case "datetime":
- case "time":
+ case "time": {
+ const format =
+ type === "date"
+ ? "%Y-%m-%d"
+ : type === "time"
+ ? "%H:%M:%S"
+ : "%Y-%m-%dT%H:%M:%S";
+
return {
...base,
// Two layers: one with the visible bars, and one with invisible bars
@@ -159,16 +166,19 @@ export class ColumnChartSpecModel<T> {
y: { aggregate: "max", type: "quantitative", axis: null },
tooltip: [
{
- field: column,
+ // Can also use column, but this is more explicit
+ field: `bin_maxbins_10_${column}`,
type: "temporal",
- format:
- type === "date"
- ? "%Y-%m-%d"
- : type === "time"
- ? "%H:%M:%S"
- : "%Y-%m-%dT%H:%M:%S",
- bin: true,
- title: column,
+ format: format,
+ bin: { binned: true },
+ title: `${column} (start)`,
+ },
+ {
+ field: `bin_maxbins_10_${column}_end`,
+ type: "temporal",
+ format: format,
+ bin: { binned: true },
+ title: `${column} (end)`,
},
{
aggregate: "count",
@@ -189,6 +199,7 @@ export class ColumnChartSpecModel<T> {
},
],
};
+ }
case "integer":
case "number": {
// Create a histogram spec that properly handles null values