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
Restyle Number and Trend dashboard cards (UXW-5128) (#81131)
Denis Berezin84223a0d4de9
diff --git a/.loki/reference/chrome_laptop_App_Embed_DashCardMenuButton_States.png b/.loki/reference/chrome_laptop_App_Embed_DashCardMenuButton_States.pngnew file mode 100644index 00000000000..945e19642adBinary files /dev/null and b/.loki/reference/chrome_laptop_App_Embed_DashCardMenuButton_States.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Card_Visualizations_Dark_Theme.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Card_Visualizations_Dark_Theme.pngindex ac0c7e2472b..c9db59417b2 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Card_Visualizations_Dark_Theme.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Card_Visualizations_Dark_Theme.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Card_Visualizations_Light_Theme.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Card_Visualizations_Light_Theme.pngindex ee5d9eb2aac..cf1628bd6c7 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Card_Visualizations_Light_Theme.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Card_Visualizations_Light_Theme.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Default.pngindex 051fe3c03ba..1d98c175df8 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Default.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Default.pngindex 94dbca56c44..2e8d273d263 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Default.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Scroll.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Scroll.pngindex c63e160192c..83138fd78d3 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Scroll.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_No_Background_Scroll.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Scroll.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Scroll.pngindex 6c0265907f2..2c129ae88c8 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Scroll.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Dark_Theme_Scroll.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Default.pngindex 2b0a6c2d6d0..af135d0ed1b 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Default.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Default.pngindex b032dd4b7aa..a4fa85937be 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Default.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Scroll.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Scroll.pngindex 3db2c35a823..fc283dfd478 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Scroll.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_No_Background_Scroll.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Scroll.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Scroll.pngindex 37a9cc3db63..6e522c0b4f9 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Scroll.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Light_Theme_Scroll.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Default.pngindex db00047d3d3..7c1e7b5f06f 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Default.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Default.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Default.pngindex 3b9e3e90b07..ccf2d951af8 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Default.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Default.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Scroll.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Scroll.pngindex 5ae7905d9f4..dbfbaed96ea 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Scroll.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_No_Background_Scroll.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Scroll.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Scroll.pngindex 5cdb580338f..b01ecf218b8 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Scroll.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_Transparent_Theme_Scroll.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Chart_Many_Filters.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Chart_Many_Filters.pngindex 1306b8dafff..d31943d7e66 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Chart_Many_Filters.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Chart_Many_Filters.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Chart_One_Filter.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Chart_One_Filter.pngindex e0343f0f99d..c5c6a28b63a 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Chart_One_Filter.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Chart_One_Filter.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Heading_Many_Filters.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Heading_Many_Filters.pngindex 03bbc1383b2..ff3f97bf853 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Heading_Many_Filters.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Heading_Many_Filters.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Heading_One_Filter.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Heading_One_Filter.pngindex 2176ecded2f..b11bba55faf 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Heading_One_Filter.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Full_Width_Heading_One_Filter.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Medium_Chart_Many_Filters.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Medium_Chart_Many_Filters.pngindex ad6d5ad23e8..93e93539f12 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Medium_Chart_Many_Filters.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Medium_Chart_Many_Filters.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Medium_Chart_One_Filter.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Medium_Chart_One_Filter.pngindex f529d8fec5b..1e4a590ca10 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Medium_Chart_One_Filter.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Medium_Chart_One_Filter.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_Many_Filters.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_Many_Filters.pngindex 7b35304e969..98e858ea420 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_Many_Filters.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_Many_Filters.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_Many_Filters_Expanded.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_Many_Filters_Expanded.pngindex b504c654d7e..56fbdd6dda4 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_Many_Filters_Expanded.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_Many_Filters_Expanded.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_One_Filter.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_One_Filter.pngindex 07b75b8dcee..e1d5626ad16 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_One_Filter.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_One_Filter.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_One_Filter_Long_Card_Name.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_One_Filter_Long_Card_Name.pngindex 3070acbc631..1f2aedfcb10 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_One_Filter_Long_Card_Name.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Chart_One_Filter_Long_Card_Name.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_Many_Filters.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_Many_Filters.pngindex c4e4dda3e0f..2c157313c0b 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_Many_Filters.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_Many_Filters.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_Many_Filters_Expanded.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_Many_Filters_Expanded.pngindex 0b961c8ee25..931d6d2ea2c 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_Many_Filters_Expanded.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_Many_Filters_Expanded.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_One_Filter.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_One_Filter.pngindex 6b5283777cf..079338bf586 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_One_Filter.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_One_Filter.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_One_Filter_Long_Text.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_One_Filter_Long_Text.pngindex 9fdf22230a0..07bfc028473 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_One_Filter_Long_Text.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_card_filters_Narrow_Heading_One_Filter_Long_Text.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_All_Options.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_All_Options.pngindex 146625b4f24..a88f9e6ed78 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_All_Options.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_All_Options.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Month_Year.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Month_Year.pngindex 64e6eabd911..d3987b5559c 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Month_Year.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Month_Year.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year.pngindex 78b36f94f1f..99e7143c517 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year_Dropdown.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year_Dropdown.pngindex a47a6e65af7..f3e3565ac25 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year_Dropdown.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year_Dropdown.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Range.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Range.pngindex 116ca1757d0..239abec71b9 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Range.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Range.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Relative.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Relative.pngindex e3873b524d4..13856ce8f1b 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Relative.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Relative.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Single.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Single.pngindex f24d4251d85..263e58455a5 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Single.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Single.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Number.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Number.pngindex d0b54e9c3de..63415d591ef 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Number.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Number.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List.pngindex cdb1a7f2325..88d2317ce90 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_Single_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_Single_With_Value.pngindex 06c9e235fce..ce7769250bc 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_Single_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_Single_With_Value.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_With_Value.pngindex 627f30ab2fe..5b70ec9d7d1 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_List_With_Value.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search.pngindex cdb1a7f2325..88d2317ce90 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search_With_Value.pngindex cb95cac6fe7..126e73ed200 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Parameter_Search_With_Value.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text.pngindex d5cdaaad006..a5cd3bd4a3e 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text_With_Value.pngindex d5cdaaad006..a5cd3bd4a3e 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text_With_Value.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Unit_Of_Time.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Unit_Of_Time.pngindex 6a820a8a3df..0254aac29c6 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Unit_Of_Time.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Unit_Of_Time.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_All_Options.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_All_Options.pngindex 7b3c3c63579..ba9d0e7b2ad 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_All_Options.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_All_Options.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Month_Year.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Month_Year.pngindex d5869af441c..9075e1836a6 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Month_Year.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Month_Year.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year.pngindex c391b899177..d3cd5823e3a 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year_Dropdown.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year_Dropdown.pngindex a0e9b16282d..f033e55207d 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year_Dropdown.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Quarter_Year_Dropdown.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Range.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Range.pngindex 9b08afad598..b862bc6d758 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Range.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Range.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Relative.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Relative.pngindex af7f0d6ae97..956c95ae914 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Relative.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Relative.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Single.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Single.pngindex f6e317e8659..247b803eedb 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Single.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Single.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Number.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Number.pngindex 50c38d55563..46492b2969e 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Number.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Number.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List.pngindex 90d15498f7c..90975ec34ca 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_Single_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_Single_With_Value.pngindex 446e7c4364e..7fe424ca1be 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_Single_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_Single_With_Value.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_With_Value.pngindex 3526eff9966..48f8bf09ce8 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_List_With_Value.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search.pngindex 90d15498f7c..fdbd83d1e9b 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search_With_Value.pngindex db153654976..90fce5869d2 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Parameter_Search_With_Value.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text.pngindex 7df5f51180c..ee2c3c32b16 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text_With_Value.pngindex 7df5f51180c..3bbeabe7416 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text_With_Value.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Unit_Of_Time.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Unit_Of_Time.pngindex f9ca4ccb2a0..917d0e6b3cb 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Unit_Of_Time.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Unit_Of_Time.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Smart_Scalar_Dark_Theme.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Smart_Scalar_Dark_Theme.pngindex 83b6ded02e2..41d39838362 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Smart_Scalar_Dark_Theme.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Smart_Scalar_Dark_Theme.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Smart_Scalar_Download.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Smart_Scalar_Download.pngindex eef40ec38f5..c15b02549dc 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Smart_Scalar_Download.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Smart_Scalar_Download.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Smart_Scalar_Light_Theme.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Smart_Scalar_Light_Theme.pngindex 6eb4ea49945..03c87cafb39 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Smart_Scalar_Light_Theme.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Smart_Scalar_Light_Theme.png differdiff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Smart_Scalar_Unicode_Subscript.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Smart_Scalar_Unicode_Subscript.pngindex ec2d7849353..c4a1444d39f 100644Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Smart_Scalar_Unicode_Subscript.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedQuestionView_Smart_Scalar_Unicode_Subscript.png differdiff --git a/.loki/reference/chrome_laptop_Components_Feedback_Loader_Default.png b/.loki/reference/chrome_laptop_Components_Feedback_Loader_Default.pngdeleted file mode 100644index e04e7108f11..00000000000Binary files a/.loki/reference/chrome_laptop_Components_Feedback_Loader_Default.png and /dev/null differdiff --git a/.loki/reference/chrome_laptop_Viz_Components_ChartSkeleton_Scalar.png b/.loki/reference/chrome_laptop_Viz_Components_ChartSkeleton_Scalar.pngindex 24042fa6e38..6f0778b8472 100644Binary files a/.loki/reference/chrome_laptop_Viz_Components_ChartSkeleton_Scalar.png and b/.loki/reference/chrome_laptop_Viz_Components_ChartSkeleton_Scalar.png differdiff --git a/.loki/reference/chrome_laptop_Viz_Components_ChartSkeleton_Scalar_Size_Tiers.png b/.loki/reference/chrome_laptop_Viz_Components_ChartSkeleton_Scalar_Size_Tiers.pngnew file mode 100644index 00000000000..32012ea63e7Binary files /dev/null and b/.loki/reference/chrome_laptop_Viz_Components_ChartSkeleton_Scalar_Size_Tiers.png differdiff --git a/.loki/reference/chrome_laptop_Viz_Components_ChartSkeleton_Smart_Scalar.png b/.loki/reference/chrome_laptop_Viz_Components_ChartSkeleton_Smart_Scalar.pngindex 24581ca360c..a13cce658c9 100644Binary files a/.loki/reference/chrome_laptop_Viz_Components_ChartSkeleton_Smart_Scalar.png and b/.loki/reference/chrome_laptop_Viz_Components_ChartSkeleton_Smart_Scalar.png differdiff --git a/.loki/reference/chrome_laptop_viz_CustomViz_CalendarHeatmap_Dashboard_Dark.png b/.loki/reference/chrome_laptop_viz_CustomViz_CalendarHeatmap_Dashboard_Dark.pngindex 8488a91bedf..f791a37bbcc 100644Binary files a/.loki/reference/chrome_laptop_viz_CustomViz_CalendarHeatmap_Dashboard_Dark.png and b/.loki/reference/chrome_laptop_viz_CustomViz_CalendarHeatmap_Dashboard_Dark.png differdiff --git a/.loki/reference/chrome_laptop_viz_CustomViz_CalendarHeatmap_Dashboard_Light.png b/.loki/reference/chrome_laptop_viz_CustomViz_CalendarHeatmap_Dashboard_Light.pngindex f22ac981e6c..06520e10ca6 100644Binary files a/.loki/reference/chrome_laptop_viz_CustomViz_CalendarHeatmap_Dashboard_Light.png and b/.loki/reference/chrome_laptop_viz_CustomViz_CalendarHeatmap_Dashboard_Light.png differdiff --git a/.loki/reference/chrome_laptop_viz_Scalar_With_Formatting_And_Hover.png b/.loki/reference/chrome_laptop_viz_Scalar_With_Formatting_And_Hover.pngindex 47af6d2e25b..43fd926dd9e 100644Binary files a/.loki/reference/chrome_laptop_viz_Scalar_With_Formatting_And_Hover.png and b/.loki/reference/chrome_laptop_viz_Scalar_With_Formatting_And_Hover.png differdiff --git a/.loki/reference/chrome_laptop_viz_SmartScalar_Dashcard_Multiple_Comparisons.png b/.loki/reference/chrome_laptop_viz_SmartScalar_Dashcard_Multiple_Comparisons.pngnew file mode 100644index 00000000000..6c9db45141dBinary files /dev/null and b/.loki/reference/chrome_laptop_viz_SmartScalar_Dashcard_Multiple_Comparisons.png differdiff --git a/.loki/reference/chrome_laptop_viz_SmartScalar_Default.png b/.loki/reference/chrome_laptop_viz_SmartScalar_Default.pngindex 63c93f9b70c..2fdc9703d3b 100644Binary files a/.loki/reference/chrome_laptop_viz_SmartScalar_Default.png and b/.loki/reference/chrome_laptop_viz_SmartScalar_Default.png differdiff --git a/.loki/reference/chrome_laptop_viz_SmartScalar_Embedding_Theme.png b/.loki/reference/chrome_laptop_viz_SmartScalar_Embedding_Theme.pngindex c9a635bfcae..2ee3f52530f 100644Binary files a/.loki/reference/chrome_laptop_viz_SmartScalar_Embedding_Theme.png and b/.loki/reference/chrome_laptop_viz_SmartScalar_Embedding_Theme.png differdiff --git a/.loki/reference/chrome_laptop_viz_SmartScalar_Query_Builder_Multiple_Comparisons.png b/.loki/reference/chrome_laptop_viz_SmartScalar_Query_Builder_Multiple_Comparisons.pngnew file mode 100644index 00000000000..df6fe142c57Binary files /dev/null and b/.loki/reference/chrome_laptop_viz_SmartScalar_Query_Builder_Multiple_Comparisons.png differdiff --git a/.loki/reference/chrome_laptop_viz_SmartScalar_Query_Builder_Single_Comparison.png b/.loki/reference/chrome_laptop_viz_SmartScalar_Query_Builder_Single_Comparison.pngnew file mode 100644index 00000000000..ddf68839768Binary files /dev/null and b/.loki/reference/chrome_laptop_viz_SmartScalar_Query_Builder_Single_Comparison.png differdiff --git a/.loki/reference/chrome_laptop_viz_SmartScalar_Standalone_Question_Multiple_Comparisons.png b/.loki/reference/chrome_laptop_viz_SmartScalar_Standalone_Question_Multiple_Comparisons.pngnew file mode 100644index 00000000000..df6fe142c57Binary files /dev/null and b/.loki/reference/chrome_laptop_viz_SmartScalar_Standalone_Question_Multiple_Comparisons.png differdiff --git a/.loki/reference/chrome_laptop_viz_SmartScalar_Standalone_Question_Single_Comparison.png b/.loki/reference/chrome_laptop_viz_SmartScalar_Standalone_Question_Single_Comparison.pngnew file mode 100644index 00000000000..ddf68839768Binary files /dev/null and b/.loki/reference/chrome_laptop_viz_SmartScalar_Standalone_Question_Single_Comparison.png differdiff --git a/e2e/test/scenarios/dashboard-cards/dashboard-card-reproductions.cy.spec.js b/e2e/test/scenarios/dashboard-cards/dashboard-card-reproductions.cy.spec.jsindex 8f75b3223b6..fd2f3c73473 100644--- a/e2e/test/scenarios/dashboard-cards/dashboard-card-reproductions.cy.spec.js+++ b/e2e/test/scenarios/dashboard-cards/dashboard-card-reproductions.cy.spec.js@@ -674,11 +674,11 @@ describe("issue 29304", () => {// This extra 1ms is crucial, without this the test would fail.cy.tick(WAIT_TIME + 1);- const expectedWidth = 130;+ const expectedWidth = 100;cy.findByTestId("scalar-value").should(([$scalarValue]) => {expect($scalarValue.offsetWidth).to.be.closeTo(expectedWidth,- expectedWidth * 0.1,+ expectedWidth * 0.2, // 20% tolerance for font rendering differences across Chrome versions);});});@@ -871,15 +871,19 @@ describe("issue 31628", () => {});it("should follow truncation rules", () => {- cy.log(- "should not truncate value and should not show value tooltip on hover",- );+ cy.log("should not truncate value");scalarContainer().then(($element) =>H.assertIsNotEllipsified($element[0]),);++ cy.log(+ "should show the title tooltip on hover because the smallest cards hide the inline title",+ );scalarContainer().realHover();- cy.findByRole("tooltip").should("not.exist");+ cy.findByRole("tooltip")+ .findByText(SCALAR_QUESTION.name)+ .should("exist");});});@@ -908,7 +912,7 @@ describe("issue 31628", () => {describe("display: smartscalar", () => {const descendantsSelector = [- "[data-testid='legend-caption']",+ "[data-testid='scalar-title']","[data-testid='scalar-container']","[data-testid='scalar-previous-value']",].join(",");@@ -946,70 +950,40 @@ describe("issue 31628", () => {});it("should follow truncation rules", () => {- cy.log(- "it should not truncate value and should not show value tooltip on hover",- );+ cy.log("it should not truncate value");scalarContainer().then(($element) =>H.assertIsNotEllipsified($element[0]),);- scalarContainer().realHover();-- cy.findByRole("tooltip").should("not.exist");cy.log(- "it should not display period because the card height is too small to fit it",+ "it should show the title tooltip on hover because the smallest cards hide the inline title",);- cy.findByTestId("scalar-period").should("not.exist");-- cy.log("it should truncate title and show title tooltip on hover");- cy.findByTestId("legend-caption-title")- .as("title")- .then(($element) => H.assertIsEllipsified($element[0]));- cy.get("@title").realHover();+ scalarContainer().realHover();cy.findByRole("tooltip").findByText(SMART_SCALAR_QUESTION.name).should("exist");- cy.log("it should show previous value tooltip on hover");- cy.findByTestId("scalar-previous-value").realHover();-- cy.findByRole("tooltip").within(() => {- cy.contains("34.72%").should("exist");- cy.contains("vs. previous month: 527").should("exist");- });+ cy.log("it should not display the period on dashboard cards");+ cy.findByTestId("scalar-period").should("not.exist");cy.log(- "it should show previous value as a percentage only (without truncation)",+ "it should show the previous value as a percentage only (without truncation)",);- previousValue()- .should("contain", "35%")- .and("not.contain", "vs. previous month: 527");-- previousValue().then(($element) =>- H.assertIsNotEllipsified($element[0]),- );- });-- it("should show previous value as a percentage without decimal places (without truncation, 1000x600)", () => {- cy.viewport(1000, 600);-- previousValue()- .should("contain", "35%")- .and("not.contain", "34.72%")- .and("not.contain", "vs. previous month: 527");+ previousValue().should("contain", "-34.72%").and("not.contain", "527");previousValue().then(($element) =>H.assertIsNotEllipsified($element[0]),);- });- it("should truncate previous value (840x600)", () => {- cy.viewport(840, 600);+ cy.log("it should show the full comparison in a panel on hover");+ previousValue().realHover();- previousValue()- .findByText("35%")- .should(($element) => H.assertIsEllipsified($element[0]));+ cy.findByRole("tooltip").within(() => {+ cy.contains("34.72%").should("exist");+ cy.contains("vs. previous month").should("exist");+ cy.contains("527").should("exist");+ });});});@@ -1033,22 +1007,18 @@ describe("issue 31628", () => {cy.findByRole("tooltip").should("not.exist");- cy.log("it should display the period");- cy.findByTestId("scalar-period").should("have.text", "Apr 2029");+ cy.log("it should display the period as part of the comparison");+ previousValue().should("contain", "Apr 2029");- cy.log("should truncate title and show title tooltip on hover");-- cy.findByTestId("legend-caption-title")- .as("title")- .then(($element) => H.assertIsEllipsified($element[0]));- cy.get("@title").realHover();+ cy.log("should truncate the inline title and show it on hover");+ cy.findByTestId("scalar-title").realHover();cy.findByRole("tooltip").findByText(SMART_SCALAR_QUESTION.name).should("exist");cy.log("should show description tooltip on hover");- cy.findByTestId("legend-caption").icon("info").realHover();+ cy.findByTestId("scalar-title").icon("info").realHover();cy.findByRole("tooltip").findByText(SMART_SCALAR_QUESTION.description)@@ -1056,13 +1026,15 @@ describe("issue 31628", () => {cy.log("should show previous value in full");previousValue()- .should("contain", "34.72%")- .and("contain", "vs. previous month: 527");+ .should("contain", "-34.72% MoM")+ .and("contain", "(527)");previousValue().then(($element) =>H.assertIsNotEllipsified($element[0]),);- cy.log("should not show previous value tooltip on hover");+ cy.log(+ "should not show a panel for a single fully-displayed comparison",+ );cy.findByTestId("scalar-previous-value").realHover();cy.findByRole("tooltip").should("not.exist");@@ -1089,21 +1061,18 @@ describe("issue 31628", () => {cy.findByRole("tooltip").should("not.exist");- cy.log("it should display the period");- cy.findByTestId("scalar-period").should("have.text", "Apr 2029");+ cy.log("it should display the period as part of the comparison");+ previousValue().should("contain", "Apr 2029");- cy.log("should truncate title and show title tooltip on hover");- cy.findByTestId("legend-caption-title")- .as("title")- .then(($element) => H.assertIsEllipsified($element[0]));- cy.get("@title").realHover();+ cy.log("should truncate the inline title and show it on hover");+ cy.findByTestId("scalar-title").realHover();cy.findByRole("tooltip").findByText(SMART_SCALAR_QUESTION.name).should("exist");cy.log("should show description tooltip on hover");- cy.findByTestId("legend-caption").icon("info").realHover();+ cy.findByTestId("scalar-title").icon("info").realHover();cy.findByRole("tooltip").findByText(SMART_SCALAR_QUESTION.description)@@ -1111,13 +1080,15 @@ describe("issue 31628", () => {cy.log("should show previous value in full");previousValue()- .should("contain", "34.72%")- .and("contain", "vs. previous month: 527");+ .should("contain", "-34.72% MoM")+ .and("contain", "(527)");previousValue().then(($element) =>H.assertIsNotEllipsified($element[0]),);- cy.log("should not show previous value tooltip on hover");+ cy.log(+ "should not show a panel for a single fully-displayed comparison",+ );cy.findByTestId("scalar-previous-value").realHover();cy.findByRole("tooltip").should("not.exist");diff --git a/e2e/test/scenarios/dashboard-cards/dashboard-card-resizing.cy.spec.js b/e2e/test/scenarios/dashboard-cards/dashboard-card-resizing.cy.spec.jsindex 4e5d9f451a5..a6b525326ee 100644--- a/e2e/test/scenarios/dashboard-cards/dashboard-card-resizing.cy.spec.js+++ b/e2e/test/scenarios/dashboard-cards/dashboard-card-resizing.cy.spec.js@@ -357,7 +357,7 @@ describe("trend charts", () => {cy.signInAsAdmin();});- it("comparisons that do not fit should only be shown in a tooltip", () => {+ it("extra comparisons should only be shown in the hover panel", () => {H.createDashboardWithQuestions({dashboardDetails: {},questions: [@@ -411,11 +411,12 @@ describe("trend charts", () => {});H.getDashboardCard().within(() => {- cy.findByText("34.72%").should("be.visible");- cy.findByText("36.65%").should("not.exist");- cy.findByText("98.88%").should("not.exist");+ cy.findByTestId("scalar-previous-value")+ .should("contain", "-34.72%")+ .and("not.contain", "36.65%")+ .and("not.contain", "98.88%");- cy.findByText("34.72%").realHover();+ cy.findByTestId("scalar-previous-value").realHover();});H.tooltip().within(() => {diff --git a/e2e/test/scenarios/embedding/embedding-reproductions.cy.spec.js b/e2e/test/scenarios/embedding/embedding-reproductions.cy.spec.jsindex d6068114c9e..14b08cd8ae6 100644--- a/e2e/test/scenarios/embedding/embedding-reproductions.cy.spec.js+++ b/e2e/test/scenarios/embedding/embedding-reproductions.cy.spec.js@@ -1055,8 +1055,8 @@ describe("issue 8490", () => {cy.findByTestId("embed-frame").within(() => {cy.log("assert the trend chart");H.getDashboardCard(2).within(() => {- // N/A- cy.findByText("해당 없음").should("be.visible");+ // N/A (the comparison row combines it with the comparison description)+ cy.findByText(/해당 없음/).should("be.visible");// (No data)cy.findByText("(데이터 없음)").should("be.visible");});diff --git a/e2e/test/scenarios/visualizations-tabular/smartscalar-trend.cy.spec.js b/e2e/test/scenarios/visualizations-tabular/smartscalar-trend.cy.spec.jsindex 8c391b8bb71..fd942a33e4e 100644--- a/e2e/test/scenarios/visualizations-tabular/smartscalar-trend.cy.spec.js+++ b/e2e/test/scenarios/visualizations-tabular/smartscalar-trend.cy.spec.js@@ -2,7 +2,6 @@ import Color from "color";const { H } = cy;import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";-import { colors } from "metabase/ui/colors";const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;@@ -65,11 +64,12 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {});// comparisons- // default should be previous period (since we have a dateUnit)+ // default should be previous period (since we have a dateUnit);+ // a single comparison renders as one inline row with the full valuecy.findByTestId("scalar-container").findByText("30,759.47");cy.findByTestId("scalar-previous-value").within(() => {- cy.findByText("vs. previous month:");- cy.findByText("45,683.68");+ cy.findByText("-32.67% MoM");+ cy.findByText("(45,683.68)");});// previous value@@ -78,8 +78,8 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {.click();H.menu().findByText("Previous value").click();cy.findByTestId("scalar-previous-value").within(() => {- cy.findByText("vs. Mar:");- cy.findByText("45,683.68");+ cy.findByText("-32.67% vs. Mar");+ cy.findByText("(45,683.68)");});// periods ago@@ -103,8 +103,8 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {cy.get("input").click().type("3{enter}");});cy.findByTestId("scalar-previous-value").within(() => {- cy.findByText("vs. Jan:");- cy.findByText("52,249.59");+ cy.findByText("-41.13% vs. Jan");+ cy.findByText("(52,249.59)");});// static number@@ -121,9 +121,8 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {cy.button("Done").click();});cy.findByTestId("scalar-previous-value").within(() => {- cy.findByText("vs. My Goal:").should("exist");- cy.findByText("42,000").should("exist"); // goal- cy.findByText("26.76%").should("exist"); // down percentage+ cy.findByText("-26.76% vs. My Goal").should("exist"); // down percentage+ cy.findByText("(42,000)").should("exist"); // goal});cy.findByTestId("chartsettings-sidebar").findByText("(My Goal)").click();H.menu().within(() => {@@ -139,9 +138,8 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {H.menu().button("Done").click();cy.findByTestId("scalar-previous-value").within(() => {- cy.findByText("vs. Mega Count:").should("exist");- cy.findByText("3,440,000").should("exist"); // goal- cy.findByText("99.11%").should("exist"); // down percentage+ cy.findByText("-99.11% vs. Mega Count").should("exist"); // down percentage+ cy.findByText("(3,440,000)").should("exist"); // goal});cy.findByTestId("chartsettings-sidebar").findByText("(Mega Count)").click();@@ -150,9 +148,8 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {H.menu().button("Done").click();cy.findByTestId("scalar-previous-value").within(() => {- cy.findByText("vs. Count:").should("exist");- cy.findByText("344").should("exist"); // goal- cy.findByText("8,841.71%").should("exist"); // up percentage+ cy.findByText("+8,841.71% vs. Count").should("exist"); // up percentage+ cy.findByText("(344)").should("exist"); // goal});});@@ -175,36 +172,27 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {cy.findByTestId("comparison-list").children().should("have.length", 1);cy.findByTestId("scalar-previous-value").within(() => {- cy.findByText("34.72%").should("exist");- cy.findByText("vs. previous month:").should("exist");- cy.findByText("527").should("exist");+ cy.findByText("-34.72% MoM").should("exist");+ cy.findByText("(527)").should("exist");});cy.button("Add comparison").click();cy.findByTestId("comparison-list").children().should("have.length", 2);H.menu().findByText("months ago").click();- cy.findAllByTestId("scalar-previous-value")- .children()- .should("have.length", 2)- .last()- .within(() => {- cy.findByText("36.65%").should("exist");- cy.findByText("vs. Feb:").should("exist");- cy.findByText("543").should("exist");- });+ cy.findAllByTestId("scalar-previous-value").should("have.length", 2);+ cy.findByTestId("scalar-comparison-list").within(() => {+ cy.findByText("vs. Feb").should("exist");+ cy.findByText("-36.65% (543)").should("exist");+ });cy.button("Add comparison").click();cy.findByTestId("comparison-list").children().should("have.length", 3);H.menu().findByText("Previous value").click();- cy.findAllByTestId("scalar-previous-value")- .children()- .should("have.length", 3)- .last()- .within(() => {- cy.findByText("34.72%").should("exist");- cy.findByText("vs. Mar:").should("exist");- cy.findByText("527").should("exist");- });+ cy.findAllByTestId("scalar-previous-value").should("have.length", 3);+ cy.findByTestId("scalar-comparison-list").within(() => {+ cy.findByText("vs. Mar").should("exist");+ cy.findAllByText("-34.72% (527)").should("have.length", 2);+ });cy.button("Add comparison").should("be.disabled");@@ -218,11 +206,9 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {cy.findByTestId("comparison-list").findByText("Previous value").should("not.exist");- cy.findAllByTestId("scalar-previous-value")- .children()- .should("have.length", 2);- cy.findAllByTestId("scalar-previous-value")- .findByText("vs. Mar:")+ cy.findAllByTestId("scalar-previous-value").should("have.length", 2);+ cy.findByTestId("scalar-comparison-list")+ .findByText("vs. Mar").should("not.exist");cy.button("Add comparison").should("be.enabled");@@ -275,8 +261,8 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {cy.findByTestId("scalar-value").should("have.text", "3,440,000");cy.findByTestId("scalar-previous-value").within(() => {cy.findByText("Sum of Total").should("not.exist");- cy.findByText("vs. Goal:").should("exist");- cy.findByText("400,000").should("exist");+ cy.findByText("+760% vs. Goal").should("exist");+ cy.findByText("(400,000)").should("exist");});// Replacing "Custom value (Goal)" with "Another column (Count)"@@ -300,8 +286,8 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {cy.findByTestId("scalar-value").should("have.text", "344");cy.findByTestId("scalar-previous-value").within(() => {cy.findByText("Count").should("not.exist");- cy.findByText("vs. previous month:").should("exist");- cy.findByText("527").should("exist");+ cy.findByText("-34.72% MoM").should("exist");+ cy.findByText("(527)").should("exist");});cy.findByTestId("chartsettings-sidebar")@@ -325,8 +311,8 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {cy.findByTestId("scalar-value").should("have.text", "3,440,000");cy.findByTestId("scalar-previous-value").within(() => {cy.findByText("Sum of Total").should("not.exist");- cy.findByText("vs. previous month:").should("exist");- cy.findByText("5,270,000").should("exist");+ cy.findByText("-34.72% MoM").should("exist");+ cy.findByText("(5,270,000)").should("exist");});// Removing the remaining numeric column, so only Count is left@@ -361,12 +347,23 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {{ visitQuestion: true },);- // scalar.switch_positive_negative setting- cy.icon("arrow_down").should(- "have.css",- "color",- Color(colors.error).rgb().string(),- );+ // scalar.switch_positive_negative setting changes the comparison sentiment color+ const assertComparisonColor = (cssVariable) => {+ cy.document().then((doc) => {+ const expectedColor = Color(+ getComputedStyle(doc.documentElement)+ .getPropertyValue(cssVariable)+ .trim(),+ )+ .rgb()+ .string();+ cy.findByTestId("scalar-previous-value")+ .findByText("-34.72% MoM")+ .should("have.css", "color", expectedColor);+ });+ };++ assertComparisonColor("--mb-color-feedback-negative-strong");H.openVizSettingsSidebar();cy.findByTestId("chartsettings-sidebar").within(() => {cy.findByText("Display").click();@@ -374,11 +371,7 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {force: true,});});- cy.icon("arrow_down").should(- "have.css",- "color",- Color(colors.success).rgb().string(),- );+ assertComparisonColor("--mb-color-feedback-positive-strong");// open the metric column's formatting (now in a popover, since the date// column is also configurable)@@ -428,12 +421,15 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {cy.findByTestId("scalar-container").findByText("68’800.0000%");// add a prefix+ // a long value auto-compacts to fit the card, so match the affixes onlycy.findByLabelText("Add a prefix").click().type("Woah: ").blur();- cy.findByTestId("scalar-container").findByText("Woah: 68’800.0000%");+ cy.findByTestId("scalar-container").should("contain", "Woah: ");// add a suffixcy.findByLabelText("Add a suffix").click().type(" ! cool").blur();- cy.findByTestId("scalar-container").findByText("Woah: 68’800.0000% ! cool");+ cy.findByTestId("scalar-container")+ .should("contain", "Woah: ")+ .and("contain", " ! cool");// scalar.compact_primary_number settingcy.findByTestId("chartsettings-sidebar").within(() => {@@ -443,20 +439,37 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {H.popover().findByRole("option", { name: "Mega Count" }).click();cy.findByTestId("chartsettings-sidebar").findByText("Display").click();+ // the single inline comparison always shows the full value; the setting+ // only affects the primary numbercy.findByTestId("scalar-container").findByText("3,440,000");- cy.findByTestId("scalar-previous-value").findByText("5,270,000");+ cy.findByTestId("scalar-previous-value").should("contain", "5,270,000");cy.findByTestId("chartsettings-sidebar").findByLabelText("Compact number").click({ force: true });cy.findByTestId("scalar-container").findByText("3.4M");- cy.findByTestId("scalar-previous-value").findByText("5.3M");+ cy.findByTestId("scalar-previous-value").should("contain", "5,270,000");cy.findByTestId("chartsettings-sidebar").findByLabelText("Compact number").click({ force: true });cy.findByTestId("scalar-container").findByText("3,440,000");- cy.findByTestId("scalar-previous-value").findByText("5,270,000");+ cy.findByTestId("scalar-previous-value").should("contain", "5,270,000");++ cy.log("scalar.show_comparison_value setting");+ cy.findByTestId("chartsettings-sidebar")+ .findByLabelText("Show comparison value")+ .should("be.checked")+ .click({ force: true });+ cy.findByTestId("scalar-previous-value")+ .should("contain", "-34.72% MoM")+ .and("not.contain", "5,270,000");++ cy.findByTestId("chartsettings-sidebar")+ .findByLabelText("Show comparison value")+ .should("not.be.checked")+ .click({ force: true });+ cy.findByTestId("scalar-previous-value").should("contain", "5,270,000");});it("should work regardless of column order (metabase#13710)", () => {@@ -630,3 +643,122 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {cy.findByTestId("scalar-container").findByText("527").should("be.visible");});});++describe("scenarios > visualizations > trend chart on dashboards and public questions", () => {+ const TREND_QUERY = {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]],+ };++ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ });++ it("should navigate to the question by clicking the dashcard title", () => {+ H.createQuestionAndDashboard({+ questionDetails: {+ name: "Trend title nav",+ query: TREND_QUERY,+ display: "smartscalar",+ },+ cardDetails: { size_x: 8, size_y: 4 },+ }).then(({ body: { dashboard_id } }) => {+ H.visitDashboard(dashboard_id);+ });++ // a real pointer press: regressions here (e.g. the link re-rendering+ // mid-press) do not reproduce with synthetic clicks+ cy.findByTestId("scalar-title").findByText("Trend title nav").realClick();++ cy.location("pathname").should("match", /^\/question\//);+ H.queryBuilderHeader()+ .findByDisplayValue("Trend title nav")+ .should("be.visible");+ });++ it("should open the description tooltip and comparison panel with keyboard navigation", () => {+ H.createQuestionAndDashboard({+ questionDetails: {+ name: "Trend keyboard",+ description: "Trend keyboard description",+ query: TREND_QUERY,+ display: "smartscalar",+ visualization_settings: {+ "scalar.comparisons": [+ { id: "1", type: "previousPeriod" },+ { id: "2", type: "periodsAgo", value: 2 },+ ],+ },+ },+ cardDetails: { size_x: 8, size_y: 4 },+ }).then(({ body: { dashboard_id } }) => {+ H.visitDashboard(dashboard_id);+ });++ // the hover-hidden description icon is the next tab stop after the+ // title link; focusing it reveals it and opens its tooltip+ cy.findByTestId("scalar-title").findByTestId("legend-label").focus();+ cy.realPress("Tab");++ cy.focused().should("have.css", "opacity", "1");+ cy.findByRole("tooltip")+ .findByText("Trend keyboard description")+ .should("be.visible");++ // the comparison row is the tab stop after the icon+ cy.realPress("Tab");++ cy.findByTestId("scalar-previous-value").should("have.focus");+ cy.findByRole("tooltip")+ .findByText("vs. previous month")+ .should("be.visible");++ // moving keyboard focus back to the title link shows a visible ring+ cy.realPress(["Shift", "Tab"]);+ cy.realPress(["Shift", "Tab"]);+ cy.findByTestId("scalar-title")+ .findByTestId("legend-label")+ .should("have.focus")+ .then(($link) => {+ const styles = getComputedStyle($link[0]);+ const brandColor = getComputedStyle(+ $link[0].ownerDocument.documentElement,+ )+ .getPropertyValue("--mb-color-core-brand")+ .trim();++ expect(styles.outlineStyle).to.equal("solid");+ expect(parseFloat(styles.outlineWidth)).to.be.greaterThan(0);+ expect(Color(styles.outlineColor).hex()).to.equal(+ Color(brandColor).hex(),+ );+ });+ });++ it("should show the full comparison list in public question views", () => {+ H.createQuestion({+ name: "Public trend",+ query: TREND_QUERY,+ display: "smartscalar",+ visualization_settings: {+ "scalar.comparisons": [+ { id: "1", type: "previousPeriod" },+ { id: "2", type: "periodsAgo", value: 2 },+ { id: "3", type: "staticNumber", value: 500, label: "Goal" },+ ],+ },+ }).then(({ body: { id } }) => {+ H.visitPublicQuestion(id);+ });++ // the standalone question view lists every comparison instead of the+ // dashboard-style compact row with a "+N" badge+ cy.findByTestId("scalar-comparison-list")+ .children()+ .should("have.length", 3);+ cy.findByTestId("scalar-period").should("have.text", "Apr 2029");+ cy.findByTestId("scalar-content").findByText("+2").should("not.exist");+ });+});diff --git a/e2e/test/scenarios/visualizations-tabular/visualizations-tabular-reproductions.cy.spec.js b/e2e/test/scenarios/visualizations-tabular/visualizations-tabular-reproductions.cy.spec.jsindex 2ec6a4b11bc..a0295b6f487 100644--- a/e2e/test/scenarios/visualizations-tabular/visualizations-tabular-reproductions.cy.spec.js+++ b/e2e/test/scenarios/visualizations-tabular/visualizations-tabular-reproductions.cy.spec.js@@ -971,8 +971,8 @@ describe("issue 50686", () => {it("should allow selecting more than 1 comparison (metabase#50686)", () => {H.createNativeQuestion(questionDetails, { visitQuestion: true });- // Default comparison- H.queryBuilderMain().findByText("N/A");+ // Default comparison (a single one renders inline)+ H.queryBuilderMain().findByText("(No data)");// Add another comparisonH.openVizSettingsSidebar();@@ -983,10 +983,10 @@ describe("issue 50686", () => {H.queryBuilderMain().within(() => {// First comparison still exists- cy.findByText("N/A");+ cy.findByText("N/A (No data)");// New comparison has been added- cy.findByText("9.09%");+ cy.findByText("-9.09% (110)");cy.contains("vs. FORECAST");});});diff --git a/frontend/src/metabase-types/api/card.ts b/frontend/src/metabase-types/api/card.tsindex 6093b7606f8..531a3cdbcee 100644--- a/frontend/src/metabase-types/api/card.ts+++ b/frontend/src/metabase-types/api/card.ts@@ -451,6 +451,9 @@ export type VisualizationSettings = {/** Use compact formatting for the primary scalar number. */"scalar.compact_primary_number"?: boolean;+ /** Show the absolute comparison value next to the percent change in trend cards. */+ "scalar.show_comparison_value"?: boolean;+/** Segment configuration for scalar visualizations. */"scalar.segments"?: ScalarSegment[];diff --git a/frontend/src/metabase-types/api/icon.ts b/frontend/src/metabase-types/api/icon.tsindex 9194e16237b..e20dcf13277 100644--- a/frontend/src/metabase-types/api/icon.ts+++ b/frontend/src/metabase-types/api/icon.ts@@ -273,6 +273,9 @@ export type IconName =| "trash"| "trash_filled"| "treemap"+ | "trend_down"+ | "trend_flat"+ | "trend_up"| "triangle_left"| "triangle_right"| "unarchive"diff --git a/frontend/src/metabase/css/query_builder.module.css b/frontend/src/metabase/css/query_builder.module.cssindex 104bf04b835..9660ee0386a 100644--- a/frontend/src/metabase/css/query_builder.module.css+++ b/frontend/src/metabase/css/query_builder.module.css@@ -287,11 +287,6 @@font-weight: bold;}-/* need to do this ugliness to override the locally scoped font size from Scalar.css */-.QueryBuilder .ScalarValue {- font-size: 5em;-}-.Overlay {background-color: color-mix(in srgb,diff --git a/frontend/src/metabase/dashboard/components/DashCard/DashCard.module.css b/frontend/src/metabase/dashboard/components/DashCard/DashCard.module.cssindex 5d8e477859e..ffde801690c 100644--- a/frontend/src/metabase/dashboard/components/DashCard/DashCard.module.css+++ b/frontend/src/metabase/dashboard/components/DashCard/DashCard.module.css@@ -17,6 +17,17 @@.DashCardRoot {background-color: var(--mb-color-bg-dashboard-card);scroll-margin: 6px 0;+ border-radius: 0.75rem;+ border: 1px solid var(--mb-color-border);+ transition: border-color 0.15s ease-in-out;++ &:hover {+ border-color: var(--mb-color-border-strong);+ }++ &.isAction {+ border: none !important;+ }&.hasHiddenBackground {border: 0 !important;@@ -32,3 +43,44 @@}}}++.DashCardMenuButton {+ flex: none;+ opacity: 0;+}++.DashCardMenuButton.DashCardMenuButton[data-variant="subtle"] {+ width: 1.5rem;+ min-width: 1.5rem;+ height: 1rem;+ min-height: 1rem;+ border-radius: var(--mantine-radius-xs);+ color: var(--mb-color-text-primary);+ background: var(--mb-color-background_surface-primary);+ box-shadow:+ 0 0 0 0.5px var(--mb-color-border-neutral-subtle),+ 0 1px 3px 0 var(--mb-color-border-neutral-subtle);++ &:hover {+ color: var(--mb-color-text-primary);+ background: var(--mb-color-background_surface-primary-hover);+ }++ &:active {+ background: var(--mb-color-background_surface-primary-pressed);+ box-shadow: none;+ transform: none;+ }+}++.DashCardRoot:hover .DashCardMenuButton,+.DashCardMenuButton:focus-visible,+.DashCardMenuButton[aria-expanded="true"] {+ opacity: 1;+}++@media (hover: none) and (pointer: coarse) {+ .DashCardMenuButton {+ opacity: 1;+ }+}diff --git a/frontend/src/metabase/dashboard/components/DashCard/DashCard.tsx b/frontend/src/metabase/dashboard/components/DashCard/DashCard.tsxindex d47ab2b527f..ff8a1299eff 100644--- a/frontend/src/metabase/dashboard/components/DashCard/DashCard.tsx+++ b/frontend/src/metabase/dashboard/components/DashCard/DashCard.tsx@@ -356,8 +356,6 @@ function DashCardInner({DashboardS.Card,EmbedFrameS.Card,CS.relative,- CS.roundedSm,- !isAction && CS.bordered,CS.flex,CS.flexColumn,CS.hoverParent,@@ -366,6 +364,7 @@ function DashCardInner({[S.hasHiddenBackground]: hasHiddenBackground,[S.shouldForceHiddenBackground]: shouldForceHiddenBackground,[S.isEmbeddingSdk]: isEmbeddingSdk(),+ [S.isAction]: isAction,},className,)}diff --git a/frontend/src/metabase/dashboard/components/DashCard/DashCardMenu/DashCardMenu.tsx b/frontend/src/metabase/dashboard/components/DashCard/DashCardMenu/DashCardMenu.tsxindex 5a7b9f1feaa..a0808b0e1a5 100644--- a/frontend/src/metabase/dashboard/components/DashCard/DashCardMenu/DashCardMenu.tsx+++ b/frontend/src/metabase/dashboard/components/DashCard/DashCardMenu/DashCardMenu.tsx@@ -1,5 +1,4 @@import { useDisclosure } from "@mantine/hooks";-import cx from "classnames";import { useMemo, useState } from "react";import { t } from "ttag";@@ -14,15 +13,15 @@ import {import { getParameterValuesBySlugMap } from "metabase/dashboard/selectors";import { transformSdkQuestion } from "metabase/embedding-sdk/lib/transform-question";import { useStore } from "metabase/redux";-import { ActionIcon, Icon, Menu, type MenuProps } from "metabase/ui";+import { Icon, Menu, type MenuProps } from "metabase/ui";import { checkNotNull } from "metabase/utils/types";-import { SAVING_DOM_IMAGE_HIDDEN_CLASS } from "metabase/visualizations/lib/save-chart-image";import type Question from "metabase-lib/v1/Question";import { InternalQuery } from "metabase-lib/v1/queries/InternalQuery";import type { DashboardCard, Dataset } from "metabase-types/api";import { getDashcardTokenId, getDashcardUuid } from "../dashcard-ids";+import { DashCardMenuButton } from "./DashCardMenuButton";import { DashCardMenuItems } from "./DashCardMenuItems";interface DashCardMenuProps {@@ -149,16 +148,7 @@ export const DashCardMenu = ({return (<Menu offset={4} position={position} opened={isOpen} onClose={close}><Menu.Target>- <ActionIcon- size="xs"- className={cx({- [SAVING_DOM_IMAGE_HIDDEN_CLASS]: true,- })}- onClick={toggle}- data-testid="dashcard-menu"- >- <Icon name="ellipsis" />- </ActionIcon>+ <DashCardMenuButton onClick={toggle} data-testid="dashcard-menu" /></Menu.Target><Menu.Dropdown>{getMenuContent()}</Menu.Dropdown>diff --git a/frontend/src/metabase/dashboard/components/DashCard/DashCardMenu/DashCardMenu.unit.spec.tsx b/frontend/src/metabase/dashboard/components/DashCard/DashCardMenu/DashCardMenu.unit.spec.tsxindex b35c673fd83..90d91fe1903 100644--- a/frontend/src/metabase/dashboard/components/DashCard/DashCardMenu/DashCardMenu.unit.spec.tsx+++ b/frontend/src/metabase/dashboard/components/DashCard/DashCardMenu/DashCardMenu.unit.spec.tsx@@ -177,6 +177,23 @@ const setup = ({};describe("DashCardMenu", () => {+ it("supports opening and closing the menu with the keyboard", async () => {+ setup();++ const menuButton = screen.getByRole("button", { name: "More options" });+ menuButton.focus();++ await userEvent.keyboard("{Enter}");++ expect(await screen.findByText("Edit question")).toBeInTheDocument();+ expect(menuButton).toHaveAttribute("aria-expanded", "true");++ await userEvent.keyboard("{Escape}");++ expect(menuButton).toHaveAttribute("aria-expanded", "false");+ expect(menuButton).toHaveFocus();+ });+it("should display a link to the notebook editor", async () => {const { router } = setup();diff --git a/frontend/src/metabase/dashboard/components/DashCard/DashCardMenu/DashCardMenuButton.stories.tsx b/frontend/src/metabase/dashboard/components/DashCard/DashCardMenu/DashCardMenuButton.stories.tsxnew file mode 100644index 00000000000..88a44f3bfd1--- /dev/null+++ b/frontend/src/metabase/dashboard/components/DashCard/DashCardMenu/DashCardMenuButton.stories.tsx@@ -0,0 +1,72 @@+import type { Meta, StoryObj } from "@storybook/react";++import { Box, Group, Stack, Text } from "metabase/ui";+import { StoryBoard } from "metabase/ui/stories/showcase";++import S from "../DashCard.module.css";++import { DashCardMenuButton } from "./DashCardMenuButton";++const STATES = [+ { id: "card-default", label: "Card default" },+ { id: "card-hover", label: "Card hover" },+ { id: "button-hover", label: "Button hover" },+ { id: "button-pressed", label: "Button pressed" },+ { id: "button-focus", label: "Button focus" },+] as const;++const rowSelector = (id: (typeof STATES)[number]["id"]) =>+ `[data-state-row="${id}"]`;++const meta: Meta<typeof DashCardMenuButton> = {+ title: "App/Embed/DashCardMenuButton",+ component: DashCardMenuButton,+ parameters: {+ layout: "fullscreen",+ controls: { disable: true },+ pseudo: {+ hover: [+ `${rowSelector("card-hover")} [data-state-card]`,+ `${rowSelector("button-hover")} [data-state-card]`,+ `${rowSelector("button-hover")} button`,+ `${rowSelector("button-pressed")} [data-state-card]`,+ ],+ active: [`${rowSelector("button-pressed")} button`],+ focusVisible: [`${rowSelector("button-focus")} button`],+ },+ },+};++export default meta;+type Story = StoryObj<typeof DashCardMenuButton>;++export const States: Story = {+ render: () => (+ <StoryBoard+ title="Dash card menu button"+ background="background_page-primary"+ padding="2rem"+ >+ <Group align="flex-start" gap="xl">+ {STATES.map(({ id, label }) => (+ <Stack key={id} data-state-row={id} gap="sm">+ <Text c="text-secondary" size="sm">+ {label}+ </Text>+ <Box+ data-state-card+ className={S.DashCardRoot}+ pos="relative"+ w="12rem"+ h="6rem"+ >+ <Box pos="absolute" top="0.75rem" right="1rem">+ <DashCardMenuButton />+ </Box>+ </Box>+ </Stack>+ ))}+ </Group>+ </StoryBoard>+ ),+};diff --git a/frontend/src/metabase/dashboard/components/DashCard/DashCardMenu/DashCardMenuButton.tsx b/frontend/src/metabase/dashboard/components/DashCard/DashCardMenu/DashCardMenuButton.tsxnew file mode 100644index 00000000000..ea64be2c897--- /dev/null+++ b/frontend/src/metabase/dashboard/components/DashCard/DashCardMenu/DashCardMenuButton.tsx@@ -0,0 +1,33 @@+import cx from "classnames";+import type { ButtonHTMLAttributes, Ref } from "react";+import { forwardRef } from "react";+import { t } from "ttag";++import { ActionIcon, type ActionIconProps, Icon } from "metabase/ui";+import { SAVING_DOM_IMAGE_HIDDEN_CLASS } from "metabase/visualizations/lib/save-chart-image";++import S from "../DashCard.module.css";++export type DashCardMenuButtonProps = ActionIconProps &+ ButtonHTMLAttributes<HTMLButtonElement>;++export const DashCardMenuButton = forwardRef(function DashCardMenuButton(+ { className, ...props }: DashCardMenuButtonProps,+ ref: Ref<HTMLButtonElement>,+) {+ return (+ <ActionIcon+ ref={ref}+ aria-label={t`More options`}+ size="xs"+ {...props}+ className={cx(+ S.DashCardMenuButton,+ SAVING_DOM_IMAGE_HIDDEN_CLASS,+ className,+ )}+ >+ <Icon name="ellipsis" size={12} />+ </ActionIcon>+ );+});diff --git a/frontend/src/metabase/dashboard/components/DashCard/PublicOrEmbeddedDashCardMenu.tsx b/frontend/src/metabase/dashboard/components/DashCard/PublicOrEmbeddedDashCardMenu.tsxindex 050c7c3e6df..04c1ce81ae4 100644--- a/frontend/src/metabase/dashboard/components/DashCard/PublicOrEmbeddedDashCardMenu.tsx+++ b/frontend/src/metabase/dashboard/components/DashCard/PublicOrEmbeddedDashCardMenu.tsx@@ -1,5 +1,4 @@import { useDisclosure } from "@mantine/hooks";-import cx from "classnames";import { useMemo, useState } from "react";import { t } from "ttag";@@ -9,12 +8,12 @@ import { useDashboardContext } from "metabase/dashboard/context";import { getParameterValuesBySlugMap } from "metabase/dashboard/selectors";import { getMetadata } from "metabase/metadata-store";import { useSelector, useStore } from "metabase/redux";-import { ActionIcon, Icon, Menu } from "metabase/ui";+import { Icon, Menu } from "metabase/ui";import { checkNotNull } from "metabase/utils/types";-import { SAVING_DOM_IMAGE_HIDDEN_CLASS } from "metabase/visualizations/lib/save-chart-image";import Question from "metabase-lib/v1/Question";import type { DashboardCard, Dataset } from "metabase-types/api";+import { DashCardMenuButton } from "./DashCardMenu/DashCardMenuButton";import { getDashcardTokenId, getDashcardUuid } from "./dashcard-ids";type PublicOrEmbeddedDashCardMenuProps = {@@ -66,16 +65,10 @@ export const PublicOrEmbeddedDashCardMenu = ({trapFocus><Menu.Target>- <ActionIcon- size="xs"- className={cx({- [SAVING_DOM_IMAGE_HIDDEN_CLASS]: true,- })}+ <DashCardMenuButtononClick={toggle}data-testid="public-or-embedded-dashcard-menu"- >- <Icon name="ellipsis" />- </ActionIcon>+ /></Menu.Target><Menu.Dropdown>diff --git a/frontend/src/metabase/embedding-sdk/theme/embedding-color-palette.ts b/frontend/src/metabase/embedding-sdk/theme/embedding-color-palette.tsindex 0821feef583..49dd10c21f6 100644--- a/frontend/src/metabase/embedding-sdk/theme/embedding-color-palette.ts+++ b/frontend/src/metabase/embedding-sdk/theme/embedding-color-palette.ts@@ -46,8 +46,8 @@ export const SDK_TO_MAIN_APP_COLORS_MAPPING: Record<"background-disabled": ["background-disabled", "background_surface-disabled"],"background-light": ["background-secondary", "background_page-secondary"],shadow: ["shadow", "shadow-default"],- positive: ["success", "feedback-positive"],- negative: ["danger", "feedback-negative"],+ positive: ["success", "feedback-positive", "feedback-positive-strong"],+ negative: ["danger", "feedback-negative", "feedback-negative-strong"],"text-white": ["text-primary-inverse", "white", "core-white"],error: ["error", "feedback-negative"],"background-error": ["background-error", "background_surface-error"],diff --git a/frontend/src/metabase/embedding-sdk/types/question.ts b/frontend/src/metabase/embedding-sdk/types/question.tsindex c561b37f2a0..0d638555c0e 100644--- a/frontend/src/metabase/embedding-sdk/types/question.ts+++ b/frontend/src/metabase/embedding-sdk/types/question.ts@@ -123,13 +123,15 @@ export type PieVisualizationSettings = Pick</*** Settings for scalar, smart scalar, gauge, and progress displays. Use these to* select the main value column, compact the number, reverse comparison meaning,- * configure smart-scalar comparisons, or format columns.+ * configure smart-scalar comparisons and whether their absolute values are+ * shown, or format columns.*/export type ScalarVisualizationSettings = Pick<VisualizationSettings,| "scalar.field"| "scalar.switch_positive_negative"| "scalar.compact_primary_number"+ | "scalar.show_comparison_value"| "scalar.comparisons"| "column_settings">;diff --git a/frontend/src/metabase/public/containers/PublicOrEmbeddedQuestion/PublicOrEmbeddedQuestionView.tsx b/frontend/src/metabase/public/containers/PublicOrEmbeddedQuestion/PublicOrEmbeddedQuestionView.tsxindex 48099b0fa00..3fc53a2a6fa 100644--- a/frontend/src/metabase/public/containers/PublicOrEmbeddedQuestion/PublicOrEmbeddedQuestionView.tsx+++ b/frontend/src/metabase/public/containers/PublicOrEmbeddedQuestion/PublicOrEmbeddedQuestionView.tsx@@ -130,6 +130,7 @@ export function PublicOrEmbeddedQuestionView({// `isDashboard` is used by Visualization to change some visual behaviors// including the "No results" messageisDashboard+ isStandaloneQuestionmetadata={metadata}onChangeCardAndRun={() => {}}tableFooterExtraButtons={diff --git a/frontend/src/metabase/static-viz/components/SmartScalar/SmartScalar.stories.tsx b/frontend/src/metabase/static-viz/components/SmartScalar/SmartScalar.stories.tsxindex c2b818630fa..648d12beedc 100644--- a/frontend/src/metabase/static-viz/components/SmartScalar/SmartScalar.stories.tsx+++ b/frontend/src/metabase/static-viz/components/SmartScalar/SmartScalar.stories.tsx@@ -107,6 +107,7 @@ export default {"scalar.comparisons": [{ id: "1", type: "previousPeriod" }],"scalar.switch_positive_negative": false,"scalar.compact_primary_number": false,+ "scalar.show_comparison_value": true,},argTypes: {"scalar.field": {@@ -119,6 +120,9 @@ export default {"scalar.compact_primary_number": {control: { type: "boolean" },},+ "scalar.show_comparison_value": {+ control: { type: "boolean" },+ },},};diff --git a/frontend/src/metabase/static-viz/components/SmartScalar/SmartScalar.tsx b/frontend/src/metabase/static-viz/components/SmartScalar/SmartScalar.tsxindex 05cba8591af..c2e2e0779c6 100644--- a/frontend/src/metabase/static-viz/components/SmartScalar/SmartScalar.tsx+++ b/frontend/src/metabase/static-viz/components/SmartScalar/SmartScalar.tsx@@ -1,5 +1,6 @@import type { CSSProperties } from "react";+import { isEmpty } from "metabase/utils/validate";import {CHANGE_TYPE_OPTIONS,computeTrend,@@ -121,17 +122,23 @@ function Comparison({ comparison, renderingContext }: ComparisonProps) {},};+ const comparisonValue = comparison.display.comparisonValue;+ const hasComparisonValue = !isEmpty(comparisonValue);+ const description = hasComparisonValue+ ? `${comparison.comparisonDescStr}: `+ : comparison.comparisonDescStr;+return (<span style={styles.root}>{!!icon && <span style={styles.icon}>{icon}</span>}<span><span style={styles.percentChange}>{changeDisplayValue}</span>- <span style={styles.comparisonDescription}>- {`${comparison.comparisonDescStr}: `}- </span>- <span style={styles.comparisonValue}>- {comparison.display.comparisonValue}- </span>+ {!isEmpty(comparison.comparisonDescStr) && (+ <span style={styles.comparisonDescription}>{description}</span>+ )}+ {hasComparisonValue && (+ <span style={styles.comparisonValue}>{comparisonValue}</span>+ )}</span></span>);diff --git a/frontend/src/metabase/static-viz/components/SmartScalar/SmartScalar.unit.spec.tsx b/frontend/src/metabase/static-viz/components/SmartScalar/SmartScalar.unit.spec.tsxnew file mode 100644index 00000000000..ce4480c24ab--- /dev/null+++ b/frontend/src/metabase/static-viz/components/SmartScalar/SmartScalar.unit.spec.tsx@@ -0,0 +1,149 @@+import { render, screen } from "__support__/ui";+import { createColorGetter } from "metabase/static-viz/lib/colors";+import {+ measureTextHeight,+ measureTextWidth,+} from "metabase/static-viz/lib/text";+import { colors } from "metabase/ui/colors";+import { DEFAULT_VISUALIZATION_THEME } from "metabase/viz-core";+import type { RowValues, VisualizationSettings } from "metabase-types/api";+import {+ createMockColumn,+ createMockSingleSeries,+} from "metabase-types/api/mocks";++import { StaticVisualization } from "../StaticVisualization";++const COLS = [+ createMockColumn({+ name: "Date",+ base_type: "type/DateTime",+ effective_type: "type/DateTime",+ source: "breakout",+ }),+ createMockColumn({+ name: "Count",+ base_type: "type/Integer",+ effective_type: "type/Integer",+ source: "aggregation",+ }),+];++const setup = (rows: RowValues[], settings: VisualizationSettings = {}) => {+ const series = createMockSingleSeries(+ {+ display: "smartscalar",+ visualization_settings: {+ "scalar.field": "Count",+ "scalar.comparisons": [{ id: "1", type: "previousPeriod" }],+ ...settings,+ },+ },+ {+ data: {+ cols: COLS,+ rows,+ insights: [+ {+ unit: "month",+ col: "Count",+ offset: 0,+ slope: 0,+ "last-change": 0,+ "previous-value": 0,+ "last-value": 0,+ },+ ],+ },+ },+ );++ render(+ <StaticVisualization+ rawSeries={[series]}+ renderingContext={{+ fontFamily: "Lato",+ getColor: createColorGetter(colors),+ measureText: (text, style) =>+ measureTextWidth(text, Number(style.size), Number(style.weight)),+ measureTextHeight: (_, style) => measureTextHeight(Number(style.size)),+ theme: DEFAULT_VISUALIZATION_THEME,+ }}+ />,+ );+};++describe("static-viz SmartScalar", () => {+ it("should render a 0.00% change without an arrow when the value is unchanged", () => {+ setup([+ ["2019-10-01", 300],+ ["2019-11-01", 300],+ ]);++ expect(screen.getByText("0.00%")).toBeInTheDocument();+ expect(screen.queryByText("↑")).not.toBeInTheDocument();+ expect(screen.queryByText("↓")).not.toBeInTheDocument();+ });++ it("should treat a change that rounds to 0% as no change", () => {+ setup([+ ["2019-10-01", 1000000],+ ["2019-11-01", 1000000.01],+ ]);++ expect(screen.getByText("0.00%")).toBeInTheDocument();+ expect(screen.queryByText("↑")).not.toBeInTheDocument();+ });++ it("should render a changed comparison with an arrow", () => {+ setup([+ ["2019-10-01", 300],+ ["2019-11-01", 310],+ ]);++ expect(screen.getByText("3.33%")).toBeInTheDocument();+ expect(screen.getByText("↑")).toBeInTheDocument();+ });++ describe("scalar.show_comparison_value", () => {+ const hideComparisonValue = { "scalar.show_comparison_value": false };++ it("should show the comparison value by default", () => {+ setup([+ ["2019-10-01", 300],+ ["2019-11-01", 310],+ ]);++ expect(screen.getByText("vs. previous month:")).toBeInTheDocument();+ expect(screen.getByText("300")).toBeInTheDocument();+ });++ it("should hide the comparison value when the setting is off", () => {+ setup(+ [+ ["2019-10-01", 300],+ ["2019-11-01", 310],+ ],+ hideComparisonValue,+ );++ expect(screen.getByText("3.33%")).toBeInTheDocument();+ expect(screen.getByText("vs. previous month")).toBeInTheDocument();+ expect(screen.queryByText("300")).not.toBeInTheDocument();+ });++ it("should keep the (No data) status when the comparison value is hidden", () => {+ setup(+ [+ ["2019-10-01", null],+ ["2019-11-01", 310],+ ],+ hideComparisonValue,+ );++ expect(screen.getByText("N/A")).toBeInTheDocument();+ expect(screen.getByText("vs. previous month:")).toBeInTheDocument();+ expect(screen.getByText("(No data)")).toBeInTheDocument();+ });+ });+});diff --git a/frontend/src/metabase/ui/components/icons/Icon/icons/index.ts b/frontend/src/metabase/ui/components/icons/Icon/icons/index.tsindex d42bef199c8..ac1761918b4 100644--- a/frontend/src/metabase/ui/components/icons/Icon/icons/index.ts+++ b/frontend/src/metabase/ui/components/icons/Icon/icons/index.ts@@ -278,6 +278,9 @@ import transform_component from "./transform.svg?component";import trash_component from "./trash.svg?component";import trash_filled_component from "./trash_filled.svg?component";import treemap_component from "./treemap.svg?component";+import trend_down_component from "./trend_down.svg?component";+import trend_flat_component from "./trend_flat.svg?component";+import trend_up_component from "./trend_up.svg?component";import triangle_left_component from "./triangle_left.svg?component";import triangle_right_component from "./triangle_right.svg?component";import unarchive_component from "./unarchive.svg?component";@@ -576,6 +579,9 @@ export const Icons: Record<IconName, React.VFC> = {trash: trash_component,trash_filled: trash_filled_component,treemap: treemap_component,+ trend_down: trend_down_component,+ trend_flat: trend_flat_component,+ trend_up: trend_up_component,triangle_left: triangle_left_component,triangle_right: triangle_right_component,unarchive: unarchive_component,diff --git a/frontend/src/metabase/ui/components/icons/Icon/icons/trend_down.svg b/frontend/src/metabase/ui/components/icons/Icon/icons/trend_down.svgnew file mode 100644index 00000000000..733504cd977--- /dev/null+++ b/frontend/src/metabase/ui/components/icons/Icon/icons/trend_down.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 16 16" fill="currentcolor" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">+ <path d="M13.3599 3.375C14.3029 3.37531 14.827 4.46662 14.2378 5.20312L8.68309 12.1465C8.33284 12.5841 7.66718 12.5841 7.31688 12.1465L1.76122 5.20312C1.17213 4.46658 1.697 3.37518 2.64012 3.375H13.3599Z" />+</svg>diff --git a/frontend/src/metabase/ui/components/icons/Icon/icons/trend_flat.svg b/frontend/src/metabase/ui/components/icons/Icon/icons/trend_flat.svgnew file mode 100644index 00000000000..e004095aa14--- /dev/null+++ b/frontend/src/metabase/ui/components/icons/Icon/icons/trend_flat.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 16 16" fill="currentcolor" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">+ <path d="M1 8C1 6.61929 2.11929 5.5 3.5 5.5H12.5C13.8807 5.5 15 6.61929 15 8C15 9.38071 13.8807 10.5 12.5 10.5H3.5C2.11929 10.5 1 9.38071 1 8Z" />+</svg>diff --git a/frontend/src/metabase/ui/components/icons/Icon/icons/trend_up.svg b/frontend/src/metabase/ui/components/icons/Icon/icons/trend_up.svgnew file mode 100644index 00000000000..e5d66a47606--- /dev/null+++ b/frontend/src/metabase/ui/components/icons/Icon/icons/trend_up.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 16 16" fill="currentcolor" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">+ <path d="M7.31693 3.85346C7.66721 3.41583 8.33287 3.41582 8.68314 3.85346L14.2378 10.7968C14.827 11.5334 14.3031 12.6248 13.3599 12.6249H2.64017C1.75603 12.6247 1.24028 11.6661 1.66458 10.9394L1.76224 10.7968L7.31693 3.85346Z" />+</svg>diff --git a/frontend/src/metabase/visualizations/components/ScalarValue/ScalarActionButtons.tsx b/frontend/src/metabase/visualizations/components/ScalarValue/ScalarActionButtons.tsxnew file mode 100644index 00000000000..41c5f4c3565--- /dev/null+++ b/frontend/src/metabase/visualizations/components/ScalarValue/ScalarActionButtons.tsx@@ -0,0 +1,27 @@+import type { HTMLAttributes, PropsWithChildren } from "react";++import { Box } from "metabase/ui";++import type { ScalarSizeTier } from "./sizing";++export const ScalarActionButtons = ({+ children,+ tier,+ ...props+}: PropsWithChildren<{ tier: ScalarSizeTier }> &+ HTMLAttributes<HTMLDivElement>) => {+ if (!children) {+ return null;+ }+ return (+ <Box+ pos="absolute"+ top={tier.menuOffset.top}+ right={tier.menuOffset.right}+ data-testid="scalar-action-buttons"+ {...props}+ >+ {children}+ </Box>+ );+};diff --git a/frontend/src/metabase/visualizations/components/ScalarValue/ScalarCardShell.tsx b/frontend/src/metabase/visualizations/components/ScalarValue/ScalarCardShell.tsxnew file mode 100644index 00000000000..b41c4e7757f--- /dev/null+++ b/frontend/src/metabase/visualizations/components/ScalarValue/ScalarCardShell.tsx@@ -0,0 +1,134 @@+import { Children, type ReactNode, useState } from "react";++import { useTranslateContent } from "metabase/content-translation/hooks";+import { Stack, Tooltip } from "metabase/ui";+import { getRootFontScale } from "metabase/visualizations/lib/scalar_utils";+import type {+ VisualizationPassThroughProps,+ VisualizationProps,+} from "metabase/visualizations/types";++import { ScalarActionButtons } from "./ScalarActionButtons";+import { ScalarTitle } from "./ScalarTitle";+import { ScalarWrapper } from "./ScalarValue";+import { type ScalarSizeTier, getScalarSizeTier } from "./sizing";++const TITLE_TOOLTIP_OFFSET = 1;++type ScalarCardProps = VisualizationProps & VisualizationPassThroughProps;++interface UseScalarCardShellOptions {+ hideTitle?: boolean;+}++export function useScalarCardShell(+ {+ settings,+ width,+ showTitle,+ height,+ getHref,+ onChangeCardAndRun,+ isVisualizerCard,+ visualizerRawSeries,+ titleMenuItems,+ headerIcon,+ rawSeries,+ isDashboard,+ isEditing,+ }: ScalarCardProps,+ { hideTitle = false }: UseScalarCardShellOptions = {},+) {+ const [isInnerTooltipHovered, setIsInnerTooltipHovered] = useState(false);+ const innerTooltipHoverHandlers = {+ onMouseEnter: () => setIsInnerTooltipHovered(true),+ onMouseLeave: () => setIsInnerTooltipHovered(false),+ };++ const tier = getScalarSizeTier(width, height);+ const rootFontScale = getRootFontScale();+ const availableWidth = Math.max(width - 2 * tier.xPadding * rootFontScale, 0);++ const tc = useTranslateContent();+ const title = showTitle && !hideTitle ? tc(settings["card.title"]) : null;+ const showsInlineTitle = Boolean(title) && tier.showsTitle;+ const showsTitleOnHover = Boolean(title) && !tier.showsTitle;+ const description =+ isDashboard && isEditing ? null : settings["card.description"];++ const canSelectTitle =+ onChangeCardAndRun != null &&+ (!isVisualizerCard || Children.count(titleMenuItems) === 1);+ const handleSelectTitle = () =>+ onChangeCardAndRun?.({+ nextCard: (visualizerRawSeries ?? rawSeries)[0].card,+ });++ const showsTitleTooltip = showsTitleOnHover && !isInnerTooltipHovered;++ const titleElement = showsInlineTitle ? (+ <ScalarTitle+ description={description}+ icon={headerIcon}+ getHref={canSelectTitle ? getHref : undefined}+ onSelectTitle={canSelectTitle ? handleSelectTitle : undefined}+ >+ {title}+ </ScalarTitle>+ ) : null;++ return {+ tier,+ rootFontScale,+ availableWidth,+ title,+ titleElement,+ showsTitleTooltip,+ innerTooltipHoverHandlers,+ };+}++interface ScalarCardShellProps {+ tier: ScalarSizeTier;+ title: ReactNode;+ showsTitleTooltip: boolean;+ actionButtons: ReactNode;+ innerTooltipHoverHandlers: {+ onMouseEnter: () => void;+ onMouseLeave: () => void;+ };+ children: ReactNode;+}++export function ScalarCardShell({+ tier,+ title,+ showsTitleTooltip,+ actionButtons,+ innerTooltipHoverHandlers,+ children,+}: ScalarCardShellProps) {+ return (+ <Tooltip+ label={title}+ disabled={!showsTitleTooltip}+ position="top"+ offset={TITLE_TOOLTIP_OFFSET}+ >+ <ScalarWrapper xPadding={tier.xPadding}>+ <ScalarActionButtons tier={tier} {...innerTooltipHoverHandlers}>+ {actionButtons}+ </ScalarActionButtons>+ <Stack+ pos="relative"+ align="center"+ gap={tier.valueTitleGap}+ maw="100%"+ data-testid="scalar-content"+ >+ {children}+ </Stack>+ </ScalarWrapper>+ </Tooltip>+ );+}diff --git a/frontend/src/metabase/visualizations/components/ScalarValue/ScalarTitle.tsx b/frontend/src/metabase/visualizations/components/ScalarValue/ScalarTitle.tsxnew file mode 100644index 00000000000..7d4d74252f8--- /dev/null+++ b/frontend/src/metabase/visualizations/components/ScalarValue/ScalarTitle.tsx@@ -0,0 +1,103 @@+import cx from "classnames";+import { type ReactNode, useCallback, useState } from "react";++import { Markdown } from "metabase/common/components/Markdown";+import { useTranslateContent } from "metabase/content-translation/hooks";+import CS from "metabase/css/core/index.css";+import {+ Box,+ Ellipsified,+ Flex,+ Icon,+ type IconProps,+ Tooltip,+} from "metabase/ui";++import { LegendLabel } from "../legend/LegendLabel";++import S from "./ScalarValue.module.css";++interface ScalarTitleProps {+ children: ReactNode;+ description?: string | null;+ icon?: IconProps | null;+ getHref?: () => string | undefined;+ onSelectTitle?: () => void;+}++export const ScalarTitle = ({+ children,+ description,+ icon,+ getHref,+ onSelectTitle,+}: ScalarTitleProps) => {+ const [href, setHref] = useState(() => getHref?.());+ const computeHref = useCallback(() => {+ if (getHref) {+ setHref(getHref());+ }+ }, [getHref]);++ const tc = useTranslateContent();+ const title = <Ellipsified tooltip={children}>{children}</Ellipsified>;++ return (+ <Flex+ align="center"+ justify="center"+ gap="xs"+ maw="100%"+ data-testid="scalar-title"+ >+ {icon && (+ <Icon+ className={S.titleIcon}+ name={icon.name}+ color={icon.color}+ size={icon.size}+ tooltip={icon.tooltip}+ />+ )}+ <Box fz="md" lh="md" fw={700} c="text-primary" ta="center" miw={0}>+ {onSelectTitle ? (+ <LegendLabel+ className={S.titleLink}+ href={href}+ onClick={onSelectTitle}+ onFocus={computeHref}+ onMouseEnter={computeHref}+ onMouseDown={computeHref}+ onTouchStart={computeHref}+ >+ {title}+ </LegendLabel>+ ) : (+ title+ )}+ </Box>+ {description && (+ <Tooltip+ label={+ <Markdown dark compact disallowHeading unstyleLinks lineClamp={8}>+ {tc(description)}+ </Markdown>+ }+ maw="22em"+ >+ <Box+ component="span"+ tabIndex={0}+ className={cx(+ S.descriptionIcon,+ CS.hoverChild,+ CS.hoverChildSmooth,+ )}+ >+ <Icon name="info" />+ </Box>+ </Tooltip>+ )}+ </Flex>+ );+};diff --git a/frontend/src/metabase/visualizations/components/ScalarValue/ScalarValue.module.css b/frontend/src/metabase/visualizations/components/ScalarValue/ScalarValue.module.cssindex a890cd5dade..d10493aadd7 100644--- a/frontend/src/metabase/visualizations/components/ScalarValue/ScalarValue.module.css+++ b/frontend/src/metabase/visualizations/components/ScalarValue/ScalarValue.module.css@@ -10,3 +10,41 @@.hoverable:hover {color: var(--mb-color-core-brand);}++.titleLink {+ && {+ line-height: inherit;+ }++ &&:focus-visible {+ outline: 2px solid var(--mb-color-core-brand);+ outline-offset: 2px;+ border-radius: 4px;+ }+}++.titleIcon {+ flex: 0 0 auto;+}++.descriptionIcon {+ display: flex;+ flex: 0 0 auto;+ color: var(--mb-color-text-disabled);++ &&&& {+ visibility: visible;+ }++ &&&&:hover {+ color: var(--mb-color-text-secondary);+ }++ &&&&:focus-visible {+ opacity: 1;+ color: var(--mb-color-text-secondary);+ outline: 2px solid var(--mb-color-core-brand);+ outline-offset: 2px;+ border-radius: 4px;+ }+}diff --git a/frontend/src/metabase/visualizations/components/ScalarValue/ScalarValue.tsx b/frontend/src/metabase/visualizations/components/ScalarValue/ScalarValue.tsxindex df4f2fd1f5e..e3d49676848 100644--- a/frontend/src/metabase/visualizations/components/ScalarValue/ScalarValue.tsx+++ b/frontend/src/metabase/visualizations/components/ScalarValue/ScalarValue.tsx@@ -1,52 +1,47 @@-/*- * Shared component for Scalar and SmartScalar to make sure our number presentation stays in sync- */import cx from "classnames";-import { type PropsWithChildren, useMemo } from "react";+import { type HTMLAttributes, type PropsWithChildren, forwardRef } from "react";import { t } from "ttag";import DashboardS from "metabase/css/dashboard.module.css";-import QueryBuilderS from "metabase/css/query_builder.module.css";import { Box, Flex, useMantineTheme } from "metabase/ui";-import type { VisualizationGridSize } from "metabase/viz-core";import S from "./ScalarValue.module.css";-import { findSize, getMaxFontSize } from "./utils";-export const ScalarWrapper = ({ children }: PropsWithChildren) => (- <Flex- pos="relative"- direction="column"- wrap="wrap"- justify="center"- align="center"- flex={1}- w="100%"- h="100%"- data-testid="scalar-root"- >- {children}- </Flex>+type ScalarWrapperProps = PropsWithChildren<{ xPadding?: number }> &+ HTMLAttributes<HTMLDivElement>;++export const ScalarWrapper = forwardRef<HTMLDivElement, ScalarWrapperProps>(+ function ScalarWrapper({ children, xPadding, ...props }, ref) {+ return (+ <Flex+ ref={ref}+ pos="relative"+ direction="column"+ justify="center"+ align="center"+ flex={1}+ w="100%"+ h="100%"+ px={xPadding}+ data-testid="scalar-root"+ {...props}+ >+ {children}+ </Flex>+ );+ },);interface ScalarValueProps {value: string;- height: number;- width: number;- gridSize?: VisualizationGridSize;- totalNumGridCols?: number;- fontFamily: string;+ fontSize: number;color?: string;disableHover?: boolean;}export const ScalarValue = ({value,- height,- width,- gridSize,- totalNumGridCols,- fontFamily,+ fontSize,color = "inherit",disableHover,}: ScalarValueProps) => {@@ -54,45 +49,16 @@ export const ScalarValue = ({other: { number: numberTheme },} = useMantineTheme();- const fontSize = useMemo(() => {- if (numberTheme?.value?.fontSize) {- return numberTheme.value?.fontSize;- }-- return findSize({- text: value,- targetHeight: height,- targetWidth: width,- fontFamily: fontFamily ?? "Lato",- fontWeight: 700,- unit: "rem",- step: 0.2,- min: 1,- max: gridSize- ? getMaxFontSize(gridSize.width, totalNumGridCols, width)- : 4,- });- }, [- fontFamily,- gridSize,- height,- totalNumGridCols,- value,- width,- numberTheme?.value?.fontSize,- ]);-return (<Boxcomponent="h1"className={cx(DashboardS.ScalarValue,- QueryBuilderS.ScalarValue,S.value,!disableHover && S.hoverable,)}- fz={fontSize}- lh={numberTheme?.value?.lineHeight}+ fz={numberTheme?.value?.fontSize ?? fontSize}+ lh={numberTheme?.value?.lineHeight ?? 1}data-testid="scalar-value"// Route color through a CSS variable so `S.hoverable:hover` can override (inline `style` would beat the class on specificity).style={{ "--scalar-value-color": color }}diff --git a/frontend/src/metabase/visualizations/components/ScalarValue/sizing.ts b/frontend/src/metabase/visualizations/components/ScalarValue/sizing.tsnew file mode 100644index 00000000000..84642b68963--- /dev/null+++ b/frontend/src/metabase/visualizations/components/ScalarValue/sizing.ts@@ -0,0 +1,110 @@+export interface ScalarSizeTier {+ minWidth: number;+ minHeight: number;+ xPadding: number;+ valueFontSize: number;+ valueTitleGap: number;+ symbolSize: number;+ symbolGap: number;+ comparisonGap: number;+ menuOffset: { top: number; right: number };+ showsTitle: boolean;+ skeleton: { valueWidth: number; valueHeight: number; titleWidth: number };+}++const SMALL_MENU_OFFSET = { top: 12, right: 16 };+const LARGE_MENU_OFFSET = { top: 22, right: 24 };++// Largest tier first; a card gets the first tier it fits both dimensions of.+// Values come from the "Charts visual improvements" Figma spec (node 314-478);+// skeleton pill sizes come from the loading states spec (node 431-1518).+export const SCALAR_SIZE_TIERS: readonly ScalarSizeTier[] = [+ {+ minWidth: 600,+ minHeight: 320,+ xPadding: 48,+ valueFontSize: 64,+ valueTitleGap: 32,+ symbolSize: 24,+ symbolGap: 20,+ comparisonGap: 12,+ menuOffset: LARGE_MENU_OFFSET,+ showsTitle: true,+ skeleton: { valueWidth: 200, valueHeight: 32, titleWidth: 256 },+ },+ {+ minWidth: 500,+ minHeight: 240,+ xPadding: 40,+ valueFontSize: 56,+ valueTitleGap: 24,+ symbolSize: 20,+ symbolGap: 16,+ comparisonGap: 12,+ menuOffset: LARGE_MENU_OFFSET,+ showsTitle: true,+ skeleton: { valueWidth: 160, valueHeight: 32, titleWidth: 256 },+ },+ {+ minWidth: 400,+ minHeight: 200,+ xPadding: 32,+ valueFontSize: 48,+ valueTitleGap: 16,+ symbolSize: 20,+ symbolGap: 16,+ comparisonGap: 8,+ menuOffset: LARGE_MENU_OFFSET,+ showsTitle: true,+ skeleton: { valueWidth: 96, valueHeight: 32, titleWidth: 128 },+ },+ {+ minWidth: 320,+ minHeight: 160,+ xPadding: 24,+ valueFontSize: 40,+ valueTitleGap: 16,+ symbolSize: 16,+ symbolGap: 12,+ comparisonGap: 8,+ menuOffset: SMALL_MENU_OFFSET,+ showsTitle: true,+ skeleton: { valueWidth: 72, valueHeight: 24, titleWidth: 128 },+ },+ {+ minWidth: 160,+ minHeight: 120,+ xPadding: 24,+ valueFontSize: 32,+ valueTitleGap: 12,+ symbolSize: 16,+ symbolGap: 8,+ comparisonGap: 6,+ menuOffset: SMALL_MENU_OFFSET,+ showsTitle: true,+ skeleton: { valueWidth: 72, valueHeight: 24, titleWidth: 128 },+ },+ {+ minWidth: 0,+ minHeight: 0,+ xPadding: 8,+ valueFontSize: 17,+ valueTitleGap: 6,+ symbolSize: 12,+ symbolGap: 6,+ comparisonGap: 6,+ menuOffset: SMALL_MENU_OFFSET,+ showsTitle: false,+ skeleton: { valueWidth: 40, valueHeight: 17, titleWidth: 128 },+ },+];++export const getScalarSizeTier = (+ width: number,+ height: number,+): ScalarSizeTier => {+ const tier = SCALAR_SIZE_TIERS.find(+ (tier) => width >= tier.minWidth && height >= tier.minHeight,+ );+ return tier ?? SCALAR_SIZE_TIERS[SCALAR_SIZE_TIERS.length - 1];+};diff --git a/frontend/src/metabase/visualizations/components/ScalarValue/sizing.unit.spec.ts b/frontend/src/metabase/visualizations/components/ScalarValue/sizing.unit.spec.tsnew file mode 100644index 00000000000..07bd08d78f8--- /dev/null+++ b/frontend/src/metabase/visualizations/components/ScalarValue/sizing.unit.spec.ts@@ -0,0 +1,30 @@+import { SCALAR_SIZE_TIERS, getScalarSizeTier } from "./sizing";++describe("getScalarSizeTier", () => {+ it("returns the smallest tier for tiny cards", () => {+ expect(getScalarSizeTier(80, 80)).toBe(+ SCALAR_SIZE_TIERS[SCALAR_SIZE_TIERS.length - 1],+ );+ expect(getScalarSizeTier(0, 0).valueFontSize).toBe(17);+ });++ it("requires both dimensions to fit before upgrading the tier", () => {+ // wide but short card stays on the tier its height allows+ expect(getScalarSizeTier(800, 130).valueFontSize).toBe(32);+ // tall but narrow card stays on the tier its width allows+ expect(getScalarSizeTier(180, 800).valueFontSize).toBe(32);+ });++ it("picks tiers by the spec thresholds", () => {+ expect(getScalarSizeTier(160, 120).valueFontSize).toBe(32);+ expect(getScalarSizeTier(320, 160).valueFontSize).toBe(40);+ expect(getScalarSizeTier(400, 200).valueFontSize).toBe(48);+ expect(getScalarSizeTier(500, 240).valueFontSize).toBe(56);+ expect(getScalarSizeTier(600, 320).valueFontSize).toBe(64);+ });++ it("hides the title only on the smallest tier", () => {+ expect(getScalarSizeTier(100, 100).showsTitle).toBe(false);+ expect(getScalarSizeTier(160, 120).showsTitle).toBe(true);+ });+});diff --git a/frontend/src/metabase/visualizations/components/ScalarValue/utils.ts b/frontend/src/metabase/visualizations/components/ScalarValue/utils.tsdeleted file mode 100644index 6a1b55fbec6..00000000000--- a/frontend/src/metabase/visualizations/components/ScalarValue/utils.ts+++ /dev/null@@ -1,72 +0,0 @@-import { DEFAULT_CARD_SIZE, GRID_WIDTH } from "metabase/utils/dashboard_grid";-import { measureText } from "metabase/utils/measure-text";--interface FindSizeInput {- text: string;- targetHeight: number;- targetWidth: number;- unit: "rem";- fontFamily: string;- fontWeight: string | number;- step: number;- min: number;- max: number;-}--export const findSize = ({- text,- targetHeight,- targetWidth,- unit,- fontFamily,- fontWeight,- step,- min,- max,-}: FindSizeInput) => {- let size = max;- let metrics = measureText(text, {- size: `${size}${unit}`,- family: fontFamily,- weight: fontWeight,- });-- while (- (metrics.width > targetWidth || metrics.height > targetHeight) &&- size > min- ) {- size = Math.max(size - step, min);-- metrics = measureText(text, {- size: `${size}${unit}`,- family: fontFamily,- weight: fontWeight,- });- }-- return `${size}${unit}`;-};--const MAX_SIZE_SMALL = 2.2;-const MAX_SIZE_LARGE = 7;--const NARROW_CARD_WIDTH = 240;-const NARROW_CARD_MAX_SIZE = 2.5;--export const getMaxFontSize = (- cardColWidth: number,- totalCols: number | undefined,- cardWidth: number | undefined,-) => {- if (totalCols != null && totalCols < DEFAULT_CARD_SIZE.width) {- return MAX_SIZE_SMALL;- }-- const size =- (cardColWidth / GRID_WIDTH) * (MAX_SIZE_LARGE - MAX_SIZE_SMALL) +- MAX_SIZE_SMALL;- if (cardWidth != null && cardWidth < NARROW_CARD_WIDTH) {- return NARROW_CARD_MAX_SIZE;- }- return size;-};diff --git a/frontend/src/metabase/visualizations/components/ScalarValue/utils.unit.spec.ts b/frontend/src/metabase/visualizations/components/ScalarValue/utils.unit.spec.tsdeleted file mode 100644index 240516093fd..00000000000--- a/frontend/src/metabase/visualizations/components/ScalarValue/utils.unit.spec.ts+++ /dev/null@@ -1,129 +0,0 @@-import type { FontStyle } from "metabase/utils/measure-text";-import * as measureText from "metabase/utils/measure-text";--import { findSize } from "./utils";--jest.doMock("metabase/utils/measure-text", () => ({- measureText: jest.fn(),-}));--const createMockMeasureText = (width: number, height: number) => {- return (_text: string, _style: FontStyle) => ({ width, height });-};--const defaults = {- text: "test",- unit: "rem" as const,- fontFamily: "Lato",- fontWeight: "900",-};--describe("findSize", () => {- let measureTextSpy: jest.SpyInstance;-- beforeEach(() => {- measureTextSpy = jest.spyOn(measureText, "measureText");- });-- afterEach(() => {- measureTextSpy.mockRestore();- });-- it("returns the max size if when text width is smaller than the target width", () => {- measureTextSpy.mockImplementation(createMockMeasureText(100, 50));-- const size = findSize({- ...defaults,- targetWidth: 100,- targetHeight: 100,- step: 0.2,- min: 2,- max: 5,- });-- expect(size).toEqual("5rem");- });-- it("returns the first size with which text width is smaller than the target width", () => {- measureTextSpy- .mockImplementationOnce(createMockMeasureText(120, 70))- .mockImplementationOnce(createMockMeasureText(110, 60))- .mockImplementationOnce(createMockMeasureText(100, 50)) // this is the one we want- .mockImplementationOnce(createMockMeasureText(90, 40));-- const size = findSize({- ...defaults,- targetWidth: 100,- targetHeight: 100,- step: 0.2,- min: 2,- max: 5,- });-- expect(size).toEqual("4.6rem");- });-- it("returns the min size if text cannot fit into the target width", () => {- measureTextSpy.mockImplementation(createMockMeasureText(120, 50));-- const size = findSize({- ...defaults,- targetWidth: 100,- targetHeight: 100,- step: 0.2,- min: 2,- max: 5,- });-- expect(size).toEqual("2rem");- });-- it("returns the max size if when text height is smaller than the target height", () => {- measureTextSpy.mockImplementation(createMockMeasureText(50, 100));-- const size = findSize({- ...defaults,- targetWidth: 100,- targetHeight: 100,- step: 0.2,- min: 2,- max: 5,- });-- expect(size).toEqual("5rem");- });-- it("returns the first size with which text height is smaller than the target height", () => {- measureTextSpy- .mockImplementationOnce(createMockMeasureText(70, 120))- .mockImplementationOnce(createMockMeasureText(60, 110))- .mockImplementationOnce(createMockMeasureText(50, 100)) // this is the one we want- .mockImplementationOnce(createMockMeasureText(40, 90));-- const size = findSize({- ...defaults,- targetWidth: 100,- targetHeight: 100,- step: 0.2,- min: 2,- max: 5,- });-- expect(size).toEqual("4.6rem");- });-- it("returns the min size if text cannot fit into the target height", () => {- measureTextSpy.mockImplementation(createMockMeasureText(50, 120));-- const size = findSize({- ...defaults,- targetWidth: 100,- targetHeight: 100,- step: 0.2,- min: 2,- max: 5,- });-- expect(size).toEqual("2rem");- });-});diff --git a/frontend/src/metabase/visualizations/components/Visualization/LoadingView/DashCardLoadingView.tsx b/frontend/src/metabase/visualizations/components/Visualization/LoadingView/DashCardLoadingView.tsxindex 3e2483dbc32..d888c49bcb7 100644--- a/frontend/src/metabase/visualizations/components/Visualization/LoadingView/DashCardLoadingView.tsx+++ b/frontend/src/metabase/visualizations/components/Visualization/LoadingView/DashCardLoadingView.tsx@@ -32,10 +32,14 @@ export const DashCardLoadingView = ({}};+ // the scalar skeleton picks its size tier from the measured area, which+ // must match the area the rendered visualization will get — no padding+ const isScalar = display === "scalar" || display === "smartscalar";+return (<divdata-testid="loading-indicator"- className={cx(CS.px2, CS.pb2, CS.fullHeight)}+ className={cx(CS.fullHeight, !isScalar && cx(CS.px2, CS.pb2))}><ChartSkeleton display={display} /><Transitiondiff --git a/frontend/src/metabase/visualizations/components/Visualization/Visualization.styled.tsx b/frontend/src/metabase/visualizations/components/Visualization/Visualization.styled.tsxindex 829e12116b5..0ae4b6a527b 100644--- a/frontend/src/metabase/visualizations/components/Visualization/Visualization.styled.tsx+++ b/frontend/src/metabase/visualizations/components/Visualization/Visualization.styled.tsx@@ -7,7 +7,6 @@ export const VisualizationRoot = styled.div`height: 100%;`;-// Remember to update DASHCARD_HEADER_HEIGHT if height of this element changesexport const VisualizationHeader = styled.div`padding: 0.625rem 0.5rem 0.375rem 0.5rem;flex-shrink: 0;diff --git a/frontend/src/metabase/visualizations/components/Visualization/Visualization.tsx b/frontend/src/metabase/visualizations/components/Visualization/Visualization.tsxindex 9b48237e2c4..d0d11e834db 100644--- a/frontend/src/metabase/visualizations/components/Visualization/Visualization.tsx+++ b/frontend/src/metabase/visualizations/components/Visualization/Visualization.tsx@@ -699,6 +699,7 @@ class Visualization extends PureComponent<isPreviewing,isRawTable,isQueryBuilder,+ isStandaloneQuestion,isRunning,isSettings,isShowingDetailsOnlyColumns,@@ -852,11 +853,17 @@ class Visualization extends PureComponent<const title = settings["card.title"];const hasHeaderContent = title || extra;const isHeaderEnabled = !(visualization && visualization.noHeader);+ const isLoadingHeaderEnabled = !(+ visualization && visualization.noLoadingHeader+ );const hasHeader =(showTitle &&hasHeaderContent &&- (loading || error || noResults || isHeaderEnabled)) ||+ ((loading && isLoadingHeaderEnabled) ||+ error ||+ noResults ||+ isHeaderEnabled)) ||(replacementContent && (dashcard?.size_y !== 1 || isMobile) && !isAction);// We can't navigate a user to a particular card from a visualizer viz,@@ -977,6 +984,7 @@ class Visualization extends PureComponent<isPreviewing={isPreviewing}isRawTable={isRawTable}isQueryBuilder={!!isQueryBuilder}+ isStandaloneQuestion={!!isStandaloneQuestion}isSettings={!!isSettings}isShowingDetailsOnlyColumns={isShowingDetailsOnlyColumns}scrollToLastColumn={scrollToLastColumn}diff --git a/frontend/src/metabase/visualizations/components/legend/LegendLabel.tsx b/frontend/src/metabase/visualizations/components/legend/LegendLabel.tsxindex b6fb59050cc..d971874c1a9 100644--- a/frontend/src/metabase/visualizations/components/legend/LegendLabel.tsx+++ b/frontend/src/metabase/visualizations/components/legend/LegendLabel.tsx@@ -5,6 +5,7 @@ import {type MouseEvent,type MouseEventHandler,type ReactNode,+ type TouchEventHandler,forwardRef,useCallback,} from "react";@@ -23,12 +24,23 @@ interface Props {onClick?: MouseEventHandler;onFocus: FocusEventHandler;onMouseEnter: MouseEventHandler;+ onMouseDown?: MouseEventHandler;+ onTouchStart?: TouchEventHandler;}// eslint-disable-next-line react/display-nameexport const LegendLabel = forwardRef((- { children, className, href, onClick, onFocus, onMouseEnter }: Props,+ {+ children,+ className,+ href,+ onClick,+ onFocus,+ onMouseEnter,+ onMouseDown,+ onTouchStart,+ }: Props,ref: React.Ref<any>,) => {const handleLinkClick = useCallback(@@ -51,6 +63,8 @@ export const LegendLabel = forwardRef(onClick={onClick}onFocus={onFocus}onMouseEnter={onMouseEnter}+ onMouseDown={onMouseDown}+ onTouchStart={onTouchStart}data-testid="legend-label"data-is-clickable={!!onClick}>@@ -69,6 +83,8 @@ export const LegendLabel = forwardRef(onClick={handleLinkClick}onFocus={onFocus}onMouseEnter={onMouseEnter}+ onMouseDown={onMouseDown}+ onTouchStart={onTouchStart}data-testid="legend-label"data-is-clickable={!!onClick}>@@ -85,6 +101,8 @@ export const LegendLabel = forwardRef(onClick={handleLinkClick}onFocus={onFocus}onMouseEnter={onMouseEnter}+ onMouseDown={onMouseDown}+ onTouchStart={onTouchStart}data-testid="legend-label"data-is-clickable={!!onClick}>diff --git a/frontend/src/metabase/visualizations/components/skeletons/ChartSkeleton/ChartSkeleton.stories.tsx b/frontend/src/metabase/visualizations/components/skeletons/ChartSkeleton/ChartSkeleton.stories.tsxindex 403c6316ed1..377b734264d 100644--- a/frontend/src/metabase/visualizations/components/skeletons/ChartSkeleton/ChartSkeleton.stories.tsx+++ b/frontend/src/metabase/visualizations/components/skeletons/ChartSkeleton/ChartSkeleton.stories.tsx@@ -109,6 +109,44 @@ export const Scalar = {},};+const SCALAR_CARD_SIZES: [number, number][] = [+ [82, 82],+ [256, 126],+ [345, 170],+ [433, 214],+ [520, 256],+ [609, 345],+];++// the dashboard loading state: no name, one skeleton card per size tier+export const ScalarSizeTiers = {+ render: () => (+ <div+ style={{+ display: "flex",+ gap: 16,+ alignItems: "flex-start",+ flexWrap: "wrap",+ padding: 16,+ }}+ >+ {SCALAR_CARD_SIZES.map(([width, height]) => (+ <div+ key={width}+ style={{+ width,+ height,+ borderRadius: 12,+ border: "1px solid var(--mb-color-border)",+ }}+ >+ <ChartSkeleton display="scalar" />+ </div>+ ))}+ </div>+ ),+};+export const Scatter = {render: Template,diff --git a/frontend/src/metabase/visualizations/components/skeletons/ChartSkeleton/ChartSkeleton.tsx b/frontend/src/metabase/visualizations/components/skeletons/ChartSkeleton/ChartSkeleton.tsxindex 84002ec8ae4..d4239fbd391 100644--- a/frontend/src/metabase/visualizations/components/skeletons/ChartSkeleton/ChartSkeleton.tsx+++ b/frontend/src/metabase/visualizations/components/skeletons/ChartSkeleton/ChartSkeleton.tsx@@ -80,7 +80,6 @@ const ChartSkeleton = ({return (<ScalarSkeletonclassName={className}- scalarType={display}name={name}description={description}actionMenu={actionMenu}diff --git a/frontend/src/metabase/visualizations/components/skeletons/ScalarSkeleton/ScalarSkeleton.module.css b/frontend/src/metabase/visualizations/components/skeletons/ScalarSkeleton/ScalarSkeleton.module.cssnew file mode 100644index 00000000000..efa68519271--- /dev/null+++ b/frontend/src/metabase/visualizations/components/skeletons/ScalarSkeleton/ScalarSkeleton.module.css@@ -0,0 +1,8 @@+.actionMenu {+ position: absolute;+ top: 0.3125rem;+ right: 0.3125rem;+ z-index: 3;+ color: var(--mb-color-text-secondary);+ visibility: hidden;+}diff --git a/frontend/src/metabase/visualizations/components/skeletons/ScalarSkeleton/ScalarSkeleton.styled.tsx b/frontend/src/metabase/visualizations/components/skeletons/ScalarSkeleton/ScalarSkeleton.styled.tsxdeleted file mode 100644index dc6e77512ba..00000000000--- a/frontend/src/metabase/visualizations/components/skeletons/ScalarSkeleton/ScalarSkeleton.styled.tsx+++ /dev/null@@ -1,33 +0,0 @@-// eslint-disable-next-line no-restricted-imports-import styled from "@emotion/styled";--import { VisualizationRoot } from "metabase/visualizations/components/Visualization/Visualization.styled";-import { animationStyles } from "metabase/visualizations/components/skeletons/ChartSkeleton/ChartSkeleton.styled";-import SkeletonCaption from "metabase/visualizations/components/skeletons/SkeletonCaption";--// eslint-disable-next-line metabase/no-color-literals-export const PositionedActionMenu = styled.div`- position: absolute;- top: 0.3125rem;- right: 0.3125rem;- z-index: 3;- color: #6e7680;- visibility: hidden;-`;-export const SkeletonRoot = styled(VisualizationRoot)`- justify-content: center;- align-items: center;-`;-export const SkeletonTopImage = styled.svg`- ${animationStyles};- height: 2rem;- margin-top: 0.625rem;-`;-export const SkeletonBottomImage = styled.svg`- ${animationStyles};- height: 0.5rem;-`;-export const SkeletonCenterCaption = styled(SkeletonCaption)`- margin-top: 0.25rem;- margin-bottom: 1.25rem;-`;diff --git a/frontend/src/metabase/visualizations/components/skeletons/ScalarSkeleton/ScalarSkeleton.tsx b/frontend/src/metabase/visualizations/components/skeletons/ScalarSkeleton/ScalarSkeleton.tsxindex f939eb342b3..2d964081add 100644--- a/frontend/src/metabase/visualizations/components/skeletons/ScalarSkeleton/ScalarSkeleton.tsx+++ b/frontend/src/metabase/visualizations/components/skeletons/ScalarSkeleton/ScalarSkeleton.tsx@@ -1,46 +1,95 @@-import {- PositionedActionMenu,- SkeletonBottomImage,- SkeletonCenterCaption,- SkeletonRoot,- SkeletonTopImage,-} from "./ScalarSkeleton.styled";+import { useLayoutEffect, useRef, useState } from "react";++import { Box, Flex, Skeleton, Stack } from "metabase/ui";+import resizeObserver from "metabase/utils/resize-observer";+import { getScalarSizeTier } from "metabase/visualizations/components/ScalarValue/sizing";+import SkeletonCaption from "metabase/visualizations/components/skeletons/SkeletonCaption";++import S from "./ScalarSkeleton.module.css";++// the title renders at fz "md" / lh "md", which is a 17px line+const TITLE_LINE_HEIGHT = 17;+const PILL_RADIUS = 8;+const TITLE_PILL_HEIGHT = 8;++// measures synchronously on mount so the first paint already has the right+// tier, then follows resizes+const useMeasuredSize = () => {+ const ref = useRef<HTMLDivElement>(null);+ const [size, setSize] = useState({ width: 0, height: 0 });++ useLayoutEffect(() => {+ const element = ref.current;+ if (!element) {+ return;+ }++ const update = () => {+ const { width, height } = element.getBoundingClientRect();+ setSize({ width, height });+ };++ update();+ resizeObserver.subscribe(element, update);++ return () => {+ resizeObserver.unsubscribe(element, update);+ };+ }, []);++ return { ref, ...size };+};const ScalarSkeleton = ({- scalarType = "scalar",name,description,actionMenu,className,}: {- scalarType?: "scalar" | "smartscalar";name?: string | null;description?: string | null;actionMenu?: JSX.Element | null;className?: string;}): JSX.Element => {+ const { ref, width, height } = useMeasuredSize();+ const tier = getScalarSizeTier(width, height);+return (- <SkeletonRoot className={className}>- <PositionedActionMenu>{actionMenu}</PositionedActionMenu>- <SkeletonTopImage xmlns="http://www.w3.org/2000/svg" viewBox="0 0 103 32">- <rect width="103" height="32" rx="16" fill="currentColor" />- </SkeletonTopImage>- <SkeletonCenterCaption- name={name}- description={description}- size="large"- />- {scalarType === "smartscalar" && (- <SkeletonBottomImage- xmlns="http://www.w3.org/2000/svg"- viewBox="0 0 182 8"- >- <circle cx="47.121" cy="4.5" r="2" fill="currentColor" />- <rect x="56" width="126" height="8" rx="4" fill="currentColor" />- <rect width="38" height="8" rx="4" fill="currentColor" />- </SkeletonBottomImage>- )}- </SkeletonRoot>+ <Flex+ ref={ref}+ className={className}+ pos="relative"+ direction="column"+ justify="center"+ align="center"+ w="100%"+ h="100%"+ data-testid="scalar-skeleton"+ >+ {actionMenu && <Box className={S.actionMenu}>{actionMenu}</Box>}+ <Stack align="center" gap={tier.valueTitleGap}>+ <Flex align="center" justify="center" h={tier.valueFontSize}>+ <Skeleton+ radius={PILL_RADIUS}+ w={tier.skeleton.valueWidth}+ h={tier.skeleton.valueHeight}+ />+ </Flex>+ {name ? (+ <SkeletonCaption name={name} description={description} size="large" />+ ) : (+ tier.showsTitle && (+ <Flex align="center" justify="center" h={TITLE_LINE_HEIGHT}>+ <Skeleton+ radius={PILL_RADIUS}+ w={tier.skeleton.titleWidth}+ h={TITLE_PILL_HEIGHT}+ />+ </Flex>+ )+ )}+ </Stack>+ </Flex>);};diff --git a/frontend/src/metabase/visualizations/components/skeletons/ScalarSkeleton/ScalarSkeleton.unit.spec.tsx b/frontend/src/metabase/visualizations/components/skeletons/ScalarSkeleton/ScalarSkeleton.unit.spec.tsxnew file mode 100644index 00000000000..b8b8d186fb8--- /dev/null+++ b/frontend/src/metabase/visualizations/components/skeletons/ScalarSkeleton/ScalarSkeleton.unit.spec.tsx@@ -0,0 +1,21 @@+import { render, screen } from "__support__/ui";++import ScalarSkeleton from "./ScalarSkeleton";++describe("ScalarSkeleton", () => {+ it("should show a value pill", () => {+ render(<ScalarSkeleton />);++ const skeleton = screen.getByTestId("scalar-skeleton");+ expect(skeleton).toBeInTheDocument();+ expect(skeleton.querySelectorAll(".mb-mantine-Skeleton-root")).toHaveLength(+ 1,+ );+ });++ it("should show the name instead of the title pill when provided", () => {+ render(<ScalarSkeleton name="Revenue" />);++ expect(screen.getByText("Revenue")).toBeInTheDocument();+ });+});diff --git a/frontend/src/metabase/visualizations/lib/scalar_utils.tsx b/frontend/src/metabase/visualizations/lib/scalar_utils.tsxindex 78f97ee7285..19e8393b6a3 100644--- a/frontend/src/metabase/visualizations/lib/scalar_utils.tsx+++ b/frontend/src/metabase/visualizations/lib/scalar_utils.tsx@@ -8,21 +8,46 @@ import type {ScalarSegment,} from "metabase-types/api";-export const COMPACT_MAX_WIDTH = 250;-export const COMPACT_WIDTH_PER_DIGIT = 25;-export const COMPACT_MIN_LENGTH = 6;+// slight overestimates of Lato Bold character widths (digits ≈0.58em,+// separators ≈0.22em), so borderline values compact instead of overflowing+const CHAR_WIDTH_EM = 0.6;+const THIN_CHAR_WIDTH_EM = 0.25;+const THIN_CHARS_PATTERN = /[.,'\u2019\u00A0\u202F ]/;++// font sizes render in rem, so the effective pixel size follows the root font+// scale while the measured container width stays in device pixels+export function getRootFontScale() {+ if (typeof document === "undefined") {+ return 1;+ }+ const rootFontSize = parseFloat(+ getComputedStyle(document.documentElement).fontSize,+ );+ return Number.isFinite(rootFontSize) ? rootFontSize / 16 : 1;+}-function checkShouldCompact(fullValue: string, width: number) {- const expectedCompactWidth = fullValue.length * COMPACT_WIDTH_PER_DIGIT;- return (- fullValue.length > COMPACT_MIN_LENGTH &&- (width < COMPACT_MAX_WIDTH || width < expectedCompactWidth)+export function estimateScalarValueWidth(text: string, fontSize: number) {+ const widthEm = [...text].reduce(+ (total, char) =>+ total ++ (THIN_CHARS_PATTERN.test(char) ? THIN_CHAR_WIDTH_EM : CHAR_WIDTH_EM),+ 0,);+ return widthEm * fontSize * getRootFontScale();+}++function checkShouldCompact(+ fullValue: string,+ width: number,+ fontSize: number,+) {+ return estimateScalarValueWidth(fullValue, fontSize) > width;}export function compactifyValue(value: RowValue,width: number,+ fontSize: number,formatOptions: ColumnSettings = {},) {const fullScalarValue = formatValue(value, {@@ -35,7 +60,8 @@ export function compactifyValue(}const displayValue =- formatOptions.compact || checkShouldCompact(fullScalarValue, width)+ formatOptions.compact ||+ checkShouldCompact(fullScalarValue, width, fontSize)? formatValue(value, {...formatOptions,compact: true,diff --git a/frontend/src/metabase/visualizations/lib/scalar_utils.unit.spec.ts b/frontend/src/metabase/visualizations/lib/scalar_utils.unit.spec.tsindex b6912bf4d59..85515968597 100644--- a/frontend/src/metabase/visualizations/lib/scalar_utils.unit.spec.ts+++ b/frontend/src/metabase/visualizations/lib/scalar_utils.unit.spec.ts@@ -1,14 +1,10 @@import { TYPE } from "metabase-lib/v1/types/constants";-import {- COMPACT_MAX_WIDTH,- COMPACT_MIN_LENGTH,- COMPACT_WIDTH_PER_DIGIT,- compactifyValue,-} from "./scalar_utils";+import { compactifyValue, estimateScalarValueWidth } from "./scalar_utils";describe("scalar utils", () => {describe("compactifyValue", () => {+ const fontSize = 32;const formatOptions = {column: {base_type: TYPE.Number,@@ -16,95 +12,60 @@ describe("scalar utils", () => {},};- it("displayValue is fullScalarValue when fullScalarValue.length <= COMPACT_MIN_LENGTH", () => {- const value = 45000;+ it("displayValue is fullScalarValue when the value fits the width", () => {+ const value = 45000.1343;const width = 200;// Unjustified type cast. FIXMEconst { displayValue, fullScalarValue } = compactifyValue(value,width,+ fontSize,formatOptions,) as { displayValue: string; fullScalarValue: string };- expect(fullScalarValue.length).toBeLessThanOrEqual(COMPACT_MIN_LENGTH);-expect(displayValue).toBe(fullScalarValue);- expect(fullScalarValue).toBe("45,000");+ expect(fullScalarValue).toBe("45,000.13");});- it("displayValue is compact when fullScalarValue.length > COMPACT_MIN_LENGTH and width < COMPACT_MAX_WIDTH", () => {+ it("displayValue is compact when the value does not fit the width", () => {const value = 45000.1343;- const width = 200;+ const width = 140;// Unjustified type cast. FIXMEconst { displayValue, fullScalarValue } = compactifyValue(value,width,+ fontSize,formatOptions,) as { displayValue: string; fullScalarValue: string };- expect(fullScalarValue.length).toBeGreaterThan(COMPACT_MIN_LENGTH);- expect(width).toBeLessThan(COMPACT_MAX_WIDTH);-expect(displayValue).not.toBe(fullScalarValue);expect(displayValue).toBe("45.0k");});- it("displayValue is compact when fullScalarValue.length > COMPACT_MIN_LENGTH & width >= COMPACT_MAX_WIDTH & width < COMPACT_WIDTH_PER_DIGIT * fullScalarValue.length", () => {- const value = 100100100100;- const width = 350;-- // Unjustified type cast. FIXME- const { displayValue, fullScalarValue } = compactifyValue(- value,- width,- formatOptions,- ) as { displayValue: string; fullScalarValue: string };-- expect(fullScalarValue.length).toBeGreaterThan(COMPACT_MIN_LENGTH);- expect(width).toBeGreaterThanOrEqual(COMPACT_MAX_WIDTH);- expect(width).toBeLessThan(- fullScalarValue.length * COMPACT_WIDTH_PER_DIGIT,- );-- expect(displayValue).not.toBe(fullScalarValue);- expect(displayValue).toBe("100.1B");- });-- it("displayValue is not compact when fullScalarValue.length > COMPACT_MIN_LENGTH & width >= COMPACT_MAX_WIDTH & width >= COMPACT_WIDTH_PER_DIGIT * fullScalarValue.length", () => {- const value = 10010010010;- const width = 350;-- // Unjustified type cast. FIXME- const { displayValue, fullScalarValue } = compactifyValue(- value,- width,- formatOptions,- ) as { displayValue: string; fullScalarValue: string };-- expect(fullScalarValue.length).toBeGreaterThan(COMPACT_MIN_LENGTH);- expect(width).toBeGreaterThanOrEqual(COMPACT_MAX_WIDTH);- expect(width).toBeGreaterThanOrEqual(- fullScalarValue.length * COMPACT_WIDTH_PER_DIGIT,- );-- expect(displayValue).toBe(fullScalarValue);- expect(displayValue).toBe("10,010,010,010");- });-- it("displayValue is always compact when formatOptions.compact is true", () => {- const value = 10010010010;- const width = 350;+ it("displayValue is compact when formatOptions request it regardless of width", () => {+ const value = 45000.1343;+ const width = 1000;// Unjustified type cast. FIXME- const { displayValue, fullScalarValue } = compactifyValue(value, width, {+ const { displayValue } = compactifyValue(value, width, fontSize, {...formatOptions,compact: true,- }) as { displayValue: string; fullScalarValue: string };+ }) as { displayValue: string };++ expect(displayValue).toBe("45.0k");+ });+ });- expect(displayValue).toBe("10.0B");- expect(fullScalarValue).toBe("10,010,010,010");+ describe("estimateScalarValueWidth", () => {+ it("should count locale digit separators as thin characters", () => {+ const plain = estimateScalarValueWidth("68000", 32);+ // Swiss apostrophe, no-break space, and narrow no-break space grouping+ for (const separator of ["’", " ", " ", ","]) {+ const grouped = estimateScalarValueWidth(`68${separator}000`, 32);+ expect(grouped - plain).toBeLessThan(0.3 * 32);+ }});});});diff --git a/frontend/src/metabase/visualizations/types/visualization.ts b/frontend/src/metabase/visualizations/types/visualization.tsindex b5bd4ad3a57..439380baa8c 100644--- a/frontend/src/metabase/visualizations/types/visualization.ts+++ b/frontend/src/metabase/visualizations/types/visualization.ts@@ -144,6 +144,7 @@ export type VisualizationPassThroughProps = {canToggleSeriesVisibility?: boolean;isObjectDetail?: boolean;isQueryBuilder?: boolean;+ isStandaloneQuestion?: boolean;queryBuilderMode?: QueryBuilderMode;zoomedRowIndex?: number;onZoomRow?: (rowIndex: number) => void;diff --git a/frontend/src/metabase/visualizations/visualizations/Scalar/Scalar.tsx b/frontend/src/metabase/visualizations/visualizations/Scalar/Scalar.tsxindex 6d618271c7d..50031fe8bf1 100644--- a/frontend/src/metabase/visualizations/visualizations/Scalar/Scalar.tsx+++ b/frontend/src/metabase/visualizations/visualizations/Scalar/Scalar.tsx@@ -2,11 +2,12 @@ import { useRef } from "react";import _ from "underscore";import DashboardS from "metabase/css/dashboard.module.css";-import { Stack, Text, Tooltip } from "metabase/ui";+import { Box, Stack, Text, Tooltip } from "metabase/ui";import {- ScalarValue,- ScalarWrapper,-} from "metabase/visualizations/components/ScalarValue/ScalarValue";+ ScalarCardShell,+ useScalarCardShell,+} from "metabase/visualizations/components/ScalarValue/ScalarCardShell";+import { ScalarValue } from "metabase/visualizations/components/ScalarValue/ScalarValue";import { TransformedVisualization } from "metabase/visualizations/components/TransformedVisualization";import {compactifyValue,@@ -27,8 +28,6 @@ import { ScalarValueContainer } from "./ScalarValueContainer";import { SCALAR_CHART_DEFINITION } from "./definition";import { scalarToBarTransform } from "./scalars-bar-transform";-const PADDING = 32;-// convert legacy `scalar.*` visualization settings to format optionsfunction legacyScalarSettingsToFormatOptions(settings: ComputedVisualizationSettings,@@ -56,14 +55,23 @@ function ScalarComponent(settings,visualizationIsClickable,onVisualizationClick,- height,- width,- gridSize,- totalNumGridCols,- fontFamily,rawSeries,+ actionButtons,} = props;+ const label = settings["scalar.label"];+ const sublabel = settings["scalar.sublabel"];+ const isMetricsViewer = label !== undefined;++ const {+ tier,+ availableWidth,+ title,+ titleElement,+ showsTitleTooltip,+ innerTooltipHoverHandlers,+ } = useScalarCardShell(props, { hideTitle: isMetricsViewer });+if (rawSeries.length > 1) {return (<TransformedVisualization@@ -97,14 +105,11 @@ function ScalarComponent(const { displayValue, fullScalarValue } = compactifyValue(value,- width,+ availableWidth,+ tier.valueFontSize,formatOptions,);- const label = settings["scalar.label"];- const sublabel = settings["scalar.sublabel"];- const isMetricsViewer = label !== undefined;-const isClickable = onVisualizationClick != null && !isMetricsViewer;const handleClick = () => {@@ -126,47 +131,55 @@ function ScalarComponent(}};+ const hasValueTooltip =+ fullScalarValue !== displayValue || tooltipContent != null;+return (- <ScalarWrapper>- <ScalarValueContainer- className={DashboardS.fullscreenNormalText}- tooltip={fullScalarValue}- alwaysShowTooltip={fullScalarValue !== displayValue}- isClickable={isClickable}- >- <Tooltip- label={tooltipContent}- position="bottom"- px="0.375rem"- py="xs"- disabled={!tooltipContent}+ <ScalarCardShell+ tier={tier}+ title={title}+ showsTitleTooltip={showsTitleTooltip}+ actionButtons={actionButtons}+ innerTooltipHoverHandlers={innerTooltipHoverHandlers}+ >+ <Box maw="100%" {...(hasValueTooltip ? innerTooltipHoverHandlers : {})}>+ <ScalarValueContainer+ className={DashboardS.fullscreenNormalText}+ tooltip={fullScalarValue}+ alwaysShowTooltip={fullScalarValue !== displayValue}+ isClickable={isClickable}>- <Stack onClick={handleClick} ref={scalarRef} align="center" gap={0}>- <ScalarValue- color={color}- disableHover={isMetricsViewer}- fontFamily={fontFamily}- gridSize={gridSize}- height={Math.max(height - PADDING * 2, 0)}- totalNumGridCols={totalNumGridCols}- // Unjustified type cast. FIXME- value={displayValue as string}- width={Math.max(width - PADDING, 0)}- />- {label && (- <Text fz="14px" lh="16px" c="text-primary" mt="md" ta="center">- {label}- </Text>- )}- {sublabel && (- <Text fz="12px" lh="16px" c="text-secondary" mt="xs" ta="center">- {sublabel}- </Text>- )}- </Stack>- </Tooltip>- </ScalarValueContainer>- </ScalarWrapper>+ <Tooltip+ label={tooltipContent}+ position="bottom"+ px="0.375rem"+ py="xs"+ disabled={!tooltipContent}+ >+ <Stack onClick={handleClick} ref={scalarRef} align="center" gap={0}>+ <ScalarValue+ color={color}+ disableHover={isMetricsViewer}+ fontSize={tier.valueFontSize}+ // Unjustified type cast. FIXME+ value={displayValue as string}+ />+ {label && (+ <Text fz={14} lh="1rem" c="text-primary" mt="md" ta="center">+ {label}+ </Text>+ )}+ {sublabel && (+ <Text fz={12} lh="1rem" c="text-secondary" mt="xs" ta="center">+ {sublabel}+ </Text>+ )}+ </Stack>+ </Tooltip>+ </ScalarValueContainer>+ </Box>+ {titleElement}+ </ScalarCardShell>);}diff --git a/frontend/src/metabase/visualizations/visualizations/Scalar/Scalar.unit.spec.tsx b/frontend/src/metabase/visualizations/visualizations/Scalar/Scalar.unit.spec.tsxindex 4817c496679..7a07b6eec92 100644--- a/frontend/src/metabase/visualizations/visualizations/Scalar/Scalar.unit.spec.tsx+++ b/frontend/src/metabase/visualizations/visualizations/Scalar/Scalar.unit.spec.tsx@@ -1,7 +1,13 @@import userEvent from "@testing-library/user-event";import type { ComponentProps } from "react";-import { render, renderWithProviders, screen, within } from "__support__/ui";+import {+ fireEvent,+ render,+ renderWithProviders,+ screen,+ within,+} from "__support__/ui";import { QuestionChartSettings } from "metabase/visualizations/components/ChartSettings";import { registerVisualizations } from "metabase/visualizations/register";import type { Series } from "metabase-types/api";@@ -34,21 +40,21 @@ const settings = {};describe("Scalar", () => {- it("shouldn't render compact if normal formatting is <=6 characters", () => {+ it("shouldn't render compact when the value fits the card", () => {render(<Scalar{...mockedProps}- series={series(12345)}- rawSeries={series(12345)}+ series={series(12345.6)}+ rawSeries={series(12345.6)}settings={settings}visualizationIsClickable={() => false}width={230}/>,);- expect(screen.getByText("12,345")).toBeInTheDocument(); // with compact formatting, we'd have 1+ expect(screen.getByText("12,345.6")).toBeInTheDocument();});- it("should render compact if normal formatting is >6 characters", () => {+ it("should render compact when the value doesn't fit the card", () => {render(<Scalar{...mockedProps}@@ -56,12 +62,195 @@ describe("Scalar", () => {rawSeries={series(12345.6)}settings={settings}visualizationIsClickable={() => false}- width={230}+ width={80}/>,);expect(screen.getByText("12.3k")).toBeInTheDocument();});+ it("should show one tooltip at a time on the smallest cards", async () => {+ render(+ <Scalar+ {...mockedProps}+ showTitle+ series={series(12345.6)}+ rawSeries={series(12345.6)}+ settings={settings}+ visualizationIsClickable={() => false}+ width={80}+ />,+ );++ // hovering the compacted value shows the full value, not the title+ await userEvent.hover(screen.getByTestId("scalar-container"));+ expect(await screen.findByText("12,345.6")).toBeInTheDocument();+ expect(screen.queryByText("Scalar Title")).not.toBeInTheDocument();+ await userEvent.unhover(screen.getByTestId("scalar-container"));++ // hovering the rest of the card shows the title+ await userEvent.hover(screen.getByTestId("scalar-content"));+ expect(await screen.findByText("Scalar Title")).toBeInTheDocument();+ });++ it("should navigate to the question when the title is clicked", async () => {+ const onChangeCardAndRun = jest.fn();+ render(+ <Scalar+ {...mockedProps}+ showTitle+ series={series(12345)}+ rawSeries={series(12345)}+ settings={settings}+ visualizationIsClickable={() => false}+ onChangeCardAndRun={onChangeCardAndRun}+ width={230}+ height={150}+ />,+ );++ await userEvent.click(screen.getByText("Scalar Title"));++ expect(onChangeCardAndRun).toHaveBeenCalledWith(+ expect.objectContaining({+ nextCard: expect.objectContaining({ display: "scalar" }),+ }),+ );+ });++ it("should render the real title link from the start so middle-click and copy-link never see a placeholder", () => {+ const getHref = jest.fn(() => "/question/42");+ render(+ <Scalar+ {...mockedProps}+ showTitle+ series={series(12345)}+ rawSeries={series(12345)}+ settings={settings}+ visualizationIsClickable={() => false}+ onChangeCardAndRun={jest.fn()}+ getHref={getHref}+ width={230}+ height={150}+ />,+ );++ const link = screen.getByTestId("legend-label");+ expect(link).toHaveAttribute("href", "/question/42");++ // interactions refresh the href in case it went stale+ fireEvent.mouseDown(link);+ expect(getHref).toHaveBeenCalledTimes(2);+ });++ it("should navigate from a visualizer card with a single underlying question", async () => {+ const onChangeCardAndRun = jest.fn();+ render(+ <Scalar+ {...mockedProps}+ showTitle+ isVisualizerCard+ titleMenuItems={<div>menu item</div>}+ visualizerRawSeries={series(999)}+ series={series(12345)}+ rawSeries={series(12345)}+ settings={settings}+ visualizationIsClickable={() => false}+ onChangeCardAndRun={onChangeCardAndRun}+ width={230}+ height={150}+ />,+ );++ await userEvent.click(screen.getByText("Scalar Title"));++ expect(onChangeCardAndRun).toHaveBeenCalledWith(+ expect.objectContaining({+ nextCard: expect.objectContaining({ display: "scalar" }),+ }),+ );+ });++ it("should not navigate from a visualizer card with several underlying questions", async () => {+ const onChangeCardAndRun = jest.fn();+ render(+ <Scalar+ {...mockedProps}+ showTitle+ isVisualizerCard+ titleMenuItems={[<div key="1" />, <div key="2" />]}+ series={series(12345)}+ rawSeries={series(12345)}+ settings={settings}+ visualizationIsClickable={() => false}+ onChangeCardAndRun={onChangeCardAndRun}+ width={230}+ height={150}+ />,+ );++ await userEvent.click(screen.getByText("Scalar Title"));++ expect(onChangeCardAndRun).not.toHaveBeenCalled();+ });++ it("should show the description in a tooltip on the title info icon", async () => {+ render(+ <Scalar+ {...mockedProps}+ showTitle+ series={series(12345)}+ rawSeries={series(12345)}+ settings={{ ...settings, "card.description": "Scalar description" }}+ visualizationIsClickable={() => false}+ width={230}+ height={150}+ />,+ );++ await userEvent.hover(screen.getByLabelText("info icon"));++ expect(await screen.findByText("Scalar description")).toBeInTheDocument();+ });++ it("should open the description tooltip with keyboard navigation", async () => {+ render(+ <Scalar+ {...mockedProps}+ showTitle+ series={series(12345)}+ rawSeries={series(12345)}+ settings={{ ...settings, "card.description": "Scalar description" }}+ visualizationIsClickable={() => false}+ width={230}+ height={150}+ />,+ );++ // without a title link, the info icon is the first tabbable element+ await userEvent.tab();++ expect(await screen.findByText("Scalar description")).toBeInTheDocument();+ });++ it("should not show the info icon while editing a dashboard", () => {+ render(+ <Scalar+ {...mockedProps}+ showTitle+ isDashboard+ isEditing+ series={series(12345)}+ rawSeries={series(12345)}+ settings={{ ...settings, "card.description": "Scalar description" }}+ visualizationIsClickable={() => false}+ width={230}+ height={150}+ />,+ );++ expect(screen.queryByLabelText("info icon")).not.toBeInTheDocument();+ });+it("should render null", () => {render(<Scalardiff --git a/frontend/src/metabase/visualizations/visualizations/Scalar/ScalarValueContainer.module.css b/frontend/src/metabase/visualizations/visualizations/Scalar/ScalarValueContainer.module.cssindex 8260eef783b..936839e800a 100644--- a/frontend/src/metabase/visualizations/visualizations/Scalar/ScalarValueContainer.module.css+++ b/frontend/src/metabase/visualizations/visualizations/Scalar/ScalarValueContainer.module.css@@ -1,5 +1,4 @@.container {- padding: 0 var(--mantine-spacing-sm);max-width: 100%;box-sizing: border-box;}diff --git a/frontend/src/metabase/visualizations/visualizations/Scalar/definition.ts b/frontend/src/metabase/visualizations/visualizations/Scalar/definition.tsindex 8b8abac030b..c55e0752183 100644--- a/frontend/src/metabase/visualizations/visualizations/Scalar/definition.ts+++ b/frontend/src/metabase/visualizations/visualizations/Scalar/definition.ts@@ -15,6 +15,8 @@ export const SCALAR_CHART_DEFINITION: VisualizationDefinition = {identifier: "scalar",iconName: "number",canSavePng: false,+ noHeader: true,+ noLoadingHeader: true,minSize: getMinSize("scalar"),defaultSize: getDefaultSize("scalar"),diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/DetailCandidate.tsx b/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/DetailCandidate.tsxdeleted file mode 100644index 5ac2576383f..00000000000--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/DetailCandidate.tsx+++ /dev/null@@ -1,35 +0,0 @@-import { jt } from "ttag";--import { Text } from "metabase/ui";-import type { ColorName } from "metabase/ui/colors/types";-import { isEmpty } from "metabase/utils/validate";--import type { ComparisonResult } from "../compute";--interface Props {- color: ColorName;- comparison: ComparisonResult;- valueFormatted: string | number | JSX.Element | null;-}--export function DetailCandidate({ color, comparison, valueFormatted }: Props) {- const { comparisonDescStr } = comparison;-- if (isEmpty(valueFormatted)) {- return comparisonDescStr;- }-- if (isEmpty(comparisonDescStr)) {- return (- <Text c={color} component="span" lh={1}>- {valueFormatted}- </Text>- );- }-- return jt`${comparisonDescStr}: ${(- <Text key="value-str" c={color} component="span" lh={1}>- {valueFormatted}- </Text>- )}`;-}diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/PreviousValueComparison.module.css b/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/PreviousValueComparison.module.cssdeleted file mode 100644index d9dd9b21247..00000000000--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/PreviousValueComparison.module.css+++ /dev/null@@ -1,5 +0,0 @@-.variationIcon {- display: flex;- align-items: center;- flex: 0 0 auto;-}diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/PreviousValueComparison.tsx b/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/PreviousValueComparison.tsxdeleted file mode 100644index 9c3046ed14b..00000000000--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/PreviousValueComparison.tsx+++ /dev/null@@ -1,171 +0,0 @@-import { isValidElement } from "react";--import DashboardS from "metabase/css/dashboard.module.css";-import { Badge, Flex, Group, Icon, Stack, Tooltip } from "metabase/ui";-import { measureTextWidth } from "metabase/utils/measure-text";-import { formatValue } from "metabase/value-formatting";-import { SAVING_DOM_IMAGE_DISPLAY_NONE_CLASS } from "metabase/viz-core";-import type { ColumnSettings } from "metabase-types/api";--import { CHANGE_TYPE_OPTIONS, type ComparisonResult } from "../compute";-import {- ELLIPSIS_BADGE_WIDTH,- ICON_MARGIN_RIGHT,- ICON_SIZE,- SPACING,- TEXT_SPACING,-} from "../constants";-import { formatChangeAutoPrecision, getChangeWidth } from "../utils";--import { DetailCandidate } from "./DetailCandidate";-import { PreviousValueComparisonTooltip } from "./PreviousValueComparisonTooltip";-import { VariationDetails } from "./VariationDetails";-import { VariationPercent } from "./VariationPercent";--export function innerText(node: React.ReactNode): string {- if (node == null || typeof node === "boolean") {- return "";- }- if (typeof node === "string") {- return node;- }- if (typeof node === "number") {- return node.toString();- }- if (Array.isArray(node)) {- return node.map(innerText).join("");- }- if (isValidElement<{ children?: React.ReactNode }>(node)) {- return innerText(node.props.children);- }- return "";-}--interface PreviousValueComparisonProps {- comparison: ComparisonResult;- fontFamily: string;- formatOptions: ColumnSettings;- tooltipComparisons: ComparisonResult[];- width: number;-}--export function PreviousValueComparison({- comparison,- fontFamily,- formatOptions,- tooltipComparisons,- width,-}: PreviousValueComparisonProps) {- const fontSize = "0.875rem";- const { changeType, percentChange, comparisonValue, display } = comparison;- const showsOtherValuesInTooltip = tooltipComparisons.length > 1;-- const fittedChangeDisplay =- changeType === CHANGE_TYPE_OPTIONS.CHANGED.CHANGE_TYPE- ? // Unjustified type cast. FIXME- formatChangeAutoPrecision(percentChange as number, {- fontFamily,- fontWeight: 900,- width: getChangeWidth(width),- })- : display.percentChange;-- const availableComparisonWidth =- width -- 4 * SPACING -- TEXT_SPACING -- ICON_SIZE -- (showsOtherValuesInTooltip ? ELLIPSIS_BADGE_WIDTH + TEXT_SPACING : 0) -- ICON_MARGIN_RIGHT -- measureTextWidth(fittedChangeDisplay, {- size: fontSize,- family: fontFamily,- weight: 900,- });-- const valueCandidates = [- display.comparisonValue,- ...(changeType === CHANGE_TYPE_OPTIONS.CHANGED.CHANGE_TYPE- ? [formatValue(comparisonValue, { ...formatOptions, compact: true })]- : []),- "",- ];-- const detailCandidates = valueCandidates.map((valueFormatted) => {- // intentionally calling the component as a function- // since otherwise measurements don't work as expected- return DetailCandidate({- color: "text-secondary",- comparison,- valueFormatted,- });- });- const fullDetailDisplay = detailCandidates[0];- const fittedDetailDisplay = detailCandidates.find(- (e) =>- measureTextWidth(innerText(e), {- size: fontSize,- family: fontFamily,- weight: 700,- }) <= availableComparisonWidth,- );-- return (- <Tooltip- disabled={- fullDetailDisplay === fittedDetailDisplay &&- tooltipComparisons.length === 0- }- label={- <Stack gap="xs" fz={14}>- {tooltipComparisons.map((comparison, index) => {- return (- <PreviousValueComparisonTooltip- comparison={comparison}- key={index}- formatOptions={formatOptions}- />- );- })}- </Stack>- }- position="bottom"- >- <Flex- gap={TEXT_SPACING}- wrap="wrap"- align="center"- justify="center"- mx="sm"- lh="1.2rem"- className={DashboardS.fullscreenNormalText}- >- <VariationPercent- color="text-disabled"- comparison={comparison}- iconSize={ICON_SIZE}- >- {fittedChangeDisplay}- </VariationPercent>-- <VariationDetails color="text-secondary">- {fittedDetailDisplay}- </VariationDetails>-- {showsOtherValuesInTooltip && (- <Badge- px="xs"- size="xs"- variant="light"- w={ELLIPSIS_BADGE_WIDTH}- className={SAVING_DOM_IMAGE_DISPLAY_NONE_CLASS}- >- <Group align="center" h="100%">- <Icon name="ellipsis" size={12} />- </Group>- </Badge>- )}- </Flex>- </Tooltip>- );-}diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/PreviousValueComparison.unit.spec.tsx b/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/PreviousValueComparison.unit.spec.tsxdeleted file mode 100644index d6ca8d46eaa..00000000000--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/PreviousValueComparison.unit.spec.tsx+++ /dev/null@@ -1,59 +0,0 @@-import { innerText } from "./PreviousValueComparison";--describe("innerText", () => {- it("returns an empty string for null, undefined, and booleans", () => {- expect(innerText(null)).toBe("");- expect(innerText(undefined)).toBe("");- expect(innerText(true)).toBe("");- expect(innerText(false)).toBe("");- });-- it("returns strings as-is", () => {- expect(innerText("vs. previous month")).toBe("vs. previous month");- expect(innerText("")).toBe("");- });-- it("stringifies numbers", () => {- expect(innerText(42)).toBe("42");- expect(innerText(0)).toBe("0");- expect(innerText(-1.5)).toBe("-1.5");- });-- it("concatenates arrays without a separator", () => {- expect(innerText(["vs. ", 42, "%"])).toBe("vs. 42%");- });-- it("extracts text from an element's children", () => {- expect(innerText(<span>vs. previous month</span>)).toBe(- "vs. previous month",- );- });-- it("recurses through nested elements, arrays, and fragments", () => {- expect(- innerText(- <div>- <span>vs. </span>- <>- {["Jan", " 1"]}- <b>{2024}</b>- </>- </div>,- ),- ).toBe("vs. Jan 12024");- });-- it("returns an empty string for an element without children", () => {- expect(innerText(<hr />)).toBe("");- });-- it("skips non-text children like booleans from conditional rendering", () => {- expect(- innerText(- <div>- {false}before{null}after- </div>,- ),- ).toBe("beforeafter");- });-});diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/PreviousValueComparisonTooltip.tsx b/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/PreviousValueComparisonTooltip.tsxdeleted file mode 100644index 2e81b9f9f5e..00000000000--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/PreviousValueComparisonTooltip.tsx+++ /dev/null@@ -1,45 +0,0 @@-import { Flex } from "metabase/ui";-import { formatValue } from "metabase/value-formatting";-import type { ColumnSettings } from "metabase-types/api";--import { CHANGE_TYPE_OPTIONS, type ComparisonResult } from "../compute";-import { TEXT_SPACING, TOOLTIP_ICON_SIZE } from "../constants";--import { DetailCandidate } from "./DetailCandidate";-import { VariationDetails } from "./VariationDetails";-import { VariationPercent } from "./VariationPercent";--interface PreviousValueComparisonProps {- comparison: ComparisonResult;- formatOptions: ColumnSettings;-}--export function PreviousValueComparisonTooltip({- comparison,- formatOptions,-}: PreviousValueComparisonProps) {- const { changeType, comparisonValue, display } = comparison;-- const valueCandidates = [- display.comparisonValue,- ...(changeType === CHANGE_TYPE_OPTIONS.CHANGED.CHANGE_TYPE- ? [formatValue(comparisonValue, { ...formatOptions, compact: true })]- : []),- "",- ];-- return (- <Flex gap={TEXT_SPACING} align="flex-start">- <VariationPercent comparison={comparison} iconSize={TOOLTIP_ICON_SIZE}>- {display.percentChange}- </VariationPercent>- <VariationDetails>- <DetailCandidate- color="core-white"- comparison={comparison}- valueFormatted={valueCandidates[0]}- />- </VariationDetails>- </Flex>- );-}diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/VariationDetails.tsx b/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/VariationDetails.tsxdeleted file mode 100644index 45ad84f39ca..00000000000--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/VariationDetails.tsx+++ /dev/null@@ -1,21 +0,0 @@-import type { ReactNode } from "react";--import { Title } from "metabase/ui";-import type { ColorName } from "metabase/ui/colors/types";--interface Props {- children: ReactNode;- color?: ColorName;-}--export const VariationDetails = ({ children, color }: Props) => {- if (!children) {- return null;- }-- return (- <Title c={color} order={5} lh="inherit">- {children}- </Title>- );-};diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/VariationPercent.tsx b/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/VariationPercent.tsxdeleted file mode 100644index 29a0bb9663a..00000000000--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/VariationPercent.tsx+++ /dev/null@@ -1,41 +0,0 @@-import type { ReactNode } from "react";--import { Ellipsified, Flex, Icon } from "metabase/ui";-import type { ColorName } from "metabase/ui/colors/types";--import type { ComparisonResult } from "../compute";--import S from "./PreviousValueComparison.module.css";--interface Props {- children: ReactNode;- color?: ColorName;- comparison: ComparisonResult;- iconSize: string | number;-}--export const VariationPercent = ({- children,- color,- comparison,- iconSize,-}: Props) => {- const { changeArrowIconName, changeColor } = comparison;-- return (- <Flex align="center" maw="100%" style={{ color: changeColor ?? color }}>- {changeArrowIconName && (- <Icon- name={changeArrowIconName}- size={iconSize}- mr="sm"- className={S.variationIcon}- />- )}-- <Ellipsified fw={900} showTooltip={false}>- {children}- </Ellipsified>- </Flex>- );-};diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/index.ts b/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/index.tsdeleted file mode 100644index 4723f8472f7..00000000000--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparison/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from "./PreviousValueComparison";diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparisonTooltip.tsx b/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparisonTooltip.tsxnew file mode 100644index 00000000000..8c4e8440fdd--- /dev/null+++ b/frontend/src/metabase/visualizations/visualizations/SmartScalar/PreviousValueComparisonTooltip.tsx@@ -0,0 +1,71 @@+import { Flex, Text } from "metabase/ui";+import { isEmpty } from "metabase/utils/validate";+import { formatValue } from "metabase/value-formatting";+import type { ColumnSettings } from "metabase-types/api";++import { TrendSymbol } from "./TrendSymbol";+import { type ComparisonResult, getComparisonDisplay } from "./compute";++const SYMBOL_SIZE = 12;+const PERCENT_MIN_WIDTH = 48;++interface PreviousValueComparisonProps {+ comparison: ComparisonResult;+ formatOptions: ColumnSettings;+ className?: string;+}++export function PreviousValueComparisonTooltip({+ comparison,+ formatOptions,+ className,+}: PreviousValueComparisonProps) {+ const { changeColorName, comparisonDescStr, comparisonValue, display } =+ comparison;++ const { sentimentColor, symbolDirection } = getComparisonDisplay(+ comparison,+ formatOptions,+ );+ const percentColor = sentimentColor ?? "text-primary";+ const valueFormatted = !isEmpty(comparisonValue)+ ? formatValue(comparisonValue, { ...formatOptions, compact: true })+ : display.comparisonValue;++ return (+ <div className={className}>+ <Flex gap={4} align="center">+ {symbolDirection != null && (+ <TrendSymbol+ direction={symbolDirection}+ colorName={changeColorName}+ size={SYMBOL_SIZE}+ />+ )}+ <Text+ component="span"+ fw={700}+ fz="md"+ lh="md"+ miw={PERCENT_MIN_WIDTH}+ c={percentColor}+ >+ {display.percentChange}+ </Text>+ </Flex>+ <Text component="span" fz="sm" lh="sm" c="text-secondary">+ {comparisonDescStr}+ </Text>+ <Text+ component="span"+ fw={700}+ fz="md"+ lh="md"+ c="text-primary"+ ta="right"+ >+ {valueFormatted}+ </Text>+ </div>+ );+}diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/ScalarPeriod.tsx b/frontend/src/metabase/visualizations/visualizations/SmartScalar/ScalarPeriod.tsxdeleted file mode 100644index 253d1b8aa0f..00000000000--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/ScalarPeriod.tsx+++ /dev/null@@ -1,30 +0,0 @@-import DashboardS from "metabase/css/dashboard.module.css";-import { Ellipsified, Text } from "metabase/ui";--interface ScalarPeriodProps {- period: string | number | JSX.Element | null;- onClick?: () => void;-}--export function ScalarPeriod({ period, onClick }: ScalarPeriodProps) {- return (- <Text- data-testid="scalar-period"- component="h3"- ta="center"- style={{ cursor: onClick && "pointer" }}- fw={700}- lh="1rem"- className={DashboardS.fullscreenNormalText}- onClick={onClick}- >- <Ellipsified- tooltip={period}- lines={1}- tooltipProps={{ position: "bottom" }}- >- {period}- </Ellipsified>- </Text>- );-}diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/SmartScalar.stories.tsx b/frontend/src/metabase/visualizations/visualizations/SmartScalar/SmartScalar.stories.tsxindex 0c7a2a2098c..1baf1c059fd 100644--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/SmartScalar.stories.tsx+++ b/frontend/src/metabase/visualizations/visualizations/SmartScalar/SmartScalar.stories.tsx@@ -5,6 +5,7 @@ import {VisualizationWrapper,} from "__support__/storybook";import type { MetabaseTheme } from "metabase/embedding-sdk/theme";+import { Box, Flex } from "metabase/ui";import Visualization from "metabase/visualizations/components/Visualization";import { registerVisualization } from "metabase/viz-core";@@ -26,11 +27,115 @@ const MOCK_ROWS = [const MOCK_SERIES = mockSeries({rows: MOCK_ROWS,insights: [{ unit: "month", col: "Count" }],+ name: "Last invoice",});+// spec card sizes: size-200, size-300, and size-400 tiers+const CARD_SIZES = [+ { width: 256, height: 126 },+ { width: 345, height: 170 },+ { width: 433, height: 214 },+];+export const Default: StoryFn = () => (<VisualizationWrapper>- <Visualization rawSeries={MOCK_SERIES} width={500} />+ <Flex gap="lg" align="flex-start" p="lg">+ {CARD_SIZES.map(({ width, height }) => (+ <Box+ key={`${width}x${height}`}+ w={width}+ h={height}+ style={{+ borderRadius: 12,+ border: "1px solid var(--mb-color-border)",+ }}+ >+ <Visualization rawSeries={MOCK_SERIES} showTitle width={width} />+ </Box>+ ))}+ </Flex>+ </VisualizationWrapper>+);++const MOCK_MULTI_COMPARISON_SERIES = mockSeries({+ rows: MOCK_ROWS,+ insights: [{ unit: "month", col: "Count" }],+ name: "Last invoice",+ comparisonTypes: [+ { id: "1", type: "previousPeriod" },+ { id: "2", type: "periodsAgo", value: 2 },+ { id: "3", type: "staticNumber", value: 90, label: "Target" },+ ],+});++// dashboards show the compact row with a "+N" badge; the extra comparisons+// live in the hover panel+export const DashcardMultipleComparisons: StoryFn = () => (+ <VisualizationWrapper>+ <Flex gap="lg" align="flex-start" p="lg">+ {CARD_SIZES.map(({ width, height }) => (+ <Box+ key={`${width}x${height}`}+ w={width}+ h={height}+ style={{+ borderRadius: 12,+ border: "1px solid var(--mb-color-border)",+ }}+ >+ <Visualization+ rawSeries={MOCK_MULTI_COMPARISON_SERIES}+ showTitle+ width={width}+ />+ </Box>+ ))}+ </Flex>+ </VisualizationWrapper>+);++// a single comparison on a full-page question renders inline with the trend+// symbol and the full comparison value+export const QueryBuilderSingleComparison: StoryFn = () => (+ <VisualizationWrapper>+ <Box w={800} h={400}>+ <Visualization rawSeries={MOCK_SERIES} width={800} isQueryBuilder />+ </Box>+ </VisualizationWrapper>+);++// several comparisons on a full-page question render as a date line plus the+// full list — no hover panel needed+export const QueryBuilderMultipleComparisons: StoryFn = () => (+ <VisualizationWrapper>+ <Box w={800} h={400}>+ <Visualization+ rawSeries={MOCK_MULTI_COMPARISON_SERIES}+ width={800}+ isQueryBuilder+ />+ </Box>+ </VisualizationWrapper>+);++// public/embedded question views get the same treatment as the query builder+export const StandaloneQuestionSingleComparison: StoryFn = () => (+ <VisualizationWrapper>+ <Box w={800} h={400}>+ <Visualization rawSeries={MOCK_SERIES} width={800} isStandaloneQuestion />+ </Box>+ </VisualizationWrapper>+);++export const StandaloneQuestionMultipleComparisons: StoryFn = () => (+ <VisualizationWrapper>+ <Box w={800} h={400}>+ <Visualization+ rawSeries={MOCK_MULTI_COMPARISON_SERIES}+ width={800}+ isStandaloneQuestion+ />+ </Box></VisualizationWrapper>);@@ -50,7 +155,9 @@ export const EmbeddingTheme: StoryFn = () => {return (<SdkVisualizationWrapper theme={theme}>- <Visualization rawSeries={MOCK_SERIES} width={500} />+ <Box w={433} h={214}>+ <Visualization rawSeries={MOCK_SERIES} width={433} />+ </Box></SdkVisualizationWrapper>);};diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/SmartScalar.tsx b/frontend/src/metabase/visualizations/visualizations/SmartScalar/SmartScalar.tsxindex 41734972bdc..02940602567 100644--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/SmartScalar.tsx+++ b/frontend/src/metabase/visualizations/visualizations/SmartScalar/SmartScalar.tsx@@ -1,7 +1,11 @@import { useEffect, useMemo, useRef } from "react";import DashboardS from "metabase/css/dashboard.module.css";-import { Box } from "metabase/ui";+import { Box, Stack, Text, rem } from "metabase/ui";+import {+ ScalarCardShell,+ useScalarCardShell,+} from "metabase/visualizations/components/ScalarValue/ScalarCardShell";import {ScalarValue,ScalarWrapper,@@ -15,28 +19,39 @@ import type {import { ScalarValueContainer } from "../Scalar/ScalarValueContainer";-import { PreviousValueComparison } from "./PreviousValueComparison";-import { ScalarPeriod } from "./ScalarPeriod";-import { computeTrend } from "./compute";-import { DASHCARD_HEADER_HEIGHT } from "./constants";+import { TrendComparisonList } from "./TrendComparisonList";+import { TrendComparisonRow } from "./TrendComparisonRow";+import { TrendSymbol } from "./TrendSymbol";+import { computeTrend, getComparisonDisplay } from "./compute";import { SMART_SCALAR_CHART_DEFINITION } from "./definition";-import { getValueHeight, getValueWidth, isPeriodVisible } from "./utils";--function SmartScalarComponent({- onVisualizationClick,- isDashboard,- settings,- visualizationIsClickable,- series,- rawSeries,- gridSize,- width,- height,- totalNumGridCols,- fontFamily,- onRenderError,-}: VisualizationProps & VisualizationPassThroughProps) {++function SmartScalarComponent(+ props: VisualizationProps & VisualizationPassThroughProps,+) {+ const {+ onVisualizationClick,+ settings,+ visualizationIsClickable,+ series,+ rawSeries,+ width,+ fontFamily,+ onRenderError,+ actionButtons,+ isQueryBuilder,+ isStandaloneQuestion,+ } = props;+const scalarRef = useRef(null);+ const {+ tier,+ rootFontScale,+ availableWidth,+ title,+ titleElement,+ showsTitleTooltip,+ innerTooltipHoverHandlers,+ } = useScalarCardShell(props);const { getColor } = useBrowserRenderingContext({ fontFamily });const insights = rawSeries?.[0].data?.insights;@@ -57,8 +72,6 @@ function SmartScalarComponent({const { value, clicked, comparisons, display, formatOptions } = trend;- const innerHeight = isDashboard ? height - DASHCARD_HEADER_HEIGHT : height;-const isClickable = onVisualizationClick != null;const handleClick = () => {@@ -77,64 +90,148 @@ function SmartScalarComponent({}};+ const isSmallestTier = !tier.showsTitle;++ const primaryComparison = comparisons[0];+ const symbolDirection =+ isSmallestTier || primaryComparison == null+ ? null+ : getComparisonDisplay(primaryComparison, formatOptions).symbolDirection;++ const symbolAllowance =+ symbolDirection != null+ ? (tier.symbolSize + tier.symbolGap) * rootFontScale+ : 0;+ const valueMaxWidth = Math.max(+ width - 2 * Math.max(tier.xPadding * rootFontScale, symbolAllowance),+ 0,+ );+const { displayValue, fullScalarValue } = compactifyValue(value,- width,+ valueMaxWidth,+ tier.valueFontSize,formatOptions,);- const { valueHeight, comparisonsCount } = getValueHeight(- innerHeight,- comparisons.length,+ const hasValueTooltip = fullScalarValue !== displayValue;++ const valueElement = (+ <ScalarValueContainer+ className={DashboardS.fullscreenNormalText}+ tooltip={fullScalarValue}+ alwaysShowTooltip={fullScalarValue !== displayValue}+ isClickable={isClickable}+ >+ <span onClick={handleClick} ref={scalarRef}>+ <ScalarValue+ fontSize={tier.valueFontSize}+ // Unjustified type cast. FIXME+ value={displayValue as string}+ />+ </span>+ </ScalarValueContainer>+ );++ const symbolElement = symbolDirection != null && (+ <Box+ pos="absolute"+ right="100%"+ top="50%"+ mr={tier.symbolGap}+ style={{ transform: "translateY(-50%)", display: "flex" }}+ >+ <TrendSymbol+ direction={symbolDirection}+ colorName={primaryComparison?.changeColorName}+ size={tier.symbolSize}+ />+ </Box>);+ if (isQueryBuilder || isStandaloneQuestion) {+ const hasSingleComparison = comparisons.length === 1;++ return (+ <ScalarWrapper xPadding={tier.xPadding}>+ <Stack align="center" gap="lg" maw="100%" data-testid="scalar-content">+ {hasSingleComparison ? (+ <Box pos="relative" maw={`${valueMaxWidth}px`}>+ {valueElement}+ {symbolElement}+ </Box>+ ) : (+ valueElement+ )}+ {hasSingleComparison ? (+ <TrendComparisonRow+ trend={trend}+ formatOptions={formatOptions}+ size="lg"+ compactValue={false}+ />+ ) : (+ <>+ {display.date != null && display.date !== "" && (+ <Text+ fz="lg"+ lh="lg"+ c="text-secondary"+ ta="center"+ data-testid="scalar-period"+ >+ {display.date}+ </Text>+ )}+ {comparisons.length > 0 && (+ <TrendComparisonList+ comparisons={comparisons}+ formatOptions={formatOptions}+ />+ )}+ </>+ )}+ </Stack>+ </ScalarWrapper>+ );+ }+return (- <ScalarWrapper>- <ScalarValueContainer- className={DashboardS.fullscreenNormalText}- tooltip={fullScalarValue}- alwaysShowTooltip={fullScalarValue !== displayValue}- isClickable={isClickable}+ <ScalarCardShell+ tier={tier}+ title={title}+ showsTitleTooltip={showsTitleTooltip}+ actionButtons={actionButtons}+ innerTooltipHoverHandlers={innerTooltipHoverHandlers}+ >+ <Box+ pos="relative"+ // measured pixels, not a design size — must not be rem-scaled+ maw={`${valueMaxWidth}px`}+ {...(hasValueTooltip ? innerTooltipHoverHandlers : {})}>- <span onClick={handleClick} ref={scalarRef}>- <ScalarValue- fontFamily={fontFamily}- gridSize={gridSize}- height={valueHeight}- totalNumGridCols={totalNumGridCols}- // Unjustified type cast. FIXME- value={displayValue as string}- width={getValueWidth(width)}- />- </span>- </ScalarValueContainer>- {isPeriodVisible(innerHeight) && <ScalarPeriod period={display.date} />}-- {comparisonsCount === 1 && (- <Box maw="100%" data-testid="scalar-previous-value">- <PreviousValueComparison- comparison={comparisons[0]}- fontFamily={fontFamily}+ {valueElement}+ {symbolElement}+ </Box>+ {titleElement}+ {comparisons.length > 0 && (+ <Box+ pos="absolute"+ top={`calc(100% + ${rem(tier.comparisonGap)})`}+ left="50%"+ // measured pixels, not a design size — must not be rem-scaled+ w={`${availableWidth}px`}+ style={{ transform: "translateX(-50%)" }}+ {...innerTooltipHoverHandlers}+ >+ <TrendComparisonRow+ trend={trend}formatOptions={formatOptions}- tooltipComparisons={comparisons}- width={width}+ percentOnly={isSmallestTier}/></Box>)}-- {comparisonsCount !== 1 &&- comparisons.map((comparison, index) => (- <Box maw="100%" key={index} data-testid="scalar-previous-value">- <PreviousValueComparison- comparison={comparison}- fontFamily={fontFamily}- formatOptions={formatOptions}- tooltipComparisons={[comparison]}- width={width}- />- </Box>- ))}- </ScalarWrapper>+ </ScalarCardShell>);}diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/TrendComparisonList.module.css b/frontend/src/metabase/visualizations/visualizations/SmartScalar/TrendComparisonList.module.cssnew file mode 100644index 00000000000..e124a8a3baf--- /dev/null+++ b/frontend/src/metabase/visualizations/visualizations/SmartScalar/TrendComparisonList.module.css@@ -0,0 +1,7 @@+.row {+ height: 2.5rem;+}++.row:not(:last-child) {+ border-bottom: 0.5px dashed var(--mb-color-border-neutral-strongest);+}diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/TrendComparisonList.tsx b/frontend/src/metabase/visualizations/visualizations/SmartScalar/TrendComparisonList.tsxnew file mode 100644index 00000000000..68aca22a83c--- /dev/null+++ b/frontend/src/metabase/visualizations/visualizations/SmartScalar/TrendComparisonList.tsx@@ -0,0 +1,80 @@+import { Ellipsified, Flex, Stack, Text } from "metabase/ui";+import type { ColumnSettings } from "metabase-types/api";++import S from "./TrendComparisonList.module.css";+import {+ type ComparisonDisplay,+ type ComparisonResult,+ getComparisonDisplay,+} from "./compute";++const LIST_WIDTH = 360;++const getChangeText = ({+ isChanged,+ isMissing,+ signedPercent,+ valueDisplay,+}: ComparisonDisplay) => {+ if (isChanged) {+ return valueDisplay != null && valueDisplay !== ""+ ? `${signedPercent} (${valueDisplay})`+ : signedPercent;+ }++ // the missing display value carries its own parentheses: "N/A (No data)"+ if (isMissing) {+ return `${signedPercent} ${valueDisplay}`;+ }++ return signedPercent;+};++interface TrendComparisonListProps {+ comparisons: ComparisonResult[];+ formatOptions: ColumnSettings;+}++export function TrendComparisonList({+ comparisons,+ formatOptions,+}: TrendComparisonListProps) {+ return (+ <Stack+ w={LIST_WIDTH}+ maw="100%"+ gap={0}+ data-testid="scalar-comparison-list"+ >+ {comparisons.map((comparison, index) => {+ const display = getComparisonDisplay(comparison, formatOptions);++ return (+ <Flex+ key={index}+ align="center"+ justify="space-between"+ gap="md"+ className={S.row}+ data-testid="scalar-previous-value"+ >+ <Ellipsified showTooltip={false}>+ <Text component="span" fz="md" lh="md" c="text-secondary">+ {comparison.comparisonDescStr}+ </Text>+ </Ellipsified>+ <Text+ component="span"+ fz="md"+ lh="md"+ flex="0 0 auto"+ c={display.sentimentColor ?? "text-primary"}+ >+ {getChangeText(display)}+ </Text>+ </Flex>+ );+ })}+ </Stack>+ );+}diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/TrendComparisonRow.module.css b/frontend/src/metabase/visualizations/visualizations/SmartScalar/TrendComparisonRow.module.cssnew file mode 100644index 00000000000..61ecdb03ecf--- /dev/null+++ b/frontend/src/metabase/visualizations/visualizations/SmartScalar/TrendComparisonRow.module.css@@ -0,0 +1,39 @@+/* the comparison hover panel from the card spec: a white floating panel+ rather than a regular dark tooltip */+.comparisonPanel {+ background: var(--mb-color-background_surface-primary);+ color: var(--mb-color-text-primary);+ border-radius: 0.75rem;+ padding: 1rem;+ /* the 0.5px hairline outline intentionally stays in px */+ box-shadow:+ 0 0 0 0.5px var(--mb-color-border-neutral-subtle),+ 0 0.0625rem 0.25rem 0 var(--mb-color-border-neutral-subtle),+ 0 0.3125rem 0.9375rem 0 var(--mb-color-shadow-default);+}++.comparisonTable {+ display: grid;+ grid-template-columns: max-content 1fr max-content;+ column-gap: 0.75rem;+}++.comparisonRow {+ display: grid;+ column-gap: 0.75rem;+ grid-template-columns: subgrid;+ grid-column: span 3;+ align-items: center;+ height: 2rem;+}++.comparisonRow:not(:last-child) {+ border-bottom: 0.5px dashed var(--mb-color-border-neutral-strongest);+}++.comparisonText {+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ min-width: 0;+}diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/TrendComparisonRow.tsx b/frontend/src/metabase/visualizations/visualizations/SmartScalar/TrendComparisonRow.tsxnew file mode 100644index 00000000000..468a8ee41bb--- /dev/null+++ b/frontend/src/metabase/visualizations/visualizations/SmartScalar/TrendComparisonRow.tsx@@ -0,0 +1,139 @@+import { Badge, Box, Flex, Text, Tooltip } from "metabase/ui";+import { useIsTruncated } from "metabase/ui/hooks/use-is-truncated";+import { SAVING_DOM_IMAGE_DISPLAY_NONE_CLASS } from "metabase/viz-core";+import type { ColumnSettings } from "metabase-types/api";++import { PreviousValueComparisonTooltip } from "./PreviousValueComparisonTooltip";+import S from "./TrendComparisonRow.module.css";+import {+ type ComparisonResult,+ type Trend,+ getComparisonDisplay,+} from "./compute";+import { TEXT_SPACING } from "./constants";++const SIZE_GAPS = { sm: TEXT_SPACING, lg: 6 };++interface TrendComparisonRowProps {+ trend: Trend;+ formatOptions: ColumnSettings;+ percentOnly?: boolean;+ size?: "sm" | "lg";+ compactValue?: boolean;+}++export function TrendComparisonRow({+ trend,+ formatOptions,+ percentOnly,+ size = "sm",+ compactValue = true,+}: TrendComparisonRowProps) {+ const { isTruncated, ref: comparisonTextRef } =+ useIsTruncated<HTMLDivElement>({ ignoreHeightTruncation: true });++ const { comparisons, display } = trend;+ const comparison: ComparisonResult | undefined = comparisons[0];++ if (comparison == null) {+ return null;+ }++ const { comparisonDescStr, comparisonDescShortStr } = comparison;+ const {+ isChanged,+ signedPercent,+ valueDisplay: comparisonValueDisplay,+ sentimentColor,+ } = getComparisonDisplay(comparison, formatOptions, {+ compact: compactValue,+ });++ const changeColor = sentimentColor ?? "text-secondary";+ const changeDesc = isChanged+ ? (comparisonDescShortStr ?? comparisonDescStr)+ : comparisonDescStr;+ const changeText = [signedPercent, changeDesc].filter(Boolean).join(" ");+ const extraComparisonsCount = comparisons.length - 1;++ const showsPanel = percentOnly || extraComparisonsCount > 0 || isTruncated;++ return (+ <Tooltip+ position="bottom"+ disabled={!showsPanel}+ classNames={{ tooltip: S.comparisonPanel }}+ label={+ <div className={S.comparisonTable}>+ {comparisons.map((comparison, index) => (+ <PreviousValueComparisonTooltip+ comparison={comparison}+ key={index}+ formatOptions={formatOptions}+ className={S.comparisonRow}+ />+ ))}+ </div>+ }+ >+ <Flex+ gap={SIZE_GAPS[size]}+ align="center"+ justify="center"+ maw="100%"+ fz={size}+ lh={size}+ tabIndex={showsPanel ? 0 : undefined}+ data-testid="scalar-previous-value"+ >+ <Box ref={comparisonTextRef} className={S.comparisonText}>+ {percentOnly ? (+ <Text component="span" fz={size} lh={size} c={changeColor}>+ {signedPercent}+ </Text>+ ) : (+ <>+ {display.date != null && display.date !== "" && (+ <Text+ component="span"+ fz={size}+ lh={size}+ c="text-secondary"+ mr={SIZE_GAPS[size]}+ >+ <span data-testid="scalar-period">{display.date}</span>+ {","}+ </Text>+ )}+ <Text component="span" fz={size} lh={size} c={changeColor}>+ {changeText}+ </Text>+ {comparisonValueDisplay != null &&+ comparisonValueDisplay !== "" && (+ <Text component="span" fz={size} lh={size} c={changeColor}>+ {isChanged ? (+ <> ({comparisonValueDisplay})</>+ ) : (+ <> {comparisonValueDisplay}</>+ )}+ </Text>+ )}+ </>+ )}+ </Box>+ {!percentOnly && extraComparisonsCount > 0 && (+ <Badge+ px={6}+ size="xs"+ variant="light"+ c="text-primary"+ flex="0 0 auto"+ className={SAVING_DOM_IMAGE_DISPLAY_NONE_CLASS}+ >+ +{extraComparisonsCount}+ </Badge>+ )}+ </Flex>+ </Tooltip>+ );+}diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/TrendSymbol.tsx b/frontend/src/metabase/visualizations/visualizations/SmartScalar/TrendSymbol.tsxnew file mode 100644index 00000000000..e6221d674f4--- /dev/null+++ b/frontend/src/metabase/visualizations/visualizations/SmartScalar/TrendSymbol.tsx@@ -0,0 +1,39 @@+import { Icon, rem } from "metabase/ui";+import type { IconName } from "metabase-types/api";++import type { ChangeColorName } from "./compute";++type TrendDirection = "arrow_up" | "arrow_down" | "no_change";++const DIRECTION_ICONS: Record<TrendDirection, IconName> = {+ arrow_up: "trend_up",+ arrow_down: "trend_down",+ no_change: "trend_flat",+};++const NO_CHANGE_OPACITY = 0.2;++interface TrendSymbolProps {+ direction: TrendDirection;+ colorName: ChangeColorName | undefined;+ size: number;+}++export const TrendSymbol = ({+ direction,+ colorName,+ size,+}: TrendSymbolProps) => {+ const isNoChange = direction === "no_change";++ return (+ <Icon+ name={DIRECTION_ICONS[direction]}+ size={rem(size)}+ color={isNoChange ? "text-primary" : (colorName ?? "feedback-positive")}+ opacity={isNoChange ? NO_CHANGE_OPACITY : undefined}+ data-testid="trend-symbol"+ data-direction={direction}+ />+ );+};diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/compute.ts b/frontend/src/metabase/visualizations/visualizations/SmartScalar/compute.tsindex 0001d2ba1ff..c211564643c 100644--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/compute.ts+++ b/frontend/src/metabase/visualizations/visualizations/SmartScalar/compute.ts@@ -2,13 +2,13 @@ import { t } from "ttag";import { dayjs } from "metabase/dayjs";import type { ColorGetter } from "metabase/ui/colors/types";+import { formatNumber } from "metabase/utils/formatting";import { isNumber } from "metabase/utils/types";import { isEmpty } from "metabase/utils/validate";import {formatDateTimeRangeWithUnit,formatValue,} from "metabase/value-formatting";-import { COMPARISON_TYPES } from "metabase/visualizations/visualizations/SmartScalar/constants";import { formatChange } from "metabase/visualizations/visualizations/SmartScalar/utils";import {computeChange,@@ -35,11 +35,15 @@ import type {import type { Insight } from "metabase-types/api/insight";import { isAbsoluteDateTimeUnit } from "metabase-types/guards/date-time";+import { COMPARISON_TYPES, VIZ_SETTINGS_DEFAULTS } from "./constants";+export type ComparisonResult = {changeArrowIconName: ChangeArrowType | undefined;changeColor: string | undefined;+ changeColorName: ChangeColorName | undefined;changeType: ChangeType;comparisonDescStr: string | undefined;+ comparisonDescShortStr: string | undefined;comparisonValue: RowValue | undefined;display: {percentChange: string;@@ -180,15 +184,35 @@ function buildComparisonObject({): undefined;+ const changeColorName = changeArrowIconName+ ? getArrowColorName(+ changeArrowIconName,+ settings["scalar.switch_positive_negative"],+ )+ : undefined;++ const showComparisonValue =+ settings["scalar.show_comparison_value"] ??+ VIZ_SETTINGS_DEFAULTS["scalar.show_comparison_value"];+ // "(No data)" is a status rather than a number, so it stays visible when the value is hidden.+ const isComparisonValueHidden =+ !showComparisonValue &&+ changeType !== CHANGE_TYPE_OPTIONS.MISSING.CHANGE_TYPE;+return {changeArrowIconName,changeColor,+ changeColorName,changeType,comparisonDescStr,- comparisonValue,+ comparisonDescShortStr: getComparisonDescShortStr({+ comparison,+ currentMetricData,+ }),+ comparisonValue: isComparisonValueHidden ? undefined : comparisonValue,display: {percentChange: percentChangeStr,- comparisonValue: comparisonValueStr,+ comparisonValue: isComparisonValueHidden ? "" : comparisonValueStr,},percentChange,};@@ -735,7 +759,10 @@ export const CHANGE_TYPE_OPTIONS = {get SAME() {return {CHANGE_TYPE: "PREVIOUS_VALUE_SAME" as const,- PERCENT_CHANGE_STR: t`No change`,+ PERCENT_CHANGE_STR: formatNumber(0, {+ number_style: "percent",+ decimals: 2,+ }),COMPARISON_VALUE_STR: "",};},@@ -774,7 +801,9 @@ function computeChangeTypeWithOptions({};}- if (percentChange === 0) {+ const roundsToZero =+ percentChange != null && formatChange(percentChange) === formatChange(0);+ if (roundsToZero) {return {changeType: CHANGE_TYPE_OPTIONS.SAME.CHANGE_TYPE,percentChangeStr: CHANGE_TYPE_OPTIONS.SAME.PERCENT_CHANGE_STR,@@ -798,15 +827,101 @@ function getArrowColor(shouldSwitchPositiveNegative: boolean | undefined,{ getColor }: { getColor: ColorGetter },) {- const arrowIconColorNames = shouldSwitchPositiveNegative- ? {- [CHANGE_ARROW_ICONS.ARROW_DOWN]: getColor("feedback-positive"),- [CHANGE_ARROW_ICONS.ARROW_UP]: getColor("feedback-negative"),- }- : {- [CHANGE_ARROW_ICONS.ARROW_DOWN]: getColor("feedback-negative"),- [CHANGE_ARROW_ICONS.ARROW_UP]: getColor("feedback-positive"),- };+ return getColor(+ getArrowColorName(changeArrowIconName, shouldSwitchPositiveNegative),+ );+}++export type ChangeColorName = "feedback-positive" | "feedback-negative";++function getArrowColorName(+ changeArrowIconName: ChangeArrowType,+ shouldSwitchPositiveNegative: boolean | undefined,+): ChangeColorName {+ const arrowIconColorNames: Record<ChangeArrowType, ChangeColorName> =+ shouldSwitchPositiveNegative+ ? {+ [CHANGE_ARROW_ICONS.ARROW_DOWN]: "feedback-positive",+ [CHANGE_ARROW_ICONS.ARROW_UP]: "feedback-negative",+ }+ : {+ [CHANGE_ARROW_ICONS.ARROW_DOWN]: "feedback-negative",+ [CHANGE_ARROW_ICONS.ARROW_UP]: "feedback-positive",+ };return arrowIconColorNames[changeArrowIconName];}++// "Month over month" style abbreviations for the compact comparison line+const getPeriodAbbreviation = (dateUnit: DateTimeAbsoluteUnit) => {+ switch (dateUnit) {+ case "day":+ return t`DoD`;+ case "week":+ return t`WoW`;+ case "month":+ return t`MoM`;+ case "quarter":+ return t`QoQ`;+ case "year":+ return t`YoY`;+ default:+ return undefined;+ }+};++function getComparisonDescShortStr({+ comparison,+ currentMetricData,+}: {+ comparison: SmartScalarComparison;+ currentMetricData: MetricData;+}) {+ const { dateUnit } = currentMetricData.dateUnitSettings;+ if (comparison.type !== COMPARISON_TYPES.PREVIOUS_PERIOD || !dateUnit) {+ return undefined;+ }+ return getPeriodAbbreviation(dateUnit);+}++export const getChangeSign = (percentChange: number | undefined) => {+ if (percentChange == null || percentChange === 0) {+ return "";+ }+ return percentChange < 0 ? "-" : "+";+};++export interface ComparisonDisplay {+ isChanged: boolean;+ isMissing: boolean;+ signedPercent: string;+ valueDisplay: SmartScalarDisplayValue;+ sentimentColor: `${ChangeColorName}-strong` | null;+ symbolDirection: ChangeArrowType | "no_change" | null;+}++export function getComparisonDisplay(+ comparison: ComparisonResult,+ formatOptions: ColumnSettings,+ { compact = true }: { compact?: boolean } = {},+): ComparisonDisplay {+ const { changeType, changeArrowIconName, changeColorName } = comparison;+ const isChanged = changeType === CHANGE_TYPE_OPTIONS.CHANGED.CHANGE_TYPE;+ const isMissing = changeType === CHANGE_TYPE_OPTIONS.MISSING.CHANGE_TYPE;+ const isSame = changeType === CHANGE_TYPE_OPTIONS.SAME.CHANGE_TYPE;+ const sign = isChanged ? getChangeSign(comparison.percentChange) : "";++ return {+ isChanged,+ isMissing,+ signedPercent: `${sign}${comparison.display.percentChange}`,+ valueDisplay: isChanged+ ? formatValue(comparison.comparisonValue, { ...formatOptions, compact })+ : isMissing+ ? comparison.display.comparisonValue+ : null,+ sentimentColor:+ changeColorName != null ? (`${changeColorName}-strong` as const) : null,+ symbolDirection: changeArrowIconName ?? (isSame ? "no_change" : null),+ };+}diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/compute.unit.spec.ts b/frontend/src/metabase/visualizations/visualizations/SmartScalar/compute.unit.spec.tsindex e9319d47181..bd5f6680b0b 100644--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/compute.unit.spec.ts+++ b/frontend/src/metabase/visualizations/visualizations/SmartScalar/compute.unit.spec.ts@@ -242,6 +242,91 @@ describe("SmartScalar > compute", () => {});});+ describe("scalar.show_comparison_value", () => {+ const cols = [+ createMockColumn({+ name: "Month",+ base_type: "type/DateTime",+ effective_type: "type/DateTime",+ }),+ createMockColumn({+ name: "Count",+ base_type: "type/Integer",+ effective_type: "type/Integer",+ }),+ ];+ const insights = createMockInsights({ col: "Count", unit: "month" });+ const comparisons = [{ id: "1", type: COMPARISON_TYPES.PREVIOUS_PERIOD }];+ const hideComparisonValue = createMockVisualizationSettings({+ "scalar.field": "Count",+ "scalar.comparisons": comparisons,+ "scalar.show_comparison_value": false,+ });+ const getComparison = (+ rows: RowValue[][],+ settings = hideComparisonValue,+ ) =>+ computeTrend(series({ rows, cols }), insights, settings).trend+ ?.comparisons[0];++ it("should keep the comparison value by default", () => {+ const comparison = getComparison(+ [+ ["2019-10-01", 100],+ ["2019-11-01", 300],+ ],+ createMockVisualizationSettings({+ "scalar.field": "Count",+ "scalar.comparisons": comparisons,+ }),+ );++ expect(comparison?.comparisonValue).toBe(100);+ expect(comparison?.display.comparisonValue).toBe("100");+ });++ it("should drop the value of a changed comparison when hidden", () => {+ const comparison = getComparison([+ ["2019-10-01", 100],+ ["2019-11-01", 300],+ ]);++ expect(comparison?.changeType).toBe(+ CHANGE_TYPE_OPTIONS.CHANGED.CHANGE_TYPE,+ );+ expect(comparison?.percentChange).toBe(2);+ expect(comparison?.comparisonValue).toBeUndefined();+ expect(comparison?.display.comparisonValue).toBe("");+ });++ it("should drop the value of an unchanged comparison when hidden", () => {+ const comparison = getComparison([+ ["2019-10-01", 100],+ ["2019-11-01", 100],+ ]);++ expect(comparison?.changeType).toBe(+ CHANGE_TYPE_OPTIONS.SAME.CHANGE_TYPE,+ );+ expect(comparison?.comparisonValue).toBeUndefined();+ expect(comparison?.display.comparisonValue).toBe("");+ });++ it("should keep the (No data) status of a missing comparison when hidden", () => {+ const comparison = getComparison([+ ["2019-10-01", null],+ ["2019-11-01", 100],+ ]);++ expect(comparison?.changeType).toBe(+ CHANGE_TYPE_OPTIONS.MISSING.CHANGE_TYPE,+ );+ expect(comparison?.display.comparisonValue).toBe(+ CHANGE_TYPE_OPTIONS.MISSING.COMPARISON_VALUE_STR,+ );+ });+ });+describe("comparison types", () => {describe(`comparisonType: ${COMPARISON_TYPES.PREVIOUS_VALUE}`, () => {const comparisonType = COMPARISON_TYPES.PREVIOUS_VALUE;diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/constants.ts b/frontend/src/metabase/visualizations/visualizations/SmartScalar/constants.tsindex 48932f219b7..af6761686b1 100644--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/constants.ts+++ b/frontend/src/metabase/visualizations/visualizations/SmartScalar/constants.ts@@ -1,25 +1,5 @@export const TEXT_SPACING = 4;-export const ELLIPSIS_BADGE_WIDTH = 22;--export const SPACING = 8;--export const ICON_SIZE = 13;--export const TOOLTIP_ICON_SIZE = 11;--export const ICON_MARGIN_RIGHT = SPACING;--export const VALUE_MIN_HEIGHT = 20;--export const PERIOD_LINE_HEIGHT = 16;--export const PREVIOUS_VALUE_SIZE = 19;--export const PERIOD_HIDE_HEIGHT_THRESHOLD = 70; // determined empirically--export const DASHCARD_HEADER_HEIGHT = 40;-export const MAX_COMPARISONS = 3;export const COMPARISON_TYPES = {@@ -33,4 +13,5 @@ export const COMPARISON_TYPES = {export const VIZ_SETTINGS_DEFAULTS = {"scalar.switch_positive_negative": false,"scalar.compact_primary_number": false,+ "scalar.show_comparison_value": true,};diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/definition.ts b/frontend/src/metabase/visualizations/visualizations/SmartScalar/definition.tsindex 5661de5b892..54f44d8b5e4 100644--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/definition.ts+++ b/frontend/src/metabase/visualizations/visualizations/SmartScalar/definition.ts@@ -67,6 +67,14 @@ export const SETTINGS_DEFINITIONS: VisualizationSettingsDefinitions = {inline: true,getDefault: () => VIZ_SETTINGS_DEFAULTS["scalar.compact_primary_number"],},+ "scalar.show_comparison_value": {+ getSection: () => t`Display`,+ // eslint-disable-next-line ttag/no-module-declaration -- see metabase#55045+ title: t`Show comparison value`,+ widget: "toggle",+ inline: true,+ getDefault: () => VIZ_SETTINGS_DEFAULTS["scalar.show_comparison_value"],+ },...columnSettings({getSection: () => t`Display`,getColumns: (@@ -103,6 +111,8 @@ export const SMART_SCALAR_CHART_DEFINITION: VisualizationDefinition = {identifier: "smartscalar",iconName: "smartscalar",canSavePng: true,+ noHeader: true,+ noLoadingHeader: true,minSize: getMinSize("smartscalar"),defaultSize: getDefaultSize("smartscalar"),diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/tests/SmartScalar.unit.spec.tsx b/frontend/src/metabase/visualizations/visualizations/SmartScalar/tests/SmartScalar.unit.spec.tsxindex e8a555346e0..e450e2dacbc 100644--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/tests/SmartScalar.unit.spec.tsx+++ b/frontend/src/metabase/visualizations/visualizations/SmartScalar/tests/SmartScalar.unit.spec.tsx@@ -1,6 +1,6 @@import userEvent from "@testing-library/user-event";-import { getIcon, renderWithProviders, screen, within } from "__support__/ui";+import { renderWithProviders, screen, within } from "__support__/ui";import { NumberColumn } from "__support__/visualizations";import Visualization from "metabase/visualizations/components/Visualization";import { registerVisualizations } from "metabase/visualizations/register";@@ -13,7 +13,9 @@ import type { Insight } from "metabase-types/api/insight";import { createMockSingleSeries } from "metabase-types/api/mocks";import {+ PREVIOUS_PERIOD_COMPARISON,PREVIOUS_VALUE_COMPARISON,+ STATIC_NUMBER_COMPARISON,getPeriodsAgoComparison,mockSeries as series,} from "./test-mocks";@@ -29,6 +31,8 @@ const createMockInsights = (insights: Partial<Insight>[]) => insights;const setup = (series: Series, width = 800) =>renderWithProviders(<Visualization rawSeries={series} width={width} />);+const getTrendSymbol = () => screen.getByTestId("trend-symbol");+describe("SmartScalar", () => {describe("current metric display", () => {it("should show metric value and date", () => {@@ -41,7 +45,7 @@ describe("SmartScalar", () => {setup(series({ rows, insights }));expect(screen.getByText("120")).toBeInTheDocument();- expect(screen.getByText("Nov 2019")).toBeInTheDocument();+ expect(screen.getByText(/Nov 2019/)).toBeInTheDocument();});});@@ -55,11 +59,9 @@ describe("SmartScalar", () => {setup(series({ rows, insights }));- expect(getIcon("arrow_up")).toBeInTheDocument();- expect(screen.getByText("20%")).toBeInTheDocument();-- expect(screen.getByText("vs. previous month:")).toBeInTheDocument();- expect(screen.getByText("100")).toBeInTheDocument();+ expect(getTrendSymbol()).toHaveAttribute("data-direction", "arrow_up");+ expect(screen.getByText("+20% MoM")).toBeInTheDocument();+ expect(screen.getByText("(100)")).toBeInTheDocument();});it("should show ↑ ∞% change", () => {@@ -72,12 +74,11 @@ describe("SmartScalar", () => {setup(series({ rows, insights }), 400);expect(screen.getByText("100")).toBeInTheDocument();- expect(screen.getByText("Nov 2019")).toBeInTheDocument();- expect(getIcon("arrow_up")).toBeInTheDocument();+ expect(screen.getByText(/Nov 2019/)).toBeInTheDocument();+ expect(getTrendSymbol()).toHaveAttribute("data-direction", "arrow_up");- expect(screen.getByText("∞%")).toBeInTheDocument();- expect(screen.getByText("vs. previous month:")).toBeInTheDocument();- expect(screen.getByText("0")).toBeInTheDocument();+ expect(screen.getByText("+∞% MoM")).toBeInTheDocument();+ expect(screen.getByText("(0)")).toBeInTheDocument();});it("should show decrease", () => {@@ -90,14 +91,12 @@ describe("SmartScalar", () => {setup(series({ rows, insights }));expect(screen.getByText("80")).toBeInTheDocument();- expect(screen.getByText("Nov 2019")).toBeInTheDocument();-- expect(getIcon("arrow_down")).toBeInTheDocument();+ expect(screen.getByText(/Nov 2019/)).toBeInTheDocument();- expect(screen.getByText("20%")).toBeInTheDocument();+ expect(getTrendSymbol()).toHaveAttribute("data-direction", "arrow_down");- expect(screen.getByText("vs. previous month:")).toBeInTheDocument();- expect(screen.getByText("100")).toBeInTheDocument();+ expect(screen.getByText("-20% MoM")).toBeInTheDocument();+ expect(screen.getByText("(100)")).toBeInTheDocument();});it("should show ↓ ∞% change", () => {@@ -110,12 +109,11 @@ describe("SmartScalar", () => {setup(series({ rows, insights }), 400);expect(screen.getByText("-100")).toBeInTheDocument();- expect(screen.getByText("Nov 2019")).toBeInTheDocument();- expect(getIcon("arrow_down")).toBeInTheDocument();+ expect(screen.getByText(/Nov 2019/)).toBeInTheDocument();+ expect(getTrendSymbol()).toHaveAttribute("data-direction", "arrow_down");- expect(screen.getByText("∞%")).toBeInTheDocument();- expect(screen.getByText("vs. previous month:")).toBeInTheDocument();- expect(screen.getByText("0")).toBeInTheDocument();+ expect(screen.getByText("-∞% MoM")).toBeInTheDocument();+ expect(screen.getByText("(0)")).toBeInTheDocument();});it("should show 0% change", () => {@@ -128,9 +126,22 @@ describe("SmartScalar", () => {setup(series({ rows, insights }), 400);expect(screen.getByText("100")).toBeInTheDocument();- expect(screen.getByText("Nov 2019")).toBeInTheDocument();- expect(screen.getByText("No change")).toBeInTheDocument();- expect(screen.getByText("vs. previous month")).toBeInTheDocument();+ expect(screen.getByText(/Nov 2019/)).toBeInTheDocument();+ expect(getTrendSymbol()).toHaveAttribute("data-direction", "no_change");+ expect(screen.getByText("0.00% vs. previous month")).toBeInTheDocument();+ });++ it("should show no change when the difference rounds to 0% (not an up/down arrow)", () => {+ const rows = [+ ["2019-10-01T00:00:00", 100],+ ["2019-11-01T00:00:00", 100.000001],+ ];+ const insights = createMockInsights([{ unit: "month", col: "Count" }]);++ setup(series({ rows, insights }), 400);++ expect(getTrendSymbol()).toHaveAttribute("data-direction", "no_change");+ expect(screen.getByText("0.00% vs. previous month")).toBeInTheDocument();});it("should show when data is missing", () => {@@ -143,9 +154,8 @@ describe("SmartScalar", () => {setup(series({ rows, insights }), 400);expect(screen.getByText("100")).toBeInTheDocument();- expect(screen.getByText("Nov 2019")).toBeInTheDocument();- expect(screen.getByText("N/A")).toBeInTheDocument();- expect(screen.getByText("vs. previous month:")).toBeInTheDocument();+ expect(screen.getByText(/Nov 2019/)).toBeInTheDocument();+ expect(screen.getByText("N/A vs. previous month")).toBeInTheDocument();expect(screen.getByText("(No data)")).toBeInTheDocument();});@@ -194,41 +204,468 @@ describe("SmartScalar", () => {expect(screen.getByText("810.8k")).toBeInTheDocument();});- it("should display tooltip with comparison info if card is not wide enough", async () => {+ it("should show only the first comparison plus a badge with the number of extra ones", async () => {+ const rows = [+ ["2019-09-01T00:00:00", 200],+ ["2019-10-01T00:00:00", 100],+ ["2019-11-01T00:00:00", 120],+ ];+ const insights = createMockInsights([{ unit: "month", col: "Count" }]);++ setup(+ series({+ rows,+ insights,+ comparisonTypes: [+ { id: "1", type: "previousPeriod" },+ { id: "2", type: "previousValue" },+ ],+ }),+ 400,+ );++ expect(screen.getByText("+20% MoM")).toBeInTheDocument();+ expect(screen.getByText("+1")).toBeInTheDocument();+ // the second comparison shows up only in the tooltip+ expect(screen.queryByText(/vs\. Oct/)).not.toBeInTheDocument();++ await userEvent.hover(screen.getByTestId("scalar-previous-value"));+ const tooltip = await screen.findByRole("tooltip");++ expect(+ within(tooltip).getByText("vs. previous month"),+ ).toBeInTheDocument();+ expect(within(tooltip).getByText("vs. Oct")).toBeInTheDocument();+ });++ it("should show no symbol and only the percentage on the smallest cards", () => {+ const rows = [+ ["2019-10-01T00:00:00", 45000],+ ["2019-11-01T00:00:00", 30759.47],+ ];+ const insights = createMockInsights([{ unit: "month", col: "Count" }]);++ setup(series({ rows, insights }), 100);++ expect(screen.getByText("30,759.47")).toBeInTheDocument();+ expect(screen.queryByTestId("trend-symbol")).not.toBeInTheDocument();+ expect(screen.getByText("-31.65%")).toBeInTheDocument();+ expect(screen.queryByText(/MoM/)).not.toBeInTheDocument();+ expect(screen.queryByText(/Nov 2019/)).not.toBeInTheDocument();+ });++ it("should list all comparisons in the query builder", () => {+ const rows = [+ ["2019-09-01T00:00:00", 200],+ ["2019-10-01T00:00:00", 100],+ ["2019-11-01T00:00:00", 120],+ ];+ const insights = createMockInsights([{ unit: "month", col: "Count" }]);++ renderWithProviders(+ <Visualization+ rawSeries={series({+ rows,+ insights,+ comparisonTypes: [+ { id: "1", type: "previousPeriod" },+ { id: "2", type: "periodsAgo", value: 2 },+ ],+ })}+ width={800}+ isQueryBuilder+ />,+ );++ const list = screen.getByTestId("scalar-comparison-list");+ expect(within(list).getByText("vs. previous month")).toBeInTheDocument();+ expect(within(list).getByText("vs. Sep")).toBeInTheDocument();+ expect(within(list).getByText("+20% (100)")).toBeInTheDocument();+ expect(within(list).getByText("-40% (200)")).toBeInTheDocument();+ // no "+N" badge in the full list+ expect(screen.queryByText("+1")).not.toBeInTheDocument();+ });++ it("should show a missing comparison in the full list", () => {+ const rows = [+ ["2019-10-01T00:00:00", null],+ ["2019-11-01T00:00:00", 100],+ ];+ const insights = createMockInsights([{ unit: "month", col: "Count" }]);++ renderWithProviders(+ <Visualization+ rawSeries={series({+ rows,+ insights,+ comparisonTypes: [+ { id: "1", type: "previousPeriod" },+ { id: "2", type: "periodsAgo", value: 2 },+ ],+ })}+ width={800}+ isQueryBuilder+ />,+ );++ const list = screen.getByTestId("scalar-comparison-list");+ expect(within(list).getByText("vs. previous month")).toBeInTheDocument();+ expect(within(list).getAllByText("N/A (No data)").length).toBeGreaterThan(+ 0,+ );+ });++ it("should show a single comparison inline in the query builder", () => {+ const rows = [+ ["2019-10-01T00:00:00", 45683.68],+ ["2019-11-01T00:00:00", 30759.47],+ ];+ const insights = createMockInsights([{ unit: "month", col: "Count" }]);++ renderWithProviders(+ <Visualization+ rawSeries={series({ rows, insights })}+ width={800}+ isQueryBuilder+ />,+ );++ // no list, one inline row with the date, the short description, and+ // the full (non-compact) comparison value; the trend symbol shows+ expect(+ screen.queryByTestId("scalar-comparison-list"),+ ).not.toBeInTheDocument();+ const row = screen.getByTestId("scalar-previous-value");+ expect(within(row).getByTestId("scalar-period")).toHaveTextContent(+ "Nov 2019",+ );+ expect(within(row).getByText("-32.67% MoM")).toBeInTheDocument();+ expect(within(row).getByText("(45,683.68)")).toBeInTheDocument();+ expect(getTrendSymbol()).toHaveAttribute("data-direction", "arrow_down");+ });++ it("should show the full layout on standalone question views", () => {+ const rows = [+ ["2019-10-01T00:00:00", 100],+ ["2019-11-01T00:00:00", 120],+ ];+ const insights = createMockInsights([{ unit: "month", col: "Count" }]);++ renderWithProviders(+ <Visualization+ rawSeries={series({+ rows,+ insights,+ comparisonTypes: [+ { id: "1", type: "previousPeriod" },+ { id: "2", type: "periodsAgo", value: 2 },+ ],+ })}+ width={800}+ isStandaloneQuestion+ />,+ );++ expect(screen.getByTestId("scalar-comparison-list")).toBeInTheDocument();+ });++ it("should show the collection badge next to the inline title", () => {+ const rows = [+ ["2019-10-01T00:00:00", 100],+ ["2019-11-01T00:00:00", 120],+ ];+ const insights = createMockInsights([{ unit: "month", col: "Count" }]);++ renderWithProviders(+ <Visualization+ rawSeries={series({ rows, insights, name: "Revenue" })}+ width={800}+ height={400}+ showTitle+ headerIcon={{ name: "star" }}+ />,+ );++ const title = screen.getByTestId("scalar-title");+ expect(within(title).getByLabelText("star icon")).toBeInTheDocument();+ });++ it("should not show a trend symbol for several comparisons in the query builder", () => {+ const rows = [+ ["2019-10-01T00:00:00", 100],+ ["2019-11-01T00:00:00", 120],+ ];+ const insights = createMockInsights([{ unit: "month", col: "Count" }]);++ renderWithProviders(+ <Visualization+ rawSeries={series({+ rows,+ insights,+ comparisonTypes: [+ { id: "1", type: "previousPeriod" },+ { id: "2", type: "periodsAgo", value: 2 },+ ],+ })}+ width={800}+ isQueryBuilder+ />,+ );++ expect(screen.getByTestId("scalar-comparison-list")).toBeInTheDocument();+ expect(screen.queryByTestId("trend-symbol")).not.toBeInTheDocument();+ });++ it("should show one tooltip at a time on the smallest cards", async () => {const rows = [["2019-10-01T00:00:00", 50],["2019-11-01T00:00:00", 100],];const insights = createMockInsights([{ unit: "month", col: "Count" }]);- setup(series({ rows, insights }), 50);+ // narrow width forces the smallest tier, where the title only shows on hover+ renderWithProviders(+ <Visualization+ rawSeries={series({ rows, insights, name: "Last invoice" })}+ width={100}+ showTitle+ />,+ );++ // hovering the comparison shows its tooltip, not the title+ await userEvent.hover(screen.getByTestId("scalar-previous-value"));+ const tooltip = await screen.findByRole("tooltip");+ expect(+ within(tooltip).getByText("vs. previous month"),+ ).toBeInTheDocument();+ expect(screen.queryByText("Last invoice")).not.toBeInTheDocument();+ await userEvent.unhover(screen.getByTestId("scalar-previous-value"));++ // hovering the rest of the card shows the title+ await userEvent.hover(screen.getByTestId("scalar-content"));+ expect(await screen.findByText("Last invoice")).toBeInTheDocument();+ });++ it("should not show a hover panel for a single fully-displayed comparison", async () => {+ const rows = [+ ["2019-10-01T00:00:00", 50],+ ["2019-11-01T00:00:00", 100],+ ];+ const insights = createMockInsights([{ unit: "month", col: "Count" }]);++ setup(series({ rows, insights }), 400);expect(screen.getByText("100")).toBeInTheDocument();- expect(screen.getByText("Nov 2019")).toBeInTheDocument();+ expect(screen.getByText(/Nov 2019/)).toBeInTheDocument();+ expect(screen.getByText("+100% MoM")).toBeInTheDocument();- // can see arrow and percent change- expect(getIcon("arrow_up")).toBeInTheDocument();+ // one comparison, fully visible — the panel would add no information+ await userEvent.hover(screen.getByTestId("scalar-previous-value"));+ expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();+ });- const lastChange = screen.getByText("100%");- expect(lastChange).toBeInTheDocument();+ it("should show the hover panel with full info on the smallest cards", async () => {+ const rows = [+ ["2019-10-01T00:00:00", 50],+ ["2019-11-01T00:00:00", 100],+ ];+ const insights = createMockInsights([{ unit: "month", col: "Count" }]);- // cannot see comparison period or comparison value b/c they are hidden- expect(screen.queryByText("vs. previous month:")).not.toBeInTheDocument();- expect(screen.queryByText("50")).not.toBeInTheDocument();+ // narrow width forces the percent-only format, so the panel adds info+ setup(series({ rows, insights }), 100);- // show tooltip- await userEvent.hover(lastChange);+ await userEvent.hover(screen.getByTestId("scalar-previous-value"));const tooltip = await screen.findByRole("tooltip");- expect(- within(tooltip).getByLabelText("arrow_up icon"),- ).toBeInTheDocument();+ expect(within(tooltip).getByTestId("trend-symbol")).toHaveAttribute(+ "data-direction",+ "arrow_up",+ );expect(within(tooltip).getByText("100%")).toBeInTheDocument();expect(- within(tooltip).getByText("vs. previous month:"),+ within(tooltip).getByText("vs. previous month"),).toBeInTheDocument();expect(within(tooltip).getByText("50")).toBeInTheDocument();});++ it("should open the panel with keyboard navigation", async () => {+ const rows = [+ ["2019-10-01T00:00:00", 50],+ ["2019-11-01T00:00:00", 100],+ ];+ const insights = createMockInsights([{ unit: "month", col: "Count" }]);++ setup(+ series({+ rows,+ insights,+ comparisonTypes: [+ { id: "1", type: "previousPeriod" },+ { id: "2", type: "periodsAgo", value: 2 },+ ],+ }),+ 400,+ );++ await userEvent.tab();++ expect(screen.getByTestId("scalar-previous-value")).toHaveFocus();+ const tooltip = await screen.findByRole("tooltip");+ expect(+ within(tooltip).getByText("vs. previous month"),+ ).toBeInTheDocument();+ });++ it("should not be keyboard-focusable when there is no panel", async () => {+ const rows = [+ ["2019-10-01T00:00:00", 50],+ ["2019-11-01T00:00:00", 100],+ ];+ const insights = createMockInsights([{ unit: "month", col: "Count" }]);++ // one fully-displayed comparison — no panel, so nothing to focus+ setup(series({ rows, insights }), 400);++ expect(screen.getByTestId("scalar-previous-value")).not.toHaveAttribute(+ "tabindex",+ );+ });+ });++ describe("scalar.show_comparison_value", () => {+ const rows = [+ ["2019-10-01T00:00:00", 50],+ ["2019-11-01T00:00:00", 100],+ ];+ const insights = createMockInsights([{ unit: "month", col: "Count" }]);+ const hideComparisonValue = { "scalar.show_comparison_value": false };+ const twoComparisons = [+ PREVIOUS_PERIOD_COMPARISON,+ STATIC_NUMBER_COMPARISON,+ ];++ it("should add an enabled Display toggle right after Compact number", () => {+ const widgets = getSettingsWidgetsForSeries(+ series({ rows, insights }),+ jest.fn(),+ );+ const displayWidgetIds = widgets+ .filter((widget) => widget.section === "Display")+ .map((widget) => widget.id);+ const widget = widgets.find(+ (widget) => widget.id === "scalar.show_comparison_value",+ );++ expect(displayWidgetIds.slice(0, 3)).toEqual([+ "scalar.switch_positive_negative",+ "scalar.compact_primary_number",+ "scalar.show_comparison_value",+ ]);+ expect(widget?.title).toBe("Show comparison value");+ expect(widget?.value).toBe(true);+ });++ it("should hide the comparison value but keep the percent change", () => {+ setup(series({ rows, insights, settings: hideComparisonValue }), 400);++ const comparison = within(screen.getByTestId("scalar-previous-value"));+ expect(getTrendSymbol()).toHaveAttribute("data-direction", "arrow_up");+ expect(comparison.getByText("+100% MoM")).toBeInTheDocument();+ expect(comparison.queryByText("(50)")).not.toBeInTheDocument();+ });++ it("should keep the (No data) status when the previous value is missing", () => {+ const rowsWithMissingValue = [+ ["2019-10-01T00:00:00", null],+ ["2019-11-01T00:00:00", 100],+ ];++ setup(+ series({+ rows: rowsWithMissingValue,+ insights,+ settings: hideComparisonValue,+ }),+ 400,+ );++ const comparison = within(screen.getByTestId("scalar-previous-value"));+ expect(+ comparison.getByText("N/A vs. previous month"),+ ).toBeInTheDocument();+ expect(comparison.getByText("(No data)")).toBeInTheDocument();+ });++ it("should hide the value of every comparison in the hover panel", async () => {+ setup(+ series({+ rows,+ insights,+ comparisonTypes: twoComparisons,+ settings: hideComparisonValue,+ }),+ 400,+ );++ const comparison = within(screen.getByTestId("scalar-previous-value"));+ expect(comparison.getByText("+100% MoM")).toBeInTheDocument();+ expect(comparison.getByText("+1")).toBeInTheDocument();+ expect(comparison.queryByText("(50)")).not.toBeInTheDocument();++ await userEvent.hover(screen.getByTestId("scalar-previous-value"));+ const tooltip = within(await screen.findByRole("tooltip"));++ expect(tooltip.getByText("vs. previous month")).toBeInTheDocument();+ expect(tooltip.getByText("vs. Goal")).toBeInTheDocument();+ expect(tooltip.getByText("25%")).toBeInTheDocument();+ expect(tooltip.queryByText("50")).not.toBeInTheDocument();+ expect(tooltip.queryByText("80")).not.toBeInTheDocument();+ });++ it("should hide the value of an unchanged comparison in the hover panel", async () => {+ const unchangedRows = [+ ["2019-10-01T00:00:00", 100],+ ["2019-11-01T00:00:00", 100],+ ];++ // the smallest tier shows the percentage only, so the panel is always available+ setup(+ series({+ rows: unchangedRows,+ insights,+ settings: hideComparisonValue,+ }),+ 100,+ );++ await userEvent.hover(screen.getByTestId("scalar-previous-value"));+ const tooltip = within(await screen.findByRole("tooltip"));++ expect(tooltip.getByText("vs. previous month")).toBeInTheDocument();+ expect(tooltip.queryByText("100")).not.toBeInTheDocument();+ });++ it("should hide the comparison values in the query builder list", () => {+ renderWithProviders(+ <Visualization+ rawSeries={series({+ rows,+ insights,+ comparisonTypes: twoComparisons,+ settings: hideComparisonValue,+ })}+ width={800}+ isQueryBuilder+ />,+ );++ const list = within(screen.getByTestId("scalar-comparison-list"));+ expect(list.getByText("vs. previous month")).toBeInTheDocument();+ expect(list.getByText("+100%")).toBeInTheDocument();+ expect(list.getByText("vs. Goal")).toBeInTheDocument();+ expect(list.getByText("+25%")).toBeInTheDocument();+ expect(list.queryByText(/\(50\)|\(80\)/)).not.toBeInTheDocument();+ });});describe("field selection", () => {@@ -249,28 +686,25 @@ describe("SmartScalar", () => {}),);expect(screen.getByText("120")).toBeInTheDocument();- expect(screen.getByText("Nov 2019")).toBeInTheDocument();- expect(screen.getByText("20%")).toBeInTheDocument();- expect(screen.getByText("vs. previous month:")).toBeInTheDocument();- expect(screen.getByText("100")).toBeInTheDocument();+ expect(screen.getByText(/Nov 2019/)).toBeInTheDocument();+ expect(screen.getByText("+20% MoM")).toBeInTheDocument();+ expect(screen.getByText("(100)")).toBeInTheDocument();});it("should use Count when selected", () => {setup(series({ rows, insights, field: "Count" }));expect(screen.getByText("120")).toBeInTheDocument();- expect(screen.getByText("Nov 2019")).toBeInTheDocument();- expect(screen.getByText("20%")).toBeInTheDocument();- expect(screen.getByText("vs. previous month:")).toBeInTheDocument();- expect(screen.getByText("100")).toBeInTheDocument();+ expect(screen.getByText(/Nov 2019/)).toBeInTheDocument();+ expect(screen.getByText("+20% MoM")).toBeInTheDocument();+ expect(screen.getByText("(100)")).toBeInTheDocument();});it("should use Sum when selected", () => {setup(series({ rows, insights, field: "Sum" }));expect(screen.getByText("220")).toBeInTheDocument();- expect(screen.getByText("Nov 2019")).toBeInTheDocument();- expect(screen.getByText("10%")).toBeInTheDocument();- expect(screen.getByText("vs. previous month:")).toBeInTheDocument();- expect(screen.getByText("200")).toBeInTheDocument();+ expect(screen.getByText(/Nov 2019/)).toBeInTheDocument();+ expect(screen.getByText("+10% MoM")).toBeInTheDocument();+ expect(screen.getByText("(200)")).toBeInTheDocument();});});@@ -290,9 +724,8 @@ describe("SmartScalar", () => {);expect(screen.getByText("100")).toBeInTheDocument();- expect(screen.getByText("Nov 2019")).toBeInTheDocument();- expect(screen.getByText("No change")).toBeInTheDocument();- expect(screen.getByText("vs. Sep")).toBeInTheDocument();+ expect(screen.getByText(/Nov 2019/)).toBeInTheDocument();+ expect(screen.getByText("0.00% vs. Sep")).toBeInTheDocument();});it("should handle no previous value to compare to", () => {@@ -308,9 +741,8 @@ describe("SmartScalar", () => {);expect(screen.getByText("100")).toBeInTheDocument();- expect(screen.getByText("Nov 2019")).toBeInTheDocument();+ expect(screen.getByText(/Nov 2019/)).toBeInTheDocument();expect(screen.getByText("N/A")).toBeInTheDocument();- expect(screen.queryByText("vs. Oct:")).not.toBeInTheDocument();expect(screen.getByText("(No data)")).toBeInTheDocument();});});@@ -334,9 +766,8 @@ describe("SmartScalar", () => {);expect(screen.getByText("100")).toBeInTheDocument();- expect(screen.getByText("Nov 2019")).toBeInTheDocument();- expect(screen.getByText("No change")).toBeInTheDocument();- expect(screen.getByText("vs. Sep")).toBeInTheDocument();+ expect(screen.getByText(/Nov 2019/)).toBeInTheDocument();+ expect(screen.getByText("0.00% vs. Sep")).toBeInTheDocument();});});});@@ -385,8 +816,7 @@ describe("SmartScalar", () => {expect(screen.queryByLabelText("warning icon")).not.toBeInTheDocument();expect(screen.getByText("100")).toBeInTheDocument();- expect(screen.getByText("Nov 2019")).toBeInTheDocument();- expect(screen.getByText("No change")).toBeInTheDocument();- expect(screen.getByText("vs. previous month")).toBeInTheDocument();+ expect(screen.getByText(/Nov 2019/)).toBeInTheDocument();+ expect(screen.getByText("0.00% vs. previous month")).toBeInTheDocument();});});diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/tests/test-mocks.ts b/frontend/src/metabase/visualizations/visualizations/SmartScalar/tests/test-mocks.tsindex 60ca77647ef..08dcba6198d 100644--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/tests/test-mocks.ts+++ b/frontend/src/metabase/visualizations/visualizations/SmartScalar/tests/test-mocks.ts@@ -4,6 +4,7 @@ import type {RowValues,Series,SmartScalarComparison,+ VisualizationSettings,} from "metabase-types/api";import type { Insight } from "metabase-types/api/insight";import { createMockStructuredDatasetQuery } from "metabase-types/api/mocks";@@ -24,11 +25,21 @@ export const getPeriodsAgoComparison = (value: number) => ({value,});+export const STATIC_NUMBER_COMPARISON = {+ id: "2",+ type: COMPARISON_TYPES.STATIC_NUMBER,+ value: 80,+ label: "Goal",+};+interface MockSeriesOptions {rows: RowValues[];insights?: Partial<Insight>[];field?: string;comparisonType?: SmartScalarComparison;+ comparisonTypes?: SmartScalarComparison[];+ name?: string;+ settings?: VisualizationSettings;}export const mockSeries = ({@@ -36,6 +47,9 @@ export const mockSeries = ({insights,field,comparisonType = PREVIOUS_PERIOD_COMPARISON,+ comparisonTypes,+ name,+ settings,}: MockSeriesOptions) => {const cols = [DateTimeColumn({ name: "Month", source: "breakout" }),@@ -47,10 +61,12 @@ export const mockSeries = ({return [{card: {+ name,display: "smartscalar",visualization_settings: {"scalar.field": field,- "scalar.comparisons": [comparisonType],+ "scalar.comparisons": comparisonTypes ?? [comparisonType],+ ...settings,},dataset_query: createMockStructuredDatasetQuery(),},diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/utils.ts b/frontend/src/metabase/visualizations/visualizations/SmartScalar/utils.tsindex 33324b50fda..5a645077d4c 100644--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/utils.ts+++ b/frontend/src/metabase/visualizations/visualizations/SmartScalar/utils.ts@@ -3,7 +3,6 @@ import _ from "underscore";import { dayjs } from "metabase/dayjs";import { formatNumber } from "metabase/utils/formatting";-import { measureText } from "metabase/utils/measure-text";import { uuid } from "metabase/utils/uuid";import { isEmpty } from "metabase/utils/validate";import {@@ -22,38 +21,7 @@ import type {RowValues,} from "metabase-types/api/dataset";-import {- COMPARISON_TYPES,- ICON_MARGIN_RIGHT,- ICON_SIZE,- PERIOD_HIDE_HEIGHT_THRESHOLD,- PERIOD_LINE_HEIGHT,- PREVIOUS_VALUE_SIZE,- SPACING,- VALUE_MIN_HEIGHT,-} from "./constants";--export const isPeriodVisible = (height: number) =>- height > PERIOD_HIDE_HEIGHT_THRESHOLD;--export const formatChangeAutoPrecision = (- change: number,- {- fontFamily,- fontWeight,- width,- }: { fontFamily: string; fontWeight: number; width: number },-): string =>- [2, 1]- .map((n) => formatChange(change, { maximumFractionDigits: n }))- .find(- (formatted) =>- measureText(formatted, {- size: "1rem",- family: fontFamily,- weight: fontWeight,- }).width <= width,- ) ?? formatChange(change, { maximumFractionDigits: 0 });+import { COMPARISON_TYPES } from "./constants";export const formatChange = (change: number,@@ -65,44 +33,6 @@ export const formatChange = (: formatNumber(n, { number_style: "percent", maximumFractionDigits });};-export const getValueWidth = (width: number): number => {- return getWidthWithoutSpacing(width);-};--const getWidthWithoutSpacing = (width: number) => {- return Math.max(width - 2 * SPACING, 0);-};--export const getValueHeight = (- height: number,- comparisonsCount: number,-): {- valueHeight: number;- comparisonsCount: number;-} => {- const valueHeight =- height -- (isPeriodVisible(height) ? PERIOD_LINE_HEIGHT : 0) -- PREVIOUS_VALUE_SIZE * comparisonsCount -- 4 * SPACING;-- if (valueHeight < VALUE_MIN_HEIGHT && comparisonsCount > 1) {- // Show only 1 comparison if more don't fit.- // We could try to show 1 fewer comparison, but then it'd be unclear- // in tooltip of which visible comparison the hidden one should be shown.- return getValueHeight(height, 1);- }-- return {- valueHeight: Math.max(valueHeight, 0),- comparisonsCount,- };-};--export const getChangeWidth = (width: number): number => {- return Math.max(width - ICON_SIZE - ICON_MARGIN_RIGHT - 2 * SPACING, 0);-};-export const COMPARISON_SELECTOR_OPTIONS = {ANOTHER_COLUMN: {type: COMPARISON_TYPES.ANOTHER_COLUMN,diff --git a/frontend/src/metabase/visualizations/visualizations/SmartScalar/utils.unit.spec.ts b/frontend/src/metabase/visualizations/visualizations/SmartScalar/utils.unit.spec.tsindex 8603e064ee9..ce2b06cbb05 100644--- a/frontend/src/metabase/visualizations/visualizations/SmartScalar/utils.unit.spec.ts+++ b/frontend/src/metabase/visualizations/visualizations/SmartScalar/utils.unit.spec.ts@@ -1,6 +1,4 @@import { DateTimeColumn, NumberColumn } from "__support__/visualizations";-import type { FontStyle } from "metabase/utils/measure-text";-import * as measureText from "metabase/utils/measure-text";import type {DatasetColumn,DateTimeAbsoluteUnit,@@ -20,26 +18,11 @@ import { COMPARISON_TYPES } from "./constants";import {COMPARISON_SELECTOR_OPTIONS,formatChange,- formatChangeAutoPrecision,- getChangeWidth,getComparisonOptions,getDefaultComparison,- getValueWidth,isComparisonValid,} from "./utils";-jest.doMock("metabase/utils/measure-text", () => ({- measureText: jest.fn(),-}));--const createMockMeasureText = (width: number, height: number) => {- return (_text: string, _style: FontStyle) => ({ width, height });-};--const getAutoPrecisionOptions = (width: number) => {- return { fontFamily: "Lato", fontWeight: 400, width };-};-describe("SmartScalar > utils", () => {describe("scalar.comparisons", () => {const FIELD_NAME = "Count";@@ -528,59 +511,6 @@ describe("SmartScalar > utils", () => {});});- describe("getValueWidth", () => {- it("should not return negative values", () => {- expect(getValueWidth(1)).toBeGreaterThanOrEqual(0);- expect(getValueWidth(1)).toBeGreaterThanOrEqual(0);- });- });-- describe("getChangeWidth", () => {- it("should not return negative values", () => {- expect(getChangeWidth(1)).toBeGreaterThanOrEqual(0);- expect(getChangeWidth(1)).toBeGreaterThanOrEqual(0);- });- });-- describe("formatChangeAutoPrecision", () => {- let measureTextSpy: jest.SpyInstance;-- beforeEach(() => {- measureTextSpy = jest.spyOn(measureText, "measureText");- });-- afterEach(() => {- measureTextSpy.mockRestore();- });-- it("should use maximum 2 fraction digits precision when text fits", () => {- measureTextSpy.mockImplementationOnce(createMockMeasureText(100, 50));-- expect(- formatChangeAutoPrecision(1.23456, getAutoPrecisionOptions(100)),- ).toBe("123.46%");- });-- it("should use 1 fraction digit when 2 digits don not fit", () => {- measureTextSpy.mockImplementationOnce(createMockMeasureText(101, 50));- measureTextSpy.mockImplementationOnce(createMockMeasureText(100, 50));-- expect(- formatChangeAutoPrecision(1.23456, getAutoPrecisionOptions(100)),- ).toBe("123.5%");- });-- it("should use no fraction digits when they do not fit", () => {- measureTextSpy.mockImplementationOnce(createMockMeasureText(103, 50));- measureTextSpy.mockImplementationOnce(createMockMeasureText(102, 50));- measureTextSpy.mockImplementationOnce(createMockMeasureText(101, 50));-- expect(- formatChangeAutoPrecision(1.23456, getAutoPrecisionOptions(100)),- ).toBe("123%");- });- });-describe("formatChange", () => {it("should format as percentage", () => {expect(formatChange(-5)).toBe("500%");diff --git a/frontend/src/metabase/viz-core/types/definition.ts b/frontend/src/metabase/viz-core/types/definition.tsindex 7d849be1245..e68d132f5c8 100644--- a/frontend/src/metabase/viz-core/types/definition.ts+++ b/frontend/src/metabase/viz-core/types/definition.ts@@ -322,6 +322,7 @@ export type VisualizationSettingsDefinitions = {SmartScalarComparisonWidgetProps>;"scalar.field"?: SeriesSettingDefinition<Value, Props>;+ "scalar.show_comparison_value"?: SeriesSettingDefinition<Value, Props>;"scalar.switch_positive_negative"?: SeriesSettingDefinition<Value, Props>;scale?: DatasetColumnSettingDefinition<Value, Props>;"scatter.bubble"?: SeriesSettingDefinition<Value, Props>;@@ -394,6 +395,7 @@ export type VisualizationDefinition = {disableClickBehavior?: boolean;canSavePng?: boolean;noHeader?: boolean;+ noLoadingHeader?: boolean;hidden?: boolean;disableSettingsConfig?: boolean;supportPreviewing?: boolean;