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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
improvement: set maximum bar width with column summaries (#2292)
Myles Scolnickd33022b66b16
diff --git a/frontend/src/components/data-table/chart-spec-model.tsx b/frontend/src/components/data-table/chart-spec-model.tsxindex eccea16c8b..562382df7a 100644--- a/frontend/src/components/data-table/chart-spec-model.tsx+++ b/frontend/src/components/data-table/chart-spec-model.tsx@@ -5,6 +5,18 @@ import type { ColumnHeaderSummary, FieldTypes } from "./types";import { asURL } from "@/utils/url";const MAX_BAR_HEIGHT = 24; // px+const MAX_BAR_WIDTH = 28; // px+const CONTAINER_WIDTH = 120; // px+const PAD = 1; // px+const VARIABLE_WIDTH = `min(${MAX_BAR_WIDTH}, ${CONTAINER_WIDTH} / length(data('source_0')) - ${PAD})`;++const scale = {+ align: 0,+ paddingInner: 0,+ paddingOuter: {+ expr: "length(data('source_0')) == 2 ? 1 : length(data('source_0')) == 3 ? 0.5 : length(data('source_0')) == 4 ? 0 : 0",+ },+};export class ColumnChartSpecModel<T> {private columnSummaries = new Map<string | number, ColumnHeaderSummary>();@@ -61,9 +73,19 @@ export class ColumnChartSpecModel<T> {case "date":return {...base,- mark: { type: "bar", color: mint.mint11 },+ mark: {+ type: "bar",+ color: mint.mint11,+ width: { expr: VARIABLE_WIDTH },+ },encoding: {- x: { field: column, type: "temporal", axis: null, bin: true },+ x: {+ field: column,+ type: "temporal",+ axis: null,+ bin: true,+ scale: scale,+ },y: { aggregate: "count", type: "quantitative", axis: null },tooltip: [{@@ -95,9 +117,20 @@ export class ColumnChartSpecModel<T> {const format = type === "integer" ? ",d" : ".2f";return {...base,- mark: { type: "bar", color: mint.mint11 },+ mark: {+ type: "bar",+ color: mint.mint11,+ size: { expr: VARIABLE_WIDTH },+ align: "right",+ },encoding: {- x: { field: column, type: "nominal", axis: null, bin: true },+ x: {+ field: column,+ type: "nominal",+ axis: null,+ bin: true,+ scale: scale,+ },y: {aggregate: "count",type: "quantitative",