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.

improve: show column summary histogram axes (#4208)

Akshay Agrawal984af117b0ec
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 315591947b..2d22240074 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
@@ -23,10 +23,7 @@ exports[`ColumnChartSpecModel > snapshot > array 1`] = `
{
"encoding": {
"x": {
- "axis": null,
- "bin": {
- "maxbins": 10,
- },
+ "bin": true,
"field": "a",
"type": "quantitative",
},
@@ -59,10 +56,12 @@ exports[`ColumnChartSpecModel > snapshot > array 1`] = `
},
],
"x": {
- "axis": null,
- "bin": {
- "maxbins": 10,
+ "axis": {
+ "labelExpr": "(datum.value >= 10000 || datum.value <= -10000) ? format(datum.value, '.2e') : datum.value",
+ "labelFontSize": 8,
+ "title": null,
},
+ "bin": true,
"field": "a",
"type": "quantitative",
},
@@ -111,10 +110,7 @@ exports[`ColumnChartSpecModel > snapshot > csv data 1`] = `
{
"encoding": {
"x": {
- "axis": null,
- "bin": {
- "maxbins": 10,
- },
+ "bin": true,
"field": "a",
"type": "quantitative",
},
@@ -147,10 +143,12 @@ exports[`ColumnChartSpecModel > snapshot > csv data 1`] = `
},
],
"x": {
- "axis": null,
- "bin": {
- "maxbins": 10,
+ "axis": {
+ "labelExpr": "(datum.value >= 10000 || datum.value <= -10000) ? format(datum.value, '.2e') : datum.value",
+ "labelFontSize": 8,
+ "title": null,
},
+ "bin": true,
"field": "a",
"type": "quantitative",
},
@@ -199,10 +197,7 @@ exports[`ColumnChartSpecModel > snapshot > csv string 1`] = `
{
"encoding": {
"x": {
- "axis": null,
- "bin": {
- "maxbins": 10,
- },
+ "bin": true,
"field": "a",
"type": "quantitative",
},
@@ -235,10 +230,12 @@ exports[`ColumnChartSpecModel > snapshot > csv string 1`] = `
},
],
"x": {
- "axis": null,
- "bin": {
- "maxbins": 10,
+ "axis": {
+ "labelExpr": "(datum.value >= 10000 || datum.value <= -10000) ? format(datum.value, '.2e') : datum.value",
+ "labelFontSize": 8,
+ "title": null,
},
+ "bin": true,
"field": "a",
"type": "quantitative",
},
diff --git a/frontend/src/components/data-table/chart-spec-model.tsx b/frontend/src/components/data-table/chart-spec-model.tsx
index 8229acb67a..b1ece4cfd2 100644
--- a/frontend/src/components/data-table/chart-spec-model.tsx
+++ b/frontend/src/components/data-table/chart-spec-model.tsx
@@ -209,8 +209,7 @@ export class ColumnChartSpecModel<T> {
x: {
field: column,
type: "quantitative",
- bin: { maxbins: 10 },
- axis: null,
+ bin: true,
},
y: {
aggregate: "count",
@@ -219,6 +218,8 @@ export class ColumnChartSpecModel<T> {
},
},
},
+
+ // Tooltip layer
{
mark: {
type: "bar",
@@ -228,8 +229,13 @@ export class ColumnChartSpecModel<T> {
x: {
field: column,
type: "quantitative",
- bin: { maxbins: 10 },
- axis: null,
+ bin: true,
+ axis: {
+ title: null,
+ labelFontSize: 8,
+ labelExpr:
+ "(datum.value >= 10000 || datum.value <= -10000) ? format(datum.value, '.2e') : datum.value",
+ },
},
y: {
aggregate: "max",
diff --git a/frontend/src/components/data-table/column-summary.tsx b/frontend/src/components/data-table/column-summary.tsx
index 42b140470b..fa8c62ac1c 100644
--- a/frontend/src/components/data-table/column-summary.tsx
+++ b/frontend/src/components/data-table/column-summary.tsx
@@ -116,26 +116,8 @@ export const TableColumnSummary = <TData, TValue>({
);
}
- if (
- typeof summary.min === "number" &&
- typeof summary.max === "number"
- ) {
- return (
- <div className="flex justify-between w-full whitespace-pre">
- <span>{prettyScientificNumber(summary.min)}</span>
- {summary.min === summary.max ? null : (
- <span>{prettyScientificNumber(summary.max)}</span>
- )}
- </div>
- );
- }
-
- return (
- <div className="flex justify-between w-full px-2 whitespace-pre">
- <span>{summary.min}</span>
- <span>{summary.max}</span>
- </div>
- );
+ // Numerical bar charts use built-in vega axis and ticks
+ return null;
case "boolean":
// Without a chart
if (!spec) {