The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Fixes static row chart ignores custom series names in its legend (#62473)
Aleksandr Lesnenko29a312d9ef69
diff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_RowChart_Default.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_RowChart_Default.pngindex b159a5b74b7..f39e540e9e6 100644Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_RowChart_Default.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_RowChart_Default.png differdiff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_RowChart_Metric_Column_With_Scaling.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_RowChart_Metric_Column_With_Scaling.pngindex b5ee3348854..4fc4ef18ab7 100644Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_RowChart_Metric_Column_With_Scaling.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_RowChart_Metric_Column_With_Scaling.png differdiff --git a/.loki/reference/chrome_laptop_Viz_Static_Viz_RowChart_Watermark.png b/.loki/reference/chrome_laptop_Viz_Static_Viz_RowChart_Watermark.pngindex 0a77bf74ae3..d0d95d161be 100644Binary files a/.loki/reference/chrome_laptop_Viz_Static_Viz_RowChart_Watermark.png and b/.loki/reference/chrome_laptop_Viz_Static_Viz_RowChart_Watermark.png differdiff --git a/.loki/reference/chrome_laptop_viz_RowChart_Default.png b/.loki/reference/chrome_laptop_viz_RowChart_Default.pngdeleted file mode 100644index a814917a26a..00000000000Binary files a/.loki/reference/chrome_laptop_viz_RowChart_Default.png and /dev/null differdiff --git a/.loki/reference/chrome_laptop_viz_RowChart_With_Long_Names.png b/.loki/reference/chrome_laptop_viz_RowChart_With_Long_Names.pngdeleted file mode 100644index f220606dbd4..00000000000Binary files a/.loki/reference/chrome_laptop_viz_RowChart_With_Long_Names.png and /dev/null differdiff --git a/frontend/src/metabase/static-viz/components/RowChart/RowChart.stories.tsx b/frontend/src/metabase/static-viz/components/RowChart/RowChart.stories.tsxindex 07bbf348a28..f125c802ceb 100644--- a/frontend/src/metabase/static-viz/components/RowChart/RowChart.stories.tsx+++ b/frontend/src/metabase/static-viz/components/RowChart/RowChart.stories.tsx@@ -6,15 +6,18 @@ import {MULTIPLE_SERIES,} from "metabase/static-viz/components/RowChart/stories-data";-import RowChart, { type StaticRowChartProps } from "./RowChart";+import {+ type StaticChartProps,+ StaticVisualization,+} from "../StaticVisualization";export default {title: "Viz/Static Viz/RowChart",- component: RowChart,+ component: StaticVisualization,};-const Template: StoryFn<StaticRowChartProps> = (args) => {- return <RowChart {...args} />;+const Template: StoryFn<StaticChartProps> = (args) => {+ return <StaticVisualization {...args} />;};export const Default = {diff --git a/frontend/src/metabase/static-viz/components/RowChart/RowChart.tsx b/frontend/src/metabase/static-viz/components/RowChart/RowChart.tsxindex 0db5b0a48d9..a0f7752d059 100644--- a/frontend/src/metabase/static-viz/components/RowChart/RowChart.tsx+++ b/frontend/src/metabase/static-viz/components/RowChart/RowChart.tsx@@ -1,5 +1,6 @@import { Group } from "@visx/group";+import type { StaticChartProps } from "metabase/static-viz/components/StaticVisualization";import {getColumnValueStaticFormatter,getLabelsStaticFormatter,@@ -19,23 +20,20 @@ import {trimData,} from "metabase/visualizations/shared/utils/data";import { getTwoDimensionalChartSeries } from "metabase/visualizations/shared/utils/series";-import type {- ColorGetter,- RemappingHydratedChartData,-} from "metabase/visualizations/types";+import type { RemappingHydratedChartData } from "metabase/visualizations/types";+import { getLegendItems } from "metabase/visualizations/visualizations/RowChart/utils/legend";import {getAxesVisibility,getLabelledSeries,+ getLabels,getXValueRange,} from "metabase/visualizations/visualizations/RowChart/utils/settings";-import type { DatasetData, VisualizationSettings } from "metabase-types/api";import Watermark from "../../watermark.svg?component";import { Legend } from "../Legend";import { calculateLegendRows } from "../Legend/utils";import { getStaticChartTheme } from "./theme";-import { getChartLabels } from "./utils/labels";const CHART_PADDING = 16;const LEGEND_FONT = {@@ -47,13 +45,6 @@ const LEGEND_FONT = {const WIDTH = 620;const HEIGHT = 440;-export interface StaticRowChartProps {- data: DatasetData;- settings: VisualizationSettings;- getColor: ColorGetter;- hasDevWatermark?: boolean;-}-const staticTextMeasurer: TextWidthMeasurer = (text: string,style: FontStyle,@@ -64,24 +55,27 @@ const staticTextMeasurer: TextWidthMeasurer = (style.weight ? parseInt(style.weight.toString(), 10) : 400,);-const StaticRowChart = ({- data,+export const StaticRowChart = ({+ rawSeries,settings,- getColor,+ renderingContext,+ width = WIDTH,+ height = HEIGHT,hasDevWatermark = false,-}: StaticRowChartProps) => {- const remappedColumnsData = extractRemappedColumns(- data,+}: StaticChartProps) => {+ const data = extractRemappedColumns(+ rawSeries[0].data,) as RemappingHydratedChartData;+ const { getColor } = renderingContext;const columnValueFormatter = getColumnValueStaticFormatter();const { chartColumns, series, seriesColors } = getTwoDimensionalChartSeries(- remappedColumnsData,+ data,settings,columnValueFormatter,);const groupedData = getGroupedDataset(- remappedColumnsData.rows,+ data.rows,chartColumns,settings,columnValueFormatter,@@ -93,30 +87,28 @@ const StaticRowChart = ({const tickFormatters = getStaticFormatters(chartColumns, settings);- const { xLabel, yLabel } = getChartLabels(chartColumns, settings);+ const { xLabel, yLabel } = getLabels(settings);+const { hasXAxis, hasYAxis } = getAxesVisibility(settings);const xValueRange = getXValueRange(settings);const labelledSeries = getLabelledSeries(settings, series);+ const legendItems = getLegendItems(series, seriesColors, settings);const legend = calculateLegendRows({- items: series.map((series) => ({- key: series.seriesKey,- name: series.seriesName,- color: seriesColors[series.seriesKey],- })),- width: WIDTH,+ items: legendItems,+ width,lineHeight: LEGEND_FONT.lineHeight,fontSize: LEGEND_FONT.size,fontWeight: LEGEND_FONT.weight,});const legendHeight = legend != null ? legend.height + CHART_PADDING : 0;- const fullChartHeight = HEIGHT + legendHeight;+ const fullChartHeight = height + legendHeight;return (<svgxmlns="http://www.w3.org/2000/svg"- width={WIDTH}+ width={width}height={fullChartHeight}fontFamily="Lato">@@ -130,8 +122,8 @@ const StaticRowChart = ({)}<Group top={legendHeight}><RowChart- width={WIDTH}- height={HEIGHT}+ width={width}+ height={height}data={groupedData}trimData={trimData}series={series}@@ -156,13 +148,10 @@ const StaticRowChart = ({x="0"y="0"height={fullChartHeight}- width={WIDTH}+ width={width}preserveAspectRatio="xMinYMin slice"/>)}</svg>);};--// eslint-disable-next-line import/no-default-export -- deprecated usage-export default StaticRowChart;diff --git a/frontend/src/metabase/static-viz/components/RowChart/index.ts b/frontend/src/metabase/static-viz/components/RowChart/index.tsindex e9896b0ad65..7864b3a75f1 100644--- a/frontend/src/metabase/static-viz/components/RowChart/index.ts+++ b/frontend/src/metabase/static-viz/components/RowChart/index.ts@@ -1,2 +1 @@-// eslint-disable-next-line import/no-default-export -- deprecated usage-export { default } from "./RowChart";+export { StaticRowChart } from "./RowChart";diff --git a/frontend/src/metabase/static-viz/components/RowChart/stories-data.ts b/frontend/src/metabase/static-viz/components/RowChart/stories-data.tsindex e9bd14240dd..3ab5092646e 100644--- a/frontend/src/metabase/static-viz/components/RowChart/stories-data.ts+++ b/frontend/src/metabase/static-viz/components/RowChart/stories-data.ts@@ -1,180 +1,203 @@-import type { StaticRowChartProps } from "metabase/static-viz/components/RowChart/RowChart";+import { color } from "metabase/lib/colors";+import {+ measureTextHeight,+ measureTextWidth,+} from "metabase/static-viz/lib/text";+import { DEFAULT_VISUALIZATION_THEME } from "metabase/visualizations/shared/utils/theme";+import type { RenderingContext } from "metabase/visualizations/types";-export const MULTIPLE_SERIES: StaticRowChartProps = {- settings: {- "graph.dimensions": ["CREATED_AT", "CATEGORY"],- column_settings: {- '["ref",["field",12,null]]': {- date_style: "MMMM D, YYYY",- date_abbreviate: true,- },- },- "graph.metrics": ["count"],- },- data: {- rows: [- ["2019-09-01T00:00:00+04:00", "Doohickey", 9],- ["2019-09-01T00:00:00+04:00", "Gadget", 13],- ["2019-09-01T00:00:00+04:00", "Gizmo", 21],- ["2019-09-01T00:00:00+04:00", "Widget", 14],- ["2019-10-01T00:00:00+04:00", "Doohickey", 102],- ["2019-10-01T00:00:00+04:00", "Gadget", 134],- ["2019-10-01T00:00:00+04:00", "Gizmo", 151],- ["2019-10-01T00:00:00+04:00", "Widget", 153],- ["2019-11-01T00:00:00+04:00", "Doohickey", 116],- ["2019-11-01T00:00:00+04:00", "Gadget", 165],- ["2019-11-01T00:00:00+04:00", "Gizmo", 127],- ["2019-11-01T00:00:00+04:00", "Widget", 134],- ["2019-12-01T00:00:00+04:00", "Doohickey", 100],- ["2019-12-01T00:00:00+04:00", "Gadget", 166],- ["2019-12-01T00:00:00+04:00", "Gizmo", 134],- ["2019-12-01T00:00:00+04:00", "Widget", 150],- ["2020-01-01T00:00:00+04:00", "Doohickey", 128],- ["2020-01-01T00:00:00+04:00", "Gadget", 155],- ["2020-01-01T00:00:00+04:00", "Gizmo", 146],- ["2020-01-01T00:00:00+04:00", "Widget", 151],- ["2020-02-01T00:00:00+04:00", "Doohickey", 114],- ["2020-02-01T00:00:00+04:00", "Gadget", 141],- ["2020-02-01T00:00:00+04:00", "Gizmo", 130],- ["2020-02-01T00:00:00+04:00", "Widget", 158],- ["2020-03-01T00:00:00+04:00", "Doohickey", 121],- ["2020-03-01T00:00:00+04:00", "Gadget", 140],- ["2020-03-01T00:00:00+04:00", "Gizmo", 137],- ["2020-03-01T00:00:00+04:00", "Widget", 129],- ["2020-04-01T00:00:00+04:00", "Doohickey", 73],- ["2020-04-01T00:00:00+04:00", "Gadget", 78],- ["2020-04-01T00:00:00+04:00", "Gizmo", 93],- ["2020-04-01T00:00:00+04:00", "Widget", 100],- ],- cols: [- {- description: "The date and time an order was submitted.",- semantic_type: "type/CreationTimestamp",- table_id: 2,- coercion_strategy: null,- unit: "month",- name: "CREATED_AT",- settings: {- date_style: "D MMMM, YYYY",- date_separator: "-",+import type { StaticChartProps } from "../StaticVisualization";++export const renderingContext: RenderingContext = {+ getColor: color,+ measureText: (text, style) =>+ measureTextWidth(text, Number(style.size), Number(style.weight)),+ measureTextHeight: (_, style) => measureTextHeight(Number(style.size)),+ fontFamily: "Lato",+ theme: DEFAULT_VISUALIZATION_THEME,+};++export const MULTIPLE_SERIES: StaticChartProps = {+ rawSeries: [+ {+ card: {+ id: 1,+ name: "Multiple Series Row Chart",+ display: "row",+ visualization_settings: {+ "graph.dimensions": ["CREATED_AT", "CATEGORY"],+ column_settings: {+ '["ref",["field",12,null]]': {+ date_style: "MMMM D, YYYY",+ date_abbreviate: true,+ },+ },+ "graph.metrics": ["count"],},- source: "breakout",- field_ref: [- "field",- 12,+ },+ data: {+ rows: [+ ["2019-09-01T00:00:00+04:00", "Doohickey", 9],+ ["2019-09-01T00:00:00+04:00", "Gadget", 13],+ ["2019-09-01T00:00:00+04:00", "Gizmo", 21],+ ["2019-09-01T00:00:00+04:00", "Widget", 14],+ ["2019-10-01T00:00:00+04:00", "Doohickey", 102],+ ["2019-10-01T00:00:00+04:00", "Gadget", 134],+ ["2019-10-01T00:00:00+04:00", "Gizmo", 151],+ ["2019-10-01T00:00:00+04:00", "Widget", 153],+ ["2019-11-01T00:00:00+04:00", "Doohickey", 116],+ ["2019-11-01T00:00:00+04:00", "Gadget", 165],+ ["2019-11-01T00:00:00+04:00", "Gizmo", 127],+ ["2019-11-01T00:00:00+04:00", "Widget", 134],+ ["2019-12-01T00:00:00+04:00", "Doohickey", 100],+ ["2019-12-01T00:00:00+04:00", "Gadget", 166],+ ["2019-12-01T00:00:00+04:00", "Gizmo", 134],+ ["2019-12-01T00:00:00+04:00", "Widget", 150],+ ["2020-01-01T00:00:00+04:00", "Doohickey", 128],+ ["2020-01-01T00:00:00+04:00", "Gadget", 155],+ ["2020-01-01T00:00:00+04:00", "Gizmo", 146],+ ["2020-01-01T00:00:00+04:00", "Widget", 151],+ ["2020-02-01T00:00:00+04:00", "Doohickey", 114],+ ["2020-02-01T00:00:00+04:00", "Gadget", 141],+ ["2020-02-01T00:00:00+04:00", "Gizmo", 130],+ ["2020-02-01T00:00:00+04:00", "Widget", 158],+ ["2020-03-01T00:00:00+04:00", "Doohickey", 121],+ ["2020-03-01T00:00:00+04:00", "Gadget", 140],+ ["2020-03-01T00:00:00+04:00", "Gizmo", 137],+ ["2020-03-01T00:00:00+04:00", "Widget", 129],+ ["2020-04-01T00:00:00+04:00", "Doohickey", 73],+ ["2020-04-01T00:00:00+04:00", "Gadget", 78],+ ["2020-04-01T00:00:00+04:00", "Gizmo", 93],+ ["2020-04-01T00:00:00+04:00", "Widget", 100],+ ],+ cols: [{- "temporal-unit": "month",+ description: "The date and time an order was submitted.",+ semantic_type: "type/CreationTimestamp",+ table_id: 2,+ coercion_strategy: null,+ unit: "month",+ name: "CREATED_AT",+ settings: {+ date_style: "D MMMM, YYYY",+ date_separator: "-",+ },+ source: "breakout",+ field_ref: [+ "field",+ 12,+ {+ "temporal-unit": "month",+ },+ ],+ effective_type: "type/DateTime",+ nfc_path: null,+ parent_id: null,+ id: 12,+ visibility_type: "normal",+ display_name: "Created At",+ base_type: "type/DateTime",},- ],- effective_type: "type/DateTime",- nfc_path: null,- parent_id: null,- id: 12,- visibility_type: "normal",- display_name: "Created At",- base_type: "type/DateTime",- },- {- description:- "The type of product, valid values include: Doohicky, Gadget, Gizmo and Widget",- semantic_type: "type/Category",- table_id: 1,- coercion_strategy: null,- name: "CATEGORY",- settings: null,- source: "breakout",- fk_field_id: 13,- field_ref: [- "field",- 4,{- "source-field": 13,+ description:+ "The type of product, valid values include: Doohicky, Gadget, Gizmo and Widget",+ semantic_type: "type/Category",+ table_id: 1,+ coercion_strategy: null,+ name: "CATEGORY",+ settings: null,+ source: "breakout",+ fk_field_id: 13,+ field_ref: [+ "field",+ 4,+ {+ "source-field": 13,+ },+ ],+ effective_type: "type/Text",+ nfc_path: null,+ parent_id: null,+ id: 4,+ visibility_type: "normal",+ display_name: "Product → Category",+ base_type: "type/Text",},- ],- effective_type: "type/Text",- nfc_path: null,- parent_id: null,- id: 4,- visibility_type: "normal",- display_name: "Product → Category",- base_type: "type/Text",- },- {- base_type: "type/BigInteger",- semantic_type: "type/Quantity",- name: "count",- display_name: "Count",- source: "aggregation",- field_ref: ["aggregation", 0],- effective_type: "type/BigInteger",- },- ],- native_form: {- query:- 'SELECT parsedatetime(formatdatetime("PUBLIC"."ORDERS"."CREATED_AT", \'yyyyMM\'), \'yyyyMM\') AS "CREATED_AT", "PRODUCTS__via__PRODUCT_ID"."CATEGORY" AS "PRODUCTS__via__PRODUCT_ID__CATEGORY", count(*) AS "count" FROM "PUBLIC"."ORDERS" LEFT JOIN "PUBLIC"."PRODUCTS" "PRODUCTS__via__PRODUCT_ID" ON "PUBLIC"."ORDERS"."PRODUCT_ID" = "PRODUCTS__via__PRODUCT_ID"."ID" WHERE ("PUBLIC"."ORDERS"."CREATED_AT" >= timestamp with time zone \'2019-09-28 00:00:00.000+04:00\' AND "PUBLIC"."ORDERS"."CREATED_AT" < timestamp with time zone \'2022-10-29 00:00:00.000+04:00\') GROUP BY parsedatetime(formatdatetime("PUBLIC"."ORDERS"."CREATED_AT", \'yyyyMM\'), \'yyyyMM\'), "PRODUCTS__via__PRODUCT_ID"."CATEGORY" ORDER BY parsedatetime(formatdatetime("PUBLIC"."ORDERS"."CREATED_AT", \'yyyyMM\'), \'yyyyMM\') ASC, "PRODUCTS__via__PRODUCT_ID"."CATEGORY" ASC',- params: null,- },- results_timezone: "Asia/Dubai",- results_metadata: {- columns: [- {- description: "The date and time an order was submitted.",- semantic_type: "type/CreationTimestamp",- coercion_strategy: null,- unit: "month",- name: "CREATED_AT",- settings: {- date_style: "D MMMM, YYYY",- date_separator: "-",+ {+ base_type: "type/BigInteger",+ semantic_type: "type/Quantity",+ name: "count",+ display_name: "Count",+ source: "aggregation",+ field_ref: ["aggregation", 0],+ effective_type: "type/BigInteger",},- field_ref: [- "field",- 12,+ ],+ native_form: {+ query:+ 'SELECT parsedatetime(formatdatetime("PUBLIC"."ORDERS"."CREATED_AT", \'yyyyMM\'), \'yyyyMM\') AS "CREATED_AT", "PRODUCTS__via__PRODUCT_ID"."CATEGORY" AS "PRODUCTS__via__PRODUCT_ID__CATEGORY", count(*) AS "count" FROM "PUBLIC"."ORDERS" LEFT JOIN "PUBLIC"."PRODUCTS" "PRODUCTS__via__PRODUCT_ID" ON "PUBLIC"."ORDERS"."PRODUCT_ID" = "PRODUCTS__via__PRODUCT_ID"."ID" WHERE ("PUBLIC"."ORDERS"."CREATED_AT" >= timestamp with time zone \'2019-09-28 00:00:00.000+04:00\' AND "PUBLIC"."ORDERS"."CREATED_AT" < timestamp with time zone \'2022-10-29 00:00:00.000+04:00\') GROUP BY parsedatetime(formatdatetime("PUBLIC"."ORDERS"."CREATED_AT", \'yyyyMM\'), \'yyyyMM\'), "PRODUCTS__via__PRODUCT_ID"."CATEGORY" ORDER BY parsedatetime(formatdatetime("PUBLIC"."ORDERS"."CREATED_AT", \'yyyyMM\'), \'yyyyMM\') ASC, "PRODUCTS__via__PRODUCT_ID"."CATEGORY" ASC',+ params: null,+ },+ results_timezone: "Asia/Dubai",+ results_metadata: {+ columns: [{- "temporal-unit": "month",+ description: "The date and time an order was submitted.",+ semantic_type: "type/CreationTimestamp",+ coercion_strategy: null,+ unit: "month",+ name: "CREATED_AT",+ settings: {+ date_style: "D MMMM, YYYY",+ date_separator: "-",+ },+ field_ref: [+ "field",+ 12,+ {+ "temporal-unit": "month",+ },+ ],+ effective_type: "type/DateTime",+ id: 12,+ visibility_type: "normal",+ display_name: "Created At",+ base_type: "type/DateTime",},- ],- effective_type: "type/DateTime",- id: 12,- visibility_type: "normal",- display_name: "Created At",- base_type: "type/DateTime",- },- {- description:- "The type of product, valid values include: Doohicky, Gadget, Gizmo and Widget",- semantic_type: "type/Category",- coercion_strategy: null,- name: "CATEGORY",- settings: null,- field_ref: [- "field",- 4,{- "source-field": 13,+ description:+ "The type of product, valid values include: Doohicky, Gadget, Gizmo and Widget",+ semantic_type: "type/Category",+ coercion_strategy: null,+ name: "CATEGORY",+ settings: null,+ field_ref: [+ "field",+ 4,+ {+ "source-field": 13,+ },+ ],+ effective_type: "type/Text",+ id: 4,+ visibility_type: "normal",+ display_name: "Product → Category",+ base_type: "type/Text",+ },+ {+ display_name: "Count",+ semantic_type: "type/Quantity",+ field_ref: ["aggregation", 0],+ name: "count",+ base_type: "type/BigInteger",+ effective_type: "type/BigInteger",},],- effective_type: "type/Text",- id: 4,- visibility_type: "normal",- display_name: "Product → Category",- base_type: "type/Text",- },- {- display_name: "Count",- semantic_type: "type/Quantity",- field_ref: ["aggregation", 0],- name: "count",- base_type: "type/BigInteger",- effective_type: "type/BigInteger",},- ],+ insights: null,+ },},- insights: null,- },-} as any;--export const METRIC_COLUMN_WITH_SCALING: StaticRowChartProps = {+ ],settings: {"graph.dimensions": ["CREATED_AT", "CATEGORY"],column_settings: {@@ -182,171 +205,208 @@ export const METRIC_COLUMN_WITH_SCALING: StaticRowChartProps = {date_style: "MMMM D, YYYY",date_abbreviate: true,},- '["name","count"]': {- scale: 0.1,- },},"graph.metrics": ["count"],},- data: {- rows: [- ["2019-09-01T00:00:00+04:00", "Doohickey", 9],- ["2019-09-01T00:00:00+04:00", "Gadget", 13],- ["2019-09-01T00:00:00+04:00", "Gizmo", 21],- ["2019-09-01T00:00:00+04:00", "Widget", 14],- ["2019-10-01T00:00:00+04:00", "Doohickey", 102],- ["2019-10-01T00:00:00+04:00", "Gadget", 134],- ["2019-10-01T00:00:00+04:00", "Gizmo", 151],- ["2019-10-01T00:00:00+04:00", "Widget", 153],- ["2019-11-01T00:00:00+04:00", "Doohickey", 116],- ["2019-11-01T00:00:00+04:00", "Gadget", 165],- ["2019-11-01T00:00:00+04:00", "Gizmo", 127],- ["2019-11-01T00:00:00+04:00", "Widget", 134],- ["2019-12-01T00:00:00+04:00", "Doohickey", 100],- ["2019-12-01T00:00:00+04:00", "Gadget", 166],- ["2019-12-01T00:00:00+04:00", "Gizmo", 134],- ["2019-12-01T00:00:00+04:00", "Widget", 150],- ["2020-01-01T00:00:00+04:00", "Doohickey", 128],- ["2020-01-01T00:00:00+04:00", "Gadget", 155],- ["2020-01-01T00:00:00+04:00", "Gizmo", 146],- ["2020-01-01T00:00:00+04:00", "Widget", 151],- ["2020-02-01T00:00:00+04:00", "Doohickey", 114],- ["2020-02-01T00:00:00+04:00", "Gadget", 141],- ["2020-02-01T00:00:00+04:00", "Gizmo", 130],- ["2020-02-01T00:00:00+04:00", "Widget", 158],- ["2020-03-01T00:00:00+04:00", "Doohickey", 121],- ["2020-03-01T00:00:00+04:00", "Gadget", 140],- ["2020-03-01T00:00:00+04:00", "Gizmo", 137],- ["2020-03-01T00:00:00+04:00", "Widget", 129],- ["2020-04-01T00:00:00+04:00", "Doohickey", 73],- ["2020-04-01T00:00:00+04:00", "Gadget", 78],- ["2020-04-01T00:00:00+04:00", "Gizmo", 93],- ["2020-04-01T00:00:00+04:00", "Widget", 100],- ],- cols: [- {- description: "The date and time an order was submitted.",- semantic_type: "type/CreationTimestamp",- table_id: 2,- coercion_strategy: null,- unit: "month",- name: "CREATED_AT",- settings: {- date_style: "D MMMM, YYYY",- date_separator: "-",+ renderingContext,+} as any;++export const METRIC_COLUMN_WITH_SCALING: StaticChartProps = {+ rawSeries: [+ {+ card: {+ id: 2,+ name: "Row Chart with Scaling",+ display: "row",+ visualization_settings: {+ "graph.dimensions": ["CREATED_AT", "CATEGORY"],+ column_settings: {+ '["ref",["field",12,null]]': {+ date_style: "MMMM D, YYYY",+ date_abbreviate: true,+ },+ '["name","count"]': {+ scale: 0.1,+ },+ },+ "graph.metrics": ["count"],},- source: "breakout",- field_ref: [- "field",- 12,+ },+ data: {+ rows: [+ ["2019-09-01T00:00:00+04:00", "Doohickey", 9],+ ["2019-09-01T00:00:00+04:00", "Gadget", 13],+ ["2019-09-01T00:00:00+04:00", "Gizmo", 21],+ ["2019-09-01T00:00:00+04:00", "Widget", 14],+ ["2019-10-01T00:00:00+04:00", "Doohickey", 102],+ ["2019-10-01T00:00:00+04:00", "Gadget", 134],+ ["2019-10-01T00:00:00+04:00", "Gizmo", 151],+ ["2019-10-01T00:00:00+04:00", "Widget", 153],+ ["2019-11-01T00:00:00+04:00", "Doohickey", 116],+ ["2019-11-01T00:00:00+04:00", "Gadget", 165],+ ["2019-11-01T00:00:00+04:00", "Gizmo", 127],+ ["2019-11-01T00:00:00+04:00", "Widget", 134],+ ["2019-12-01T00:00:00+04:00", "Doohickey", 100],+ ["2019-12-01T00:00:00+04:00", "Gadget", 166],+ ["2019-12-01T00:00:00+04:00", "Gizmo", 134],+ ["2019-12-01T00:00:00+04:00", "Widget", 150],+ ["2020-01-01T00:00:00+04:00", "Doohickey", 128],+ ["2020-01-01T00:00:00+04:00", "Gadget", 155],+ ["2020-01-01T00:00:00+04:00", "Gizmo", 146],+ ["2020-01-01T00:00:00+04:00", "Widget", 151],+ ["2020-02-01T00:00:00+04:00", "Doohickey", 114],+ ["2020-02-01T00:00:00+04:00", "Gadget", 141],+ ["2020-02-01T00:00:00+04:00", "Gizmo", 130],+ ["2020-02-01T00:00:00+04:00", "Widget", 158],+ ["2020-03-01T00:00:00+04:00", "Doohickey", 121],+ ["2020-03-01T00:00:00+04:00", "Gadget", 140],+ ["2020-03-01T00:00:00+04:00", "Gizmo", 137],+ ["2020-03-01T00:00:00+04:00", "Widget", 129],+ ["2020-04-01T00:00:00+04:00", "Doohickey", 73],+ ["2020-04-01T00:00:00+04:00", "Gadget", 78],+ ["2020-04-01T00:00:00+04:00", "Gizmo", 93],+ ["2020-04-01T00:00:00+04:00", "Widget", 100],+ ],+ cols: [+ {+ description: "The date and time an order was submitted.",+ semantic_type: "type/CreationTimestamp",+ table_id: 2,+ coercion_strategy: null,+ unit: "month",+ name: "CREATED_AT",+ settings: {+ date_style: "D MMMM, YYYY",+ date_separator: "-",+ },+ source: "breakout",+ field_ref: [+ "field",+ 12,+ {+ "temporal-unit": "month",+ },+ ],+ effective_type: "type/DateTime",+ nfc_path: null,+ parent_id: null,+ id: 12,+ visibility_type: "normal",+ display_name: "Created At",+ base_type: "type/DateTime",+ },{- "temporal-unit": "month",+ description:+ "The type of product, valid values include: Doohicky, Gadget, Gizmo and Widget",+ semantic_type: "type/Category",+ table_id: 1,+ coercion_strategy: null,+ name: "CATEGORY",+ settings: null,+ source: "breakout",+ fk_field_id: 13,+ field_ref: [+ "field",+ 4,+ {+ "source-field": 13,+ },+ ],+ effective_type: "type/Text",+ nfc_path: null,+ parent_id: null,+ id: 4,+ visibility_type: "normal",+ display_name: "Product → Category",+ base_type: "type/Text",},- ],- effective_type: "type/DateTime",- nfc_path: null,- parent_id: null,- id: 12,- visibility_type: "normal",- display_name: "Created At",- base_type: "type/DateTime",- },- {- description:- "The type of product, valid values include: Doohicky, Gadget, Gizmo and Widget",- semantic_type: "type/Category",- table_id: 1,- coercion_strategy: null,- name: "CATEGORY",- settings: null,- source: "breakout",- fk_field_id: 13,- field_ref: [- "field",- 4,{- "source-field": 13,+ base_type: "type/BigInteger",+ semantic_type: "type/Quantity",+ name: "count",+ display_name: "Count",+ source: "aggregation",+ field_ref: ["aggregation", 0],+ effective_type: "type/BigInteger",},],- effective_type: "type/Text",- nfc_path: null,- parent_id: null,- id: 4,- visibility_type: "normal",- display_name: "Product → Category",- base_type: "type/Text",- },- {- base_type: "type/BigInteger",- semantic_type: "type/Quantity",- name: "count",- display_name: "Count",- source: "aggregation",- field_ref: ["aggregation", 0],- effective_type: "type/BigInteger",- },- ],- native_form: {- query:- 'SELECT parsedatetime(formatdatetime("PUBLIC"."ORDERS"."CREATED_AT", \'yyyyMM\'), \'yyyyMM\') AS "CREATED_AT", "PRODUCTS__via__PRODUCT_ID"."CATEGORY" AS "PRODUCTS__via__PRODUCT_ID__CATEGORY", count(*) AS "count" FROM "PUBLIC"."ORDERS" LEFT JOIN "PUBLIC"."PRODUCTS" "PRODUCTS__via__PRODUCT_ID" ON "PUBLIC"."ORDERS"."PRODUCT_ID" = "PRODUCTS__via__PRODUCT_ID"."ID" WHERE ("PUBLIC"."ORDERS"."CREATED_AT" >= timestamp with time zone \'2019-09-28 00:00:00.000+04:00\' AND "PUBLIC"."ORDERS"."CREATED_AT" < timestamp with time zone \'2022-10-29 00:00:00.000+04:00\') GROUP BY parsedatetime(formatdatetime("PUBLIC"."ORDERS"."CREATED_AT", \'yyyyMM\'), \'yyyyMM\'), "PRODUCTS__via__PRODUCT_ID"."CATEGORY" ORDER BY parsedatetime(formatdatetime("PUBLIC"."ORDERS"."CREATED_AT", \'yyyyMM\'), \'yyyyMM\') ASC, "PRODUCTS__via__PRODUCT_ID"."CATEGORY" ASC',- params: null,- },- results_timezone: "Asia/Dubai",- results_metadata: {- columns: [- {- description: "The date and time an order was submitted.",- semantic_type: "type/CreationTimestamp",- coercion_strategy: null,- unit: "month",- name: "CREATED_AT",- settings: {- date_style: "D MMMM, YYYY",- date_separator: "-",- },- field_ref: [- "field",- 12,+ native_form: {+ query:+ 'SELECT parsedatetime(formatdatetime("PUBLIC"."ORDERS"."CREATED_AT", \'yyyyMM\'), \'yyyyMM\') AS "CREATED_AT", "PRODUCTS__via__PRODUCT_ID"."CATEGORY" AS "PRODUCTS__via__PRODUCT_ID__CATEGORY", count(*) AS "count" FROM "PUBLIC"."ORDERS" LEFT JOIN "PUBLIC"."PRODUCTS" "PRODUCTS__via__PRODUCT_ID" ON "PUBLIC"."ORDERS"."PRODUCT_ID" = "PRODUCTS__via__PRODUCT_ID"."ID" WHERE ("PUBLIC"."ORDERS"."CREATED_AT" >= timestamp with time zone \'2019-09-28 00:00:00.000+04:00\' AND "PUBLIC"."ORDERS"."CREATED_AT" < timestamp with time zone \'2022-10-29 00:00:00.000+04:00\') GROUP BY parsedatetime(formatdatetime("PUBLIC"."ORDERS"."CREATED_AT", \'yyyyMM\'), \'yyyyMM\'), "PRODUCTS__via__PRODUCT_ID"."CATEGORY" ORDER BY parsedatetime(formatdatetime("PUBLIC"."ORDERS"."CREATED_AT", \'yyyyMM\'), \'yyyyMM\') ASC, "PRODUCTS__via__PRODUCT_ID"."CATEGORY" ASC',+ params: null,+ },+ results_timezone: "Asia/Dubai",+ results_metadata: {+ columns: [{- "temporal-unit": "month",+ description: "The date and time an order was submitted.",+ semantic_type: "type/CreationTimestamp",+ coercion_strategy: null,+ unit: "month",+ name: "CREATED_AT",+ settings: {+ date_style: "D MMMM, YYYY",+ date_separator: "-",+ },+ field_ref: [+ "field",+ 12,+ {+ "temporal-unit": "month",+ },+ ],+ effective_type: "type/DateTime",+ id: 12,+ visibility_type: "normal",+ display_name: "Created At",+ base_type: "type/DateTime",},- ],- effective_type: "type/DateTime",- id: 12,- visibility_type: "normal",- display_name: "Created At",- base_type: "type/DateTime",- },- {- description:- "The type of product, valid values include: Doohicky, Gadget, Gizmo and Widget",- semantic_type: "type/Category",- coercion_strategy: null,- name: "CATEGORY",- settings: null,- field_ref: [- "field",- 4,{- "source-field": 13,+ description:+ "The type of product, valid values include: Doohicky, Gadget, Gizmo and Widget",+ semantic_type: "type/Category",+ coercion_strategy: null,+ name: "CATEGORY",+ settings: null,+ field_ref: [+ "field",+ 4,+ {+ "source-field": 13,+ },+ ],+ effective_type: "type/Text",+ id: 4,+ visibility_type: "normal",+ display_name: "Product → Category",+ base_type: "type/Text",+ },+ {+ display_name: "Count",+ semantic_type: "type/Quantity",+ field_ref: ["aggregation", 0],+ name: "count",+ base_type: "type/BigInteger",+ effective_type: "type/BigInteger",},],- effective_type: "type/Text",- id: 4,- visibility_type: "normal",- display_name: "Product → Category",- base_type: "type/Text",- },- {- display_name: "Count",- semantic_type: "type/Quantity",- field_ref: ["aggregation", 0],- name: "count",- base_type: "type/BigInteger",- effective_type: "type/BigInteger",},- ],+ insights: null,+ },+ },+ ],+ settings: {+ "graph.dimensions": ["CREATED_AT", "CATEGORY"],+ column_settings: {+ '["ref",["field",12,null]]': {+ date_style: "MMMM D, YYYY",+ date_abbreviate: true,+ },+ '["name","count"]': {+ scale: 0.1,+ },},- insights: null,+ "graph.metrics": ["count"],},+ renderingContext,} as any;diff --git a/frontend/src/metabase/static-viz/components/RowChart/utils/labels.ts b/frontend/src/metabase/static-viz/components/RowChart/utils/labels.tsdeleted file mode 100644index 1907b077916..00000000000--- a/frontend/src/metabase/static-viz/components/RowChart/utils/labels.ts+++ /dev/null@@ -1,33 +0,0 @@-import type { CartesianChartColumns } from "metabase/visualizations/lib/graph/columns";-import type { VisualizationSettings } from "metabase-types/api";--// Uses inverse axis settings to have settings compatibility between line/area/bar/combo and row charts-export const getChartLabels = (- chartColumns: CartesianChartColumns,- settings: VisualizationSettings,-) => {- const defaultXLabel =- "breakout" in chartColumns ? chartColumns.metric.column.display_name : "";- const xLabelValue = settings["graph.y_axis.title_text"] ?? defaultXLabel;-- const xLabel =- (settings["graph.y_axis.labels_enabled"] ?? true) && xLabelValue.length > 0- ? xLabelValue- : undefined;-- const defaultYLabel =- "breakout" in chartColumns- ? ""- : chartColumns.dimension.column.display_name;- const yLabelValue = settings["graph.x_axis.title_text"] ?? defaultYLabel;- const yLabel =- (settings["graph.x_axis.labels_enabled"] ?? true) &&- (yLabelValue.length ?? 0) > 0- ? yLabelValue- : undefined;-- return {- xLabel,- yLabel,- };-};diff --git a/frontend/src/metabase/static-viz/components/StaticVisualization/StaticVisualization.tsx b/frontend/src/metabase/static-viz/components/StaticVisualization/StaticVisualization.tsxindex 65ed91384f0..5ad5758ce5f 100644--- a/frontend/src/metabase/static-viz/components/StaticVisualization/StaticVisualization.tsx+++ b/frontend/src/metabase/static-viz/components/StaticVisualization/StaticVisualization.tsx@@ -6,6 +6,7 @@ import type { StaticVisualizationProps } from "metabase/visualizations/types";import { ComboChart } from "../ComboChart";import { FunnelBarChart } from "../FunnelBarChart";import { PieChart } from "../PieChart/PieChart";+import { StaticRowChart } from "../RowChart/RowChart";import { SankeyChart } from "../SankeyChart";import { ScalarChart } from "../ScalarChart";import { ScatterPlot } from "../ScatterPlot/ScatterPlot";@@ -51,6 +52,9 @@ export const StaticVisualization = ({return <PieChart {...props} />;case "sankey":return <SankeyChart {...props} />;+ case "row":+ // TODO: replace with an ECharts implementation+ return <StaticRowChart {...props} />;}throw new Error(`Unsupported display type: ${display}`);diff --git a/frontend/src/metabase/static-viz/containers/LegacyStaticChart/LegacyStaticChart.tsx b/frontend/src/metabase/static-viz/containers/LegacyStaticChart/LegacyStaticChart.tsxindex 32ccafe7c0c..1f10d55dd13 100644--- a/frontend/src/metabase/static-viz/containers/LegacyStaticChart/LegacyStaticChart.tsx+++ b/frontend/src/metabase/static-viz/containers/LegacyStaticChart/LegacyStaticChart.tsx@@ -2,12 +2,10 @@ import type { ColorPalette } from "metabase/lib/colors/types";import Funnel from "metabase/static-viz/components/FunnelChart";import Gauge from "metabase/static-viz/components/Gauge";import ProgressBar from "metabase/static-viz/components/ProgressBar";-import RowChart from "metabase/static-viz/components/RowChart";import { createColorGetter } from "metabase/static-viz/lib/colors";export type LegacyStaticChartType =| "progress"- | "row"| "waterfall"| "gauge"| "funnel";@@ -33,8 +31,6 @@ export const LegacyStaticChart = ({switch (type) {case "gauge":return <Gauge {...chartProps} />;- case "row":- return <RowChart {...chartProps} />;case "progress":return <ProgressBar {...chartProps} />;case "funnel":diff --git a/frontend/src/metabase/static-viz/register.js b/frontend/src/metabase/static-viz/register.jsindex 4fc4d3828e7..aafbae9d9d6 100644--- a/frontend/src/metabase/static-viz/register.js+++ b/frontend/src/metabase/static-viz/register.js@@ -8,6 +8,7 @@ import { ComboChart } from "metabase/visualizations/visualizations/ComboChart";import { Funnel } from "metabase/visualizations/visualizations/Funnel";import { LineChart } from "metabase/visualizations/visualizations/LineChart";import { PieChart } from "metabase/visualizations/visualizations/PieChart";+import RowChart from "metabase/visualizations/visualizations/RowChart";import { SankeyChart } from "metabase/visualizations/visualizations/SankeyChart";import { Scalar } from "metabase/visualizations/visualizations/Scalar";import { ScatterPlot } from "metabase/visualizations/visualizations/ScatterPlot";@@ -26,5 +27,6 @@ export const registerStaticVisualizations = () => {registerVisualization(ScatterPlot);registerVisualization(PieChart);registerVisualization(SankeyChart);+ registerVisualization(RowChart);setDefaultVisualization(Scalar);};diff --git a/resources/frontend_shared/static_viz_interface.js b/resources/frontend_shared/static_viz_interface.jsindex a40ea3659f5..e55da5471dd 100644--- a/resources/frontend_shared/static_viz_interface.js+++ b/resources/frontend_shared/static_viz_interface.js@@ -14,18 +14,6 @@ function toJSMap(m) {return o;}-/**- * @deprecated use javascript_visualization instead- */-function row_chart(settings, data, colors, tokenFeatures) {- return StaticViz.LegacyRenderChart("row", {- settings: JSON.parse(settings),- data: JSON.parse(data),- colors: JSON.parse(colors),- tokenFeatures: JSON.parse(tokenFeatures),- });-}-/*** @deprecated use javascript_visualization instead*/diff --git a/src/metabase/channel/render/body.clj b/src/metabase/channel/render/body.cljindex 831c4ac9995..aa50899752d 100644--- a/src/metabase/channel/render/body.clj+++ b/src/metabase/channel/render/body.clj@@ -390,21 +390,6 @@(assoc :data (:data result))(dissoc :result)))-(mu/defmethod render :row :- ::RenderedPartCard- [_chart-type render-type _timezone-id card _dashcard data]- (let [viz-settings (get card :visualization_settings)- image-bundle (image-bundle/make-image-bundle- render-type- (js.svg/row-chart viz-settings data))]- {:attachments- (when image-bundle- (image-bundle/image-bundle->attachment image-bundle))-- :content- [:div- [:img {:style (style/style {:display :block :width :100%})- :src (:image-src image-bundle)}]]}))-(mu/defmethod render :scalar :- ::RenderedPartCard[_chart-type _render-type timezone-id _card _dashcard {:keys [cols rows viz-settings]}](let [field-name (:scalar.field viz-settings)diff --git a/src/metabase/channel/render/card.clj b/src/metabase/channel/render/card.cljindex 5c68e875c9a..d8da16a0fd6 100644--- a/src/metabase/channel/render/card.clj+++ b/src/metabase/channel/render/card.clj@@ -116,7 +116,6 @@(chart-type :scalar "result has one row and one column")(#{:scalar- :row:progress:gauge:table@@ -129,6 +128,7 @@:pie:scatter:waterfall+ :row:line:area:bardiff --git a/src/metabase/channel/render/js/svg.clj b/src/metabase/channel/render/js/svg.cljindex 3b2a11809f9..0ad09d493ce 100644--- a/src/metabase/channel/render/js/svg.clj+++ b/src/metabase/channel/render/js/svg.clj@@ -218,17 +218,6 @@json/decode+kw(update :type (fnil keyword "unknown")))))-(defn row-chart- "Clojure entrypoint to render a row chart."- [settings data]- (let [svg-string (with-static-viz-context context- (.asString (js.engine/execute-fn-name context "row_chart"- (json/encode settings)- (json/encode data)- (json/encode (appearance/application-colors))- (json/encode (premium-features/token-features)))))]- (svg-string->bytes svg-string)))-(defn gauge"Clojure entrypoint to render a gauge chart. Returns a byte array of a png file"[card data]diff --git a/test/metabase/channel/render/card_test.clj b/test/metabase/channel/render/card_test.cljindex b903b32e93b..3d0a56f7e1d 100644--- a/test/metabase/channel/render/card_test.clj+++ b/test/metabase/channel/render/card_test.clj@@ -136,7 +136,6 @@{:base_type :type/Number}]:rows [["A" 2]["B" 3]]}))- :row:funnel:progress:table)))