Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(bi): improve chart layout and restore drilldowns (#114004)

Marius Andra156f947f5caf
diff --git a/docs/published/handbook/engineering/data-warehouse.md b/docs/published/handbook/engineering/data-warehouse.md
index a4e256103f3b..23eca5c74131 100644
--- a/docs/published/handbook/engineering/data-warehouse.md
+++ b/docs/published/handbook/engineering/data-warehouse.md
@@ -32,6 +32,8 @@ Insights can be saved or updated before running the SQL. Updating a view still r
Choose a connection in the **Data** panel, then select a table below it. **Run** is the first toolbar action, before **Swap rows and columns**.
+**Chart types** opens the chart picker. While it is docked, the visualization hides its duplicate chart selector. Compact dropdowns keep the data pane and chart controls dense. Visualization controls share a toolbar that wraps as the worksheet narrows, and the Series/Display settings panel scrolls independently. Date dimensions sort oldest first by default, including in tables; explicit sorts still take precedence. Time charts show years centered below their date ticks. Clicking a bar opens the drill-down options for that result.
+
**Auto update** is off by default and remembers your choice. Selecting a table alone can run a count when you click **Run**. In wide worksheets, drag the divider between the data and analysis panels to resize the data panel, or drag the analysis panel's right edge to resize that panel independently.
BI usage keeps the existing `sql-editor-bi-mode-selected`, `sql-editor-bi-query-run`, and `sql-editor-bi-query-saved` events. Their properties describe table calculations, Top N, comparisons, formatting, axes, totals, and related/property field counts. The `bi-worksheet-action` event's `action` property defines the funnel: `opened`, `source_selected`, `first_chart`, `saved`, `added_to_dashboard`. The first chart is the first nonempty successful result per editor visit; reruns and failures do not count again. Saved and dashboard steps include `insight_id`. Additional actions record drill-down choices, related-table expansion, and property browsing/search. These events exclude SQL, source names, field names, formulas, search text, filter values, and result contents.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index ca0a7e52a03d..5a4c6d235e64 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6498,6 +6498,10 @@ snapshots:
hash: v1.k794b7964.a9de84c1f27dab319f1c8144f25dcb2ee86f24e4a8a81e3e4f1af8772691a853.-8abFqmvKqn68PvlPf_7mXyGfyzzVGlhwqMEIRLT1VQ
products-autoresearch-training-run-row--run-produced-the-champion--light:
hash: v1.k794b7964.99a7492e480121211d7b1bdcc80551dd1237c844db39f3e125a3419fcea07392.vVadWxwzVkcx_5Rs8NM_JR-rgQ1Mddc8LADMSDGJ5qA
+ products-business-intelligence-chart-years--partial-years--dark:
+ hash: v1.k794b7964.2a6374590be64f7a06a222b2c702f194a05289115c618d7ec8864a6b62f85631.wJMlvq8tZxD3TVKI8Lt9pHxK7YwHkdHS2QDRpZaqRJo
+ products-business-intelligence-chart-years--partial-years--light:
+ hash: v1.k794b7964.ad1cfd8dda30f43abe49015b147072655ea1caf4c489b5e2486c2b30c564179a.LmriewEzsh1fJaMdGc99tyCLB-7BwdQrOAdjdmPaE74
products-business-intelligence-comparison-summary--kpi--dark:
hash: v1.k794b7964.f57d81874455ecab234e86bea129aa84be0ab55617e1a3f78e4df5ae0b5bef03.0KX9-_jhsiyC9WxFodb_tR84PkA3Sg_F1zEuQGSIPfw
products-business-intelligence-comparison-summary--kpi--light:
@@ -9783,73 +9787,73 @@ snapshots:
scenes-app-data-warehouse-settings-schemas--multi-schema--light:
hash: v1.k794b7964.2f4bd6098d8c54c0b25ed9ee0ef7770a59c4d343191d065b0814299a27a42a22.6jWN3F1ozzMy7KZRTYHY1XPxasFL_u2H8Ybw9WcDjfk
scenes-app-data-warehouse-sql-editor--bi-calculated-measure-editor--dark:
- hash: v1.k794b7964.1c26a867126bd8f979d25b607a2b97f8ca6c6247af3277a01f3743b70ee79906.2WumIrqVnmCHOdKoSFlfOweHTj1x0mY2uixo5g-bBkE
+ hash: v1.k794b7964.87b9871ba40527e15aff583d855822e3d4bd58d0dfbba0c5ebab4f6fc6f28d59.G36fGeQ5awgRh8N2pp3qgS7p3J5-56CokKJitervSQk
scenes-app-data-warehouse-sql-editor--bi-calculated-measure-editor--light:
- hash: v1.k794b7964.e372f1acdc4460bd92df4c1d47b1995013566643ede9a4df193fd8519656a31e.0FqHLQiwr1QawwbcwZjh4O5bP0W_DEgWWXRX8etSTUU
+ hash: v1.k794b7964.69c71d482b1b19aa18a81b5ba0fc0bb038d8f3bdc9bdb0a7286c9addb4893dc2.LjgKhmcTELX-Cd50ZnnKmKLTGxv3AH0cD5BfLrBKfQ8
scenes-app-data-warehouse-sql-editor--bi-category-groups--dark:
- hash: v1.k794b7964.66ec45051a096c59a68b697692b10bb086a3ac739c25015e7cf0282e7c7053ad.DEBjzrYLSC2paBtr6HfGr8R8sGjsyokzXe2A_NozrHA
+ hash: v1.k794b7964.63f7b914c5960ab4f854637942ea11592193028e6293b951a760bfae1eb67b70.-YMxno9UDZTKvlRloZRdBQmx0kCRg0qKnFHXfhPbslY
scenes-app-data-warehouse-sql-editor--bi-category-groups--light:
- hash: v1.k794b7964.69f108b72473d757b7a8ce8f8465160e7d09d195d307037bc3e16f885051890d.hAmrrJ3QY4XcTBG0XB55k2ENtaQBeDGWgAaaWl0V7v8
+ hash: v1.k794b7964.81a477c02903248226b1d7926e9255633dd5cc12701133afb1244048bb5c8ae6.jgbC8pd2rT_AUI0ETrU0qlBlcMs_-ake47UxOm_vZjA
scenes-app-data-warehouse-sql-editor--bi-combined-measures--dark:
- hash: v1.k794b7964.09a8bc2f32bdc11358e8e2e47e8ee27f24c6c685013360f6d1cfa4c1d5b5936f.U-vRC09hHiNsoVqmtEHHk3J22eBn-fsFz_LD87tZX1Q
+ hash: v1.k794b7964.aae60216a2288d48b097b0acd69db10681d6ec0351a77c7018431eeec5083212.GFuC4m0VvbcEYMn4q0z7WDKWuO5AyCV3-RGH9wt6iY4
scenes-app-data-warehouse-sql-editor--bi-combined-measures--light:
- hash: v1.k794b7964.381714c67d398a94e60460022d6d176049b3cd9799d68a6389efffcc73c71dfd.wvz5lIWhFxRTY0Csvsp2HQoIZsF6VWBTkuTwtSP2okE
+ hash: v1.k794b7964.f75bacccbc710f2775774539cadc709b9abc2e81ce07aadd3e9bdc2b4ae59d6e.KumXcqoOUGDfHs7S3jcFIakY99FaTGBFoQ7mMQsZw-E
scenes-app-data-warehouse-sql-editor--bi-connections--dark:
- hash: v1.k794b7964.30fa64956a72d0e5ad04915a689ab4ae2f28033b1ccf2ed64aba828fdf72376e.OK5R-iy-rRpBfuvZMttjS35Mk9xbsw2k1lohMWcdPoo
+ hash: v1.k794b7964.85e793119bfab812807ee881d0d947d7c7bc703ba59b38895b8d6b2e6831de3a.IXcQpl7SOaT4jT-OBXmNgHJKUxk3WW4WPhqRniCI5Vo
scenes-app-data-warehouse-sql-editor--bi-connections--light:
- hash: v1.k794b7964.e94d9579f06adc1ce94daa983313f3ad61d31d719eac7ea7c7e98f464eda46df.OM_zpS2uSuzdRWdOeIunASj-usUdZ2nGj70neegODjI
+ hash: v1.k794b7964.64342d64b102cb15df680e45e3775ab077738e1088ef531a635bf00940c8bf4a.an8bPIGZHMUsuJ5q9eaZPLyGDyptetmoepIzpKfuTQg
scenes-app-data-warehouse-sql-editor--bi-data-source-picker--dark:
- hash: v1.k794b7964.29916b4b2b70a92b1ee1c480674c9df95379037584297bb489ede99415807a03.a4XGwj4B_nCBBOXLgL0csu8w4yW0YkjQK3-9OdHrfBU
+ hash: v1.k794b7964.0bcebcb125477fff88cc5f3603782cabfe3663fa67436f6ff1d97d3b7333f7aa.03zp45mQbNsNqbjyc1HIX6R2kyjtg0zoFlqir2fkeE8
scenes-app-data-warehouse-sql-editor--bi-data-source-picker--light:
- hash: v1.k794b7964.4fdeed1bbd422768c488e936728e0ebd850418076a54086460342cf6763bf533.pEalqCxPAWUuLTg4huXBRzEjd_zVJMyhWpHAn4Ncm-k
+ hash: v1.k794b7964.70d0f29b0d7d5a8d4bd5cc285933f4b3eed84632e031b04eb1a9c3b5f0e00183.FEm91SyUWiPiygxYEeMtsEMTxVCW5GQUmGBeFhSyQA4
scenes-app-data-warehouse-sql-editor--bi-drilldown--dark:
- hash: v1.k794b7964.182a98228bfd31547d3da94736c9f4edd46bcf2df159f7b2f205366e1b2861bb.lTR1rIlnk0Fv3y7XjHRI-bvfL6Z7C2O5t3h3pl9yG5A
+ hash: v1.k794b7964.08db0d1af995b93f629d5f9dd62bf2d28d3d3092370300287c766bfbec8dce0c.LhsqG-jRrxEs1cJgLZidBWN1Cruwyz99pMYvtpkHL2M
scenes-app-data-warehouse-sql-editor--bi-drilldown--light:
- hash: v1.k794b7964.7c6a504d11a8b8ac5b6520d91e4ba717f8b3cd06a954d63009cd190aba5b81e3.j-8gZpi8prOIMMRnYxkxe4NJV8IujxqYLRUuENWtj4Q
+ hash: v1.k794b7964.64086844ccfeee7b554e8800720fbdc36338ff0be87382481ed98a357bd7eada.1bOKRn1KYdVw_meBxCBcLH0l6KYqr7wUFFhwZG2d3dM
scenes-app-data-warehouse-sql-editor--bi-edit-saved-insight--dark:
- hash: v1.k794b7964.a3e27aeaf26aa9cbced69edcf2bd79432b009741a80ac0803ac42d0a014a11ed.K2aPuoBTdiu9licgR3HVVjI0-r8hqwx__zDELafRSVE
+ hash: v1.k794b7964.7c3fe1ba42a4fc4f4c325c89bf4392d6af99dafb14bccb1a23eefdab88d7fe1f.xKcolxz25yu5zobGf1ZDsNQiyHgbV6-8wazoYW3QiV4
scenes-app-data-warehouse-sql-editor--bi-edit-saved-insight--light:
- hash: v1.k794b7964.02422eb6c6206e94f8f7c0c2fa63e494604bd0f46fab1a29a98ea5037a499c58.qh-YHmBLo0OYAJHhCMSODJIZccX-LVmnnuJAV8EljyI
+ hash: v1.k794b7964.2e64417ea9fcb4976527abd32ac4ada02c47eaf4f73fad15926e6725418bc845.H7WmCLHHz3Kyje1Zq7ZyBBwzQX-WSzSxPI4Dl9_15hc
scenes-app-data-warehouse-sql-editor--bi-empty-worksheet--dark:
- hash: v1.k794b7964.02b2c5ef535309fbabbc662d0a18c0aa63186b35a5b2b66d141f0a238d5f11ab.Wkl7IYUP_AQq3I5eRVBzl8fDMvmDEYE6oa9q_iF2_Xc
+ hash: v1.k794b7964.a170032c57df0f7a688bf31af7447bf57b41a1ad409cf780eef81a64a60e2469.MFLzlChSLXxmCsubO1GfEO6zSMGJo1nBHVa9-vgir2g
scenes-app-data-warehouse-sql-editor--bi-empty-worksheet--light:
- hash: v1.k794b7964.a617727cf00b1a3e9eadc5e327bc51685aa1fece1f3347fa2f3213d433214805.9IY8Hk8zebtKx6bbkP56iIQ0MgU3rEu3wihYVovPBfE
+ hash: v1.k794b7964.df208814a9f5ec08690c857c3022a77b74a6b103a98ac92c8ee93e3dc972f3a0.oSPLcdtvlrVFgbDeX5CM0V_Ok0smRmt-hQpyTsx4PkY
scenes-app-data-warehouse-sql-editor--bi-measure-display--dark:
- hash: v1.k794b7964.9e0d3533dd5ae0783cc0420475e78e5fe5f87d47a43d6630524882ef9a9f77f7.uf0QFgT2W9wcED0qCCDISHHTYTX--hklwiBQTkyPLpo
+ hash: v1.k794b7964.1f1d13fb4ce71f3bb6a8462337b417f366ba9728fc7cfe7815c7848832c4bb28.wpINoBXgRTrOAHUSjyGjgTFZP_N9dqWg9umtiMM2nHU
scenes-app-data-warehouse-sql-editor--bi-measure-display--light:
- hash: v1.k794b7964.c50185dcf01dc16647795157545a16269ea79403bd04fc6b63d86d2e9991fd12.6C4Pz3LIrHUbp1LbYcRE2vN_HJjikyQQeonijKS2o1A
+ hash: v1.k794b7964.c8e9eb07cf403a27ecbaa5ff93899bbafee4f194653d2b967e46dcb1e5910073.0O9yXMzXEZk83pH3eJ69yNfa2KUR5pULsgaHg8syyH4
scenes-app-data-warehouse-sql-editor--bi-mode-worksheet--dark:
hash: v1.k794b7964.ba547f3a41ec2e8b517142f1a6549848e39ce50da6245a8185117128424b5fc6.mto7EGXrYQwr6BBCyPfkDZS_fYGuYIb_k6KbIkShjQY
scenes-app-data-warehouse-sql-editor--bi-mode-worksheet--light:
hash: v1.k794b7964.f17b0a24d40667261252cd224fc879c6303e143cdb46582ea0c3d58516a96508.B3zMdPmNMyvPT29AsSlyzi2TOsGlD40QZz4jThEmkXY
scenes-app-data-warehouse-sql-editor--bi-numeric-bins--dark:
- hash: v1.k794b7964.49ccf73c1eaefe539b3eb14172f6fc20577693ecfd0b2fc969b7c8a33f344b6c.2RAKqVztCf6GQ2MXlOgaP_AHgjJYJHlBtB4RW9JzmBM
+ hash: v1.k794b7964.1313c706915c92807e91e24cceeb57db1d66dfc0b41c9b674ee3b91320d952f8.TK0iXH4j6c7piySgpcruvXiCY_SNbAAZzXkW70NOSDU
scenes-app-data-warehouse-sql-editor--bi-numeric-bins--light:
- hash: v1.k794b7964.57aea5873020e95f2201bf79c5c715c398b6411ff7893c30e24b0f09c472fe22.K__odgjET4LULBxnyhf9KIxhIBpCF3sStZEx5bxjuC0
+ hash: v1.k794b7964.003a65922e0b0b3df7f202a6266532ab990c04eee188486eec565bf3a287c48c.ppIpaZ3GKuxnX5hoiMzYdtcq2c7pMKJl5AKeVTJAQkM
scenes-app-data-warehouse-sql-editor--bi-one-click-comparison--dark:
- hash: v1.k794b7964.bf9cdbe93cab7bf8f2cc7bc226082cea7dbc69cffb6496ce7b991b18d42fa682.8qoSKEAsOEoHEg8AbdLRi1olkEjewJKyZgqoQLvIEes
+ hash: v1.k794b7964.0c59b3e1c90da6324505aecf74d1a7cb0f80df6acb867a1a7faaf9dcbf80a9cb.VLXgicQzk8TTEKODWzOpe13Dczpb-0xucxU1LLUGa-o
scenes-app-data-warehouse-sql-editor--bi-one-click-comparison--light:
- hash: v1.k794b7964.4905cca54a8784621c6b308a250aea5189f1174f9bd5ae8a2b3ffcb057271c5d.Yk5VBWhfk5hRBcBxcC2ZrfOtrM-E1Fqgc9sRDwgpeNE
+ hash: v1.k794b7964.a7d88cdef92e7b49cdda12c3ebc3f4e386516a557d6439c85620a9e8ee1373b6.LBE--oihN1Aae_qLek7tZ_UmM3QZPEJkmQL6lAo_eDs
scenes-app-data-warehouse-sql-editor--bi-pivot-totals--dark:
- hash: v1.k794b7964.ba7dd8440b82298b8a835b074caaa583b9891daedebbab72e63d46ca071296fd.rpuG6tkNxpKPeqhG9OfyGm5zmAbxX8n6050enO2w0k8
+ hash: v1.k794b7964.aab9e3fccc447b883fc831a2f66702fbb88386a0b6e6576144627e707962e5ba.a9z8cq1U7rh2m3M7ZHOlsfNZ8mO5uqJ9PpEwswLkKIM
scenes-app-data-warehouse-sql-editor--bi-pivot-totals--light:
- hash: v1.k794b7964.21c60f1857e95b0c1c69838d2e9cfd89172a39a73190680e20242082f8f4e418.gJ_J-XhbGJW54fGkLwYsvUlNjukbVkSo38aToib-iC0
+ hash: v1.k794b7964.e28412b7fa94b818d4bcde4891917aabd331d0958f42cfe892a711f88524bb54.twokl8WCvexW7I37Tif0EbHOmCEMte2T71YGe_w2PMc
scenes-app-data-warehouse-sql-editor--bi-quick-filters--dark:
- hash: v1.k794b7964.891179a5c3b2812c50491fee62425f1ece998d04e6e07cf3193dc3f8f0225c04.wGgdjGeHK86dTMz-KhnC1Yu8SLgTMLOtHH2uopiDNV8
+ hash: v1.k794b7964.299a5a1d8c9f142522a19e26614c2470740ae2e6a8c241d81b1e60f3e32530c8.N5SaivMuuz77BS9wN99ve200hex_Wm9ZOX2Zpi8ShHw
scenes-app-data-warehouse-sql-editor--bi-quick-filters--light:
- hash: v1.k794b7964.6dc50c0ffe71227b8bc73fb2803d8f71a7e194ce75c0e0b3cb2ef6250c9bff45.eZQCYcqOtICgnZDi4EA8eLvQH3KrWO7cNT-ySses3C0
+ hash: v1.k794b7964.f71b920765b40a67bc469a1e247040dffa52eafd3617a6a8e19dd2d2a03ed7ea.ZLQRm6vISDJ0ecDRC6sy5iLMVbm-urWlsRdrutVmGOk
scenes-app-data-warehouse-sql-editor--bi-quick-filters-narrow--dark:
- hash: v1.k794b7964.45cb34e1887e2ef904eda3659590e0a0ff2779cbdc79ce1660527746043cd776.as-M5pRkI-EQcNTHXhRpozCY5q8FYhkyV34K8OgivYY
+ hash: v1.k794b7964.fd3f20adf9fc6bf746f8988f1a7c1d627bff099e1e8b19b8a480ed573b7eb4ab.lEOhofKVjITKytr77tjg6jf660bwa5KmEm4YJlc6UCE
scenes-app-data-warehouse-sql-editor--bi-quick-filters-narrow--light:
- hash: v1.k794b7964.ad38cf101821f04b7a4c54859b79f9267eec63f988405cb7d8b3cc4ce06fafe7.10gV65jLd9_8rrrmJmAxweXy-4Sy7ayKJhWCUlDDy7Q
+ hash: v1.k794b7964.dddbf848e1fc7ca07774fa11456b1184ac048144917339fbe9a9ce5448f2947f.i3reZPyAOzno3cwRy5FxK46UxLHLt6paZvtg4iSjW50
scenes-app-data-warehouse-sql-editor--bi-saved-insight--dark:
- hash: v1.k794b7964.24b439b90164ae7db044155845ca7672d56a4cba3114d585495e5dda13f24767.wjZpVrMTZpKpD3Ih75kZd7Q0gbrlPNB-GP22OYGTzZE
+ hash: v1.k794b7964.b5232e6c73960ca4f1ebb963ee8a0d82d4b419d4ebdaf8d2564d7535684c0c7c.-z4_dSLh23mW5qEG88QK4ybNGNbLLBfbd4kAHo6BT7U
scenes-app-data-warehouse-sql-editor--bi-saved-insight--light:
- hash: v1.k794b7964.a81476825e10522264b1bc91fdd971de2742ac5a58336132a16c5783d3341fb1.7U0EUeE-WqdHuHI4EedMwFE35R94newfE_FFgsD3Do4
+ hash: v1.k794b7964.2e321b996c4f4216c36e9e8272cbffa243759e37dfc1685c5a33bdceaa411110.Cfm4ZrRTvWUUa_rl2kP_6sGvXH5Quw6fkPsvo-rkuBM
scenes-app-data-warehouse-sql-editor--bi-table-analysis--dark:
- hash: v1.k794b7964.467d3be4d930d429885a56a1a6fb3f5499306bdd20f183b0e295a68a4a8ec9e3.ovgkf--OxmJTB6ZJgX87yaL3JsNgfs6hSX_rEcu3838
+ hash: v1.k794b7964.698efecc8dd863d7eec52fb2a4e7bf55de1fa9d498cdc2f527cf09b7eb6dedab.V1VDO9CX4qvGtZPcmWuKwoUUKr5ykUOljulg_TAkjpI
scenes-app-data-warehouse-sql-editor--bi-table-analysis--light:
- hash: v1.k794b7964.614d75dcf1a8eb88a89855d533a073166e0ca184c0364d703f157de14a457f30.Yhom8F1BQD4NGDykAPbOK-Ycn5SLeeWrDRSd66S0nR4
+ hash: v1.k794b7964.7c0758873b738fa29b6235ff169cc4154ec2272487ef6c015deb133d97648a1b.4J9w34_-Z43HNL-yAhrYMLDTvlq_Yp_zS5TKl-gKktg
scenes-app-data-warehouse-sql-editor--edited-insight--dark:
hash: v1.k794b7964.334b216a8359c768613cdec5b99a8a8ee26b6b5fac76397eaed8d6d1401a23c0.0pI7NMTufzUIfDel9Ngmhv3P3sdBu6IgpSj5xYNmYrY
scenes-app-data-warehouse-sql-editor--edited-insight--light:
@@ -11879,13 +11883,13 @@ snapshots:
scenes-app-insights-product-analytics-insight-home-guide--stickiness--light:
hash: v1.k794b7964.a0210d5b109541457b72b6bd02509db0827d03a85e1fc986d46ace118de975de.3cCSNF6omEhMKUEBSLVzi3YLvnVrSwZ7UA3w2MkL7Qc
scenes-app-insights-side-panel-actions--saved-data-visualization--dark:
- hash: v1.k794b7964.57c582d5224e7a3008ca82becdcb0b7108d54df64a341aa2f66927f193534a02.aLr9rbd8XdUYtM06IQBvu_3ylrHYi6RoR4FYZ1f8Dng
+ hash: v1.k794b7964.0db2a7637e314ea14e0657f37c14996241f84f0652e9de66c488bb3ab41c074f.Rj3VyjFRI5S4Ju-f8eUu0dDPF-C25i7I7mDCK2RgE1Q
scenes-app-insights-side-panel-actions--saved-data-visualization--light:
- hash: v1.k794b7964.2042476ecd2ee70f51405e876669b9fa9002a1ead8cc5d9d2060311dd6fce77e.7x99Scpof55eY7Hy80Ysru6pVpsQ7dWGSXuHPT2p0ds
+ hash: v1.k794b7964.602be55b40a5fdcd79839a50eb3ced165702357fda6074051233988743b6a263.UOEP704d0eIAA0ilaz1KTYezDdWn8SI0BWZtGa11LTE
scenes-app-insights-side-panel-actions--saved-hog-ql-data-table--dark:
- hash: v1.k794b7964.57c582d5224e7a3008ca82becdcb0b7108d54df64a341aa2f66927f193534a02.dhUGWzrtjNWIv8nOf6CXONIGwOlccEORvs-KP979hz8
+ hash: v1.k794b7964.0db2a7637e314ea14e0657f37c14996241f84f0652e9de66c488bb3ab41c074f.B6KmjbI_mJmc8ILOntbcjhCFR37MdMuyd82nVI4a-Pg
scenes-app-insights-side-panel-actions--saved-hog-ql-data-table--light:
- hash: v1.k794b7964.2042476ecd2ee70f51405e876669b9fa9002a1ead8cc5d9d2060311dd6fce77e.EqStq-QS115jPsfkh2v5r6jgRS0aEHABbQYlZXYQfL4
+ hash: v1.k794b7964.602be55b40a5fdcd79839a50eb3ced165702357fda6074051233988743b6a263.5AuLPU3Rcd90xrrOMpWjO2SowfaamP291mM0FEoAn_M
scenes-app-insights-side-panel-actions--saved-trends-insight--dark:
hash: v1.k794b7964.bbb281c33fb319c3533f089f9012364e09adb7ec4ec105bbd031035cfec30d8f.t3-xk6ogh7h_ngxjAm_Kv9sKzEprz03rTKu_ZixujOc
scenes-app-insights-side-panel-actions--saved-trends-insight--light:
@@ -12543,13 +12547,13 @@ snapshots:
scenes-app-notebooks-generated-widgets--before-generation--light:
hash: v1.k794b7964.f8eabbbe270e16f6db6253fac4ccc1298d6486f4fcc54d086f39b494e32276bb.byEVF2WvcVULWZ_b-qJMNkCK-hCMqS-EcQNFNyVUVd4
scenes-app-notebooks-jupyter-mode--jupyter-mode--dark:
- hash: v1.k794b7964.b1b5795dd47e91aa9dde3efaecbf05c9dccefb9b62633c384d18625c7e8b7c53.CxjZTRuVEQ4Y8OjVARnLCxcz0UThrY8iLmEpSYrR8cM
+ hash: v1.k794b7964.999bb1c59ceaa9a76b1bdc28b2b24f67f345d22e986e2ae7aad57cffaaf25621.2A56iTWWLKXdmpS1g7TooVeM3DY-y1Mbmq2bjtpt5vE
scenes-app-notebooks-jupyter-mode--jupyter-mode--light:
- hash: v1.k794b7964.cf76ee4914da9e36af37dfb32ceb7b2b2ea280e3aef926b2e916e95034c5255b.ym9yp28m4aMZJQY00RJPonAeixJ8Tg47EFuqeYRSdkM
+ hash: v1.k794b7964.b9f5f2ae8ff0b6921c71d8bc102e0aae6d4029589a4aa9cbea567d9d09644f73.TV6wY-T8RH14L5AInke72aCjROD3aHhqExNWHwBdDy4
scenes-app-notebooks-jupyter-mode--jupyter-mode-off--dark:
- hash: v1.k794b7964.a49ed133530106e5ac09e61c7b81f637d27bf874290732535ac8470df2272675.rj99mNBmRl8s1d9SjTkuSG7U41uBhcVkEmcZDA-1EvE
+ hash: v1.k794b7964.8a933f9d3d913d27c9306f54490eff93629b2ae2c5a42c3a08c2165a7db72b68.ghNnjSunZ43NsgdxzN6tQlPHLUl6OFRy-vLszghAd7s
scenes-app-notebooks-jupyter-mode--jupyter-mode-off--light:
- hash: v1.k794b7964.0e9f1961a3321cfad65b7389a8a8a84b89a02f814e88a9f84099f420a5fb72ab.IN_uRp_18l9sAsi36onpxwM-ZZZyXgq2CBwWNivCp_8
+ hash: v1.k794b7964.e5f3696e8d1b266d63a8be0d38b0becbd75c7eb6e478d31909da8d030f60695c.9if2KQS4f4KII2N3_eJtTeKPjgOdXnkOGEOq3wTkCMo
scenes-app-notebooks-kernel-info--free-compute--dark:
hash: v1.k794b7964.e8e81cc18d66dcca3d1cd23cc5017833b040abcaa4a3be85c6161787fed0efcd.OiaNuBz69zbpOxiLQsFYOQuJn_226577RmjJ_GbOdyQ
scenes-app-notebooks-kernel-info--free-compute--light:
diff --git a/frontend/src/lib/components/CompareFilter/CompareFilter.tsx b/frontend/src/lib/components/CompareFilter/CompareFilter.tsx
index 902473acd409..d82a18372956 100644
--- a/frontend/src/lib/components/CompareFilter/CompareFilter.tsx
+++ b/frontend/src/lib/components/CompareFilter/CompareFilter.tsx
@@ -1,7 +1,7 @@
import { useEffect, useState } from 'react'
import { IconClock } from '@posthog/icons'
-import { LemonSelect } from '@posthog/lemon-ui'
+import { LemonButtonProps, LemonSelect } from '@posthog/lemon-ui'
import { RollingDateRangeFilter } from 'lib/components/DateFilter/RollingDateRangeFilter'
import { useWindowSize } from 'lib/hooks/useWindowSize'
@@ -17,6 +17,7 @@ type CompareFilterProps = {
disableReason?: string | null
/** Shown on hover, e.g. the resolved comparison date range */
tooltip?: string | null
+ size?: LemonButtonProps['size']
}
export function CompareFilter({
@@ -26,6 +27,7 @@ export function CompareFilter({
disableReason,
tooltip,
allowCustomComparison = true,
+ size = 'small',
}: CompareFilterProps): JSX.Element | null {
// This keeps the state of the rolling date range filter, even when different drop down options are selected
// The default value for this is one month
@@ -89,7 +91,7 @@ export function CompareFilter({
return 'Compare to'
}
- const isHugeScreen = !isWindowLessThan('2xl')
+ const isHugeScreen = size !== 'xsmall' && !isWindowLessThan('2xl')
if (leaf.value === 'compareTo') {
return isHugeScreen
? `Compare to ${dateFromToText(tentativeCompareTo)} earlier`
@@ -114,7 +116,7 @@ export function CompareFilter({
}}
data-attr="compare-filter"
options={options.filter((option) => allowCustomComparison || option.value !== 'compareTo')}
- size="small"
+ size={size}
disabled={disabled}
disabledReason={disableReason}
tooltip={tooltip}
diff --git a/frontend/src/queries/nodes/DataNode/DateRange.tsx b/frontend/src/queries/nodes/DataNode/DateRange.tsx
index 1561c1b7b43c..ca9cfd65fb2e 100644
--- a/frontend/src/queries/nodes/DataNode/DateRange.tsx
+++ b/frontend/src/queries/nodes/DataNode/DateRange.tsx
@@ -1,4 +1,5 @@
import { DateFilter } from 'lib/components/DateFilter/DateFilter'
+import { LemonButtonProps } from 'lib/lemon-ui/LemonButton'
import {
EventsQuery,
@@ -20,13 +21,15 @@ interface DateRangeProps<
> {
query: Q
setQuery?: (query: Q) => void
+ size?: LemonButtonProps['size']
}
export function DateRange<
Q extends EventsQuery | HogQLQuery | SessionAttributionExplorerQuery | SessionsQuery | TracesQuery,
->({ query, setQuery }: DateRangeProps<Q>): JSX.Element | null {
+>({ query, setQuery, size }: DateRangeProps<Q>): JSX.Element | null {
if (isEventsQuery(query) || isSessionsQuery(query)) {
return (
<DateFilter
+ size={size}
dateFrom={query.after ?? undefined}
dateTo={query.before ?? undefined}
onChange={(changedDateFrom, changedDateTo) => {
@@ -46,6 +49,7 @@ export function DateRange<
if (isHogQLQuery(query) || isSessionAttributionExplorerQuery(query)) {
return (
<DateFilter
+ size={size}
dateFrom={query.filters?.dateRange?.date_from ?? undefined}
dateTo={query.filters?.dateRange?.date_to ?? undefined}
onChange={(changedDateFrom, changedDateTo) => {
@@ -69,6 +73,7 @@ export function DateRange<
if (isTracesQuery(query)) {
return (
<DateFilter
+ size={size}
dateFrom={query.dateRange?.date_from ?? undefined}
dateTo={query.dateRange?.date_to ?? undefined}
onChange={(changedDateFrom, changedDateTo) => {
diff --git a/frontend/src/queries/nodes/DataNode/Reload.tsx b/frontend/src/queries/nodes/DataNode/Reload.tsx
index 2536a0b13951..850e03b4002a 100644
--- a/frontend/src/queries/nodes/DataNode/Reload.tsx
+++ b/frontend/src/queries/nodes/DataNode/Reload.tsx
@@ -2,14 +2,14 @@ import { useActions, useValues } from 'kea'
import { IconRefresh } from '@posthog/icons'
-import { LemonButton } from 'lib/lemon-ui/LemonButton'
+import { LemonButton, LemonButtonProps } from 'lib/lemon-ui/LemonButton'
import { Spinner } from 'lib/lemon-ui/Spinner'
import { dataNodeCollectionLogic } from '~/queries/nodes/DataNode/dataNodeCollectionLogic'
import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'
import { shouldQueryBeAsync } from '~/queries/utils'
-export function Reload(): JSX.Element {
+export function Reload({ size = 'small' }: Pick<LemonButtonProps, 'size'>): JSX.Element {
const { responseLoading, query } = useValues(dataNodeLogic)
const { loadData, cancelQuery } = useActions(dataNodeLogic)
@@ -25,7 +25,7 @@ export function Reload(): JSX.Element {
}}
// Setting the loading icon manually to capture clicks while spinning.
icon={responseLoading ? <Spinner textColored /> : <IconRefresh />}
- size="small"
+ size={size}
>
{responseLoading ? 'Cancel' : 'Reload'}
</LemonButton>
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.test.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.test.tsx
index 1c0e19e9c7f8..2237a9bbe0db 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.test.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.test.tsx
@@ -2,9 +2,10 @@ import '@testing-library/jest-dom'
import { cleanup, configure, fireEvent, screen, waitFor } from '@testing-library/react'
-import { setupJsdom, setupSyncRaf } from '@posthog/quill-charts/testing'
+import { clickAtIndex, setupJsdom, setupSyncRaf } from '@posthog/quill-charts/testing'
-import { ChartSettings } from '~/queries/schema/schema-general'
+import { BIConfig } from '~/queries/schema/schema-business-intelligence'
+import { NodeKind, ChartSettings } from '~/queries/schema/schema-general'
import {
type DataVizFixture,
buildDataVisualizationQuery,
@@ -16,6 +17,8 @@ import {
} from '~/test/insight-testing'
import { ChartDisplayType } from '~/types'
+import { buildBIQuery } from 'products/business_intelligence/frontend/biEditorTypes'
+
// Neither timeout is set globally (jest.setup leaves asyncUtilTimeout at 1s, jest.config has no
// testTimeout → 5s): this heavy ~7-logic mount needs findBy* headroom beyond 1s on CI, and
// sqlChart.hoverTooltip's internal waits (findBy* + tooltip poll) can sum past the 5s default.
@@ -64,6 +67,65 @@ const renderBar = (
})
describe('SqlBarGraph', () => {
+ it.each([ChartDisplayType.ActionsBar, ChartDisplayType.ActionsStackedBar, ChartDisplayType.ActionsBarValue])(
+ 'opens the BI drilldown on the first click with multiple series in %s',
+ async (chartType) => {
+ const config: BIConfig = {
+ source: { table: 'events' },
+ rows: [
+ {
+ id: 'month',
+ name: 'month',
+ expression: 'timestamp',
+ type: 'datetime',
+ source: { table: 'events' },
+ dateBucket: 'month',
+ },
+ ],
+ columns: [],
+ values: [
+ {
+ field: { id: 'a', name: 'a', expression: 'a', type: 'integer', source: { table: 'events' } },
+ aggregation: 'sum',
+ },
+ {
+ field: { id: 'b', name: 'b', expression: 'b', type: 'integer', source: { table: 'events' } },
+ aggregation: 'sum',
+ },
+ ],
+ filters: [],
+ chartType,
+ limit: 100,
+ }
+ const node = buildBIQuery(config)!.node
+ renderDataVisualization({
+ query: {
+ ...node,
+ kind: NodeKind.BIVisualizationNode,
+ config,
+ chartSettings: {
+ xAxis: { column: 'toStartOfMonth(timestamp)' },
+ yAxis: [{ column: 'sum_a' }, { column: 'sum_b_2' }],
+ },
+ },
+ response: {
+ columns: ['toStartOfMonth(timestamp)', 'sum_a', 'sum_b_2'],
+ types: [
+ ['toStartOfMonth(timestamp)', 'DateTime'],
+ ['sum_a', 'UInt64'],
+ ['sum_b_2', 'UInt64'],
+ ],
+ results: MONTHS.map((month, index) => [month, (index + 1) * 100, (index + 1) * 10]),
+ },
+ })
+ const canvas = await screen.findByLabelText(/chart with 2 data series/i)
+ await clickAtIndex(canvas.parentElement!, HOVER, MONTHS.length)
+ expect(await screen.findByText('Explore this result')).toBeVisible()
+ expect(screen.getByText('View underlying rows')).toBeVisible()
+ expect(screen.getByText(/month: 202[56]-/)).toBeVisible()
+ }
+ )
+
describe('bar layouts', () => {
it.each([
{ name: 'grouped', display: ChartDisplayType.ActionsBar, extra: {} },
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.tsx
index 63b6857f7b37..510de810b78b 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.tsx
@@ -107,6 +107,7 @@ export const SqlBarGraph = (props: SqlChartProps): JSX.Element => {
}
onError={handleChartError}
>
+ {props.children}
{props.showAnnotations && props.insightNumericId && (
<AnnotationsLayer insightNumericId={props.insightNumericId} dates={model.labels} />
)}
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlChart.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlChart.tsx
index 5b0e67b9ac58..5a4c5361a8e4 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlChart.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlChart.tsx
@@ -1,3 +1,7 @@
+import type { ReactNode } from 'react'
+
+import type { XAxisConfig, ChartMargins } from '@posthog/quill-charts'
+
import { ChartSettings, GoalLine } from '~/queries/schema/schema-general'
import { ChartDisplayType } from '~/types'
@@ -35,6 +39,10 @@ export type SqlChartProps = {
* When provided, the SQL chart shows a "click to inspect" hint in the tooltip. */
onPointClick?: (seriesKey: string, dataIndex: number, label: string) => void
pointClickHint?: string
+ directPointClick?: boolean
+ xAxis?: XAxisConfig
+ margins?: Partial<ChartMargins>
+ children?: ReactNode
}
/**
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlComboGraph.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlComboGraph.tsx
index 2d076a8f709f..064a3abac521 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlComboGraph.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlComboGraph.tsx
@@ -56,6 +56,7 @@ export const SqlComboGraph = (props: SqlChartProps): JSX.Element => {
: undefined
}
>
+ {props.children}
{props.showAnnotations && props.insightNumericId && (
<AnnotationsLayer insightNumericId={props.insightNumericId} dates={model.labels} />
)}
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.tsx
index 06a20beb01b1..bb7dc94a7565 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.tsx
@@ -69,6 +69,7 @@ export const SqlLineGraph = (props: SqlChartProps): JSX.Element => {
onPointClick={onPointClickProp ? onPointClick : undefined}
onError={handleChartError}
>
+ {props.children}
{props.showAnnotations && props.insightNumericId && (
<AnnotationsLayer insightNumericId={props.insightNumericId} dates={model.labels} />
)}
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.ts
index 47170e669acb..9343d8ef4d45 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.ts
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.ts
@@ -1,7 +1,13 @@
import { useValues } from 'kea'
import { useEffect, useMemo } from 'react'
-import { type ChartTheme, type Series } from '@posthog/quill-charts'
+import {
+ type ChartTheme,
+ type Series,
+ type TooltipConfig,
+ type XAxisConfig,
+ type ChartMargins,
+} from '@posthog/quill-charts'
import { useChartTheme, useChartConfig } from 'lib/charts/hooks'
import { useChartLegendSeriesMenu } from 'lib/components/ChartLegendSeriesMenu/useChartLegendSeriesMenu'
@@ -26,8 +32,21 @@ export interface SqlChartModel<TConfig> {
config: TConfig
}
-export function useSqlChartModel<TConfig extends object>(
- { xData, yData, visualizationType, chartSettings, dashboardId, goalLines, embedded }: SqlChartProps,
+export function useSqlChartModel<
+ TConfig extends { tooltip?: TooltipConfig; xAxis?: XAxisConfig; margins?: Partial<ChartMargins> },
+>(
+ {
+ xData,
+ yData,
+ visualizationType,
+ chartSettings,
+ dashboardId,
+ goalLines,
+ embedded,
+ directPointClick,
+ xAxis,
+ margins,
+ }: SqlChartProps,
buildConfig: (args: BuildBarConfigArgs) => TConfig
): SqlChartModel<TConfig> | null {
const { timezone } = useValues(teamLogic)
@@ -49,34 +68,42 @@ export function useSqlChartModel<TConfig extends object>(
const legendRenderItem = useChartLegendSeriesMenu({ surface: 'sql', seriesCount: series.length })
- const config = useChartConfig(
- () =>
- xData
- ? buildConfig({
- xData,
- chartSettings,
- timezone,
- goalLines,
- visualizationType,
- ySeriesData,
- series,
- legendRenderItem,
- embedded,
- })
- : undefined,
- [
+ const config = useChartConfig(() => {
+ if (!xData) {
+ return undefined
+ }
+ const config = buildConfig({
xData,
chartSettings,
timezone,
goalLines,
visualizationType,
- buildConfig,
ySeriesData,
series,
legendRenderItem,
embedded,
- ]
- )
+ })
+ return {
+ ...config,
+ xAxis: { ...config.xAxis, ...xAxis },
+ margins: { ...config.margins, ...margins },
+ tooltip: { ...config.tooltip, resolveClickToNearestSeries: directPointClick },
+ }
+ }, [
+ xData,
+ chartSettings,
+ timezone,
+ goalLines,
+ visualizationType,
+ buildConfig,
+ ySeriesData,
+ series,
+ legendRenderItem,
+ embedded,
+ directPointClick,
+ xAxis,
+ margins,
+ ])
const labels = useMemo(
() =>
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/SideBar.tsx b/frontend/src/queries/nodes/DataVisualization/Components/SideBar.tsx
index 01a5f7a757b7..47c2e1c145cc 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/SideBar.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/SideBar.tsx
@@ -57,7 +57,7 @@ export const SideBar = (): JSX.Element => {
const activeTab = tabs.some((tab) => tab.key === activeSideBarTab) ? activeSideBarTab : SideBarTab.Series
return (
- <div className="bg-surface-primary w-[18rem] flex flex-col">
+ <div className="bg-surface-primary w-72 min-h-0 max-w-[50%] shrink-0 flex flex-col">
<LemonTabs
size="small"
activeKey={activeTab}
@@ -66,7 +66,7 @@ export const SideBar = (): JSX.Element => {
className="pt-1"
barClassName="px-3"
/>
- <div className="flex-1 overflow-y-auto">{TABS_TO_CONTENT[activeTab].content}</div>
+ <div className="min-h-0 flex-1 overflow-y-auto">{TABS_TO_CONTENT[activeTab].content}</div>
</div>
)
}
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/TableDisplay.tsx b/frontend/src/queries/nodes/DataVisualization/Components/TableDisplay.tsx
index f3ee22d1821c..ea1ccc9d878d 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/TableDisplay.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/TableDisplay.tsx
@@ -195,7 +195,7 @@ export function getTableDisplayOptions(
interface TableDisplayProps extends Pick<
LemonSelectProps<ChartDisplayType>,
- 'disabledReason' | 'fullWidth' | 'loading'
+ 'disabledReason' | 'fullWidth' | 'loading' | 'size'
> {
dataAttr?: string
disabledReasonFor?: (displayType: ChartDisplayType) => string | undefined
@@ -207,6 +207,7 @@ export const TableDisplay = ({
disabledReasonFor,
fullWidth,
loading,
+ size = 'small',
}: TableDisplayProps): JSX.Element => {
const { setVisualizationType } = useActions(dataVisualizationLogic)
const { autoVisualizationType, columns, numericalColumns, visualizationType } = useValues(dataVisualizationLogic)
@@ -229,7 +230,7 @@ export const TableDisplay = ({
!!featureFlags[FEATURE_FLAGS.METRIC_INSIGHT]
)}
renderButtonContent={() => renderDisplayTypeLabel(visualizationType, autoVisualizationType)}
- size="small"
+ size={size}
value={visualizationType}
data-attr={dataAttr}
/>
diff --git a/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx b/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
index 31d403b26466..8e320024f152 100644
--- a/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
@@ -1,7 +1,7 @@
import clsx from 'clsx'
import { BindLogic, BuiltLogic, LogicWrapper, useActions, useValues } from 'kea'
import { router } from 'kea-router'
-import { useCallback, useRef, useState } from 'react'
+import { useCallback, useMemo, useRef, useState } from 'react'
import { IconGear } from '@posthog/icons'
import { LemonBanner, LemonButton, LemonDivider } from '@posthog/lemon-ui'
@@ -12,6 +12,7 @@ import { useAttachedLogic } from 'lib/logic/scenes/useAttachedLogic'
import { InsightErrorState, StatelessInsightLoadingState } from 'scenes/insights/EmptyStates'
import { insightDataLogic } from 'scenes/insights/insightDataLogic'
import { insightLogic } from 'scenes/insights/insightLogic'
+import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
import { insightVizDataCollectionId, insightVizDataNodeKey } from '~/queries/nodes/InsightViz/insightVizKeys'
@@ -29,10 +30,13 @@ import { shouldQueryBeAsync } from '~/queries/utils'
import { ChartDisplayType, ExportContext, ExporterFormat, InsightLogicProps } from '~/types'
import { alertsToThresholdGoalLines, insightAlertsLogic } from 'products/alerts/frontend/logic/insightAlertsLogic'
+import { getBIChartDateAxis } from 'products/business_intelligence/frontend/biChartDateAxis'
+import { BIChartYearLabels } from 'products/business_intelligence/frontend/BIChartYearLabels'
import { BIComparisonSummary } from 'products/business_intelligence/frontend/BIComparisonSummary'
import { getBIChartRecord } from 'products/business_intelligence/frontend/biDrilldown'
import { biDrilldownLogic } from 'products/business_intelligence/frontend/biDrilldownLogic'
import { BIDrilldownModal } from 'products/business_intelligence/frontend/BIDrilldownModal'
+import { getBIResultDimensions } from 'products/business_intelligence/frontend/biEditorTypes'
import { BIPivotTable } from 'products/business_intelligence/frontend/BIPivotTable'
import { getBIVisualizationSource } from 'products/business_intelligence/frontend/biQueryResults'
import { HogQLBoldNumber } from 'products/product_analytics/frontend/insights/shared/BoldNumber/BoldNumber'
@@ -250,6 +254,28 @@ function InternalDataTableVisualization(props: DataTableVisualizationProps): JSX
[props.setQuery, props.query] // oxlint-disable-line react-hooks/exhaustive-deps
)
+ const { timezone } = useValues(teamLogic)
+ const dateBucket =
+ query.kind === NodeKind.BIVisualizationNode
+ ? getBIResultDimensions(query.config).find(({ column }) => column === xData?.column.name)?.field.dateBucket
+ : undefined
+ const showYearLabels =
+ query.kind === NodeKind.BIVisualizationNode &&
+ (xData?.column.type.name === 'DATE' || xData?.column.type.name === 'DATETIME') &&
+ dateBucket !== 'year' &&
+ effectiveVisualizationType !== ChartDisplayType.ActionsBarValue &&
+ chartSettings.showXAxisTicks !== false
+ const dateAxis = useMemo(
+ () => (showYearLabels && xData ? getBIChartDateAxis(xData.data, timezone, dateBucket) : undefined),
+ [showYearLabels, xData, timezone, dateBucket]
+ )
+ const dateMargins = useMemo(
+ () => (showYearLabels ? { bottom: chartSettings.xAxisLabel ? 76 : 54 } : undefined),
+ [showYearLabels, chartSettings.xAxisLabel]
+ )
+
+ const controlSize = query.kind === NodeKind.BIVisualizationNode ? 'xsmall' : 'small'
+
const isDateXAxis = xData?.column.type.name === 'DATE' || xData?.column.type.name === 'DATETIME'
let component: JSX.Element | null = null
@@ -329,6 +355,9 @@ function InternalDataTableVisualization(props: DataTableVisualizationProps): JSX
showAnnotations={!props.inSharedMode && isDateXAxis && chartSettings.showAnnotations === true}
presetChartHeight={presetChartHeight}
embedded={props.embedded}
+ directPointClick={canDrill}
+ xAxis={dateAxis}
+ margins={dateMargins}
onPointClick={
canDrill
? (seriesKey, dataIndex) => {
@@ -348,8 +377,10 @@ function InternalDataTableVisualization(props: DataTableVisualizationProps): JSX
}
: undefined
}
- pointClickHint={canDrill ? 'Click a series to explore this result' : undefined}
- />
+ pointClickHint={canDrill ? 'Click to explore this result' : undefined}
+ >
+ {showYearLabels && <BIChartYearLabels timezone={timezone} />}
+ </SqlChart>
</BindLogic>
)
} else if (PART_OF_WHOLE_DISPLAY_TYPES.includes(effectiveVisualizationType)) {
@@ -443,73 +474,74 @@ function InternalDataTableVisualization(props: DataTableVisualizationProps): JSX
return (
<div
- className={clsx('DataVisualization flex flex-1 gap-2', {
+ className={clsx('DataVisualization flex min-h-0 min-w-0 flex-1 gap-2', {
'h-full': effectiveVisualizationType !== ChartDisplayType.ActionsTable,
})}
>
- <div className="relative w-full flex flex-col gap-4 flex-1 overflow-hidden">
+ <div className="relative min-h-0 min-w-0 w-full flex flex-col gap-2 flex-1 overflow-hidden">
{!readOnly && showResultControls && (
<>
<LemonDivider className="my-0" />
- <div className="flex gap-4 justify-between flex-wrap px-px">
- <div className="flex gap-4 items-center">
- <Reload />
+ <div className="flex items-center gap-2 flex-wrap px-2">
+ <div className="flex gap-2 items-center">
+ <Reload size={controlSize} />
<ElapsedTime />
</div>
- <div className="flex gap-4 items-center">
- <div className="flex gap-4 items-center flex-wrap">
- <AddVariableButton />
-
- {sourceFeatures.has(QueryFeature.dateRangePicker) &&
- !router.values.location.pathname.includes(urls.sqlEditor()) && ( // decouple this component from insights tab and datawarehouse scene
- <DateRange
- key="date-range"
- query={query.source}
- setQuery={(query) => {
- if (query.kind === NodeKind.HogQLQuery) {
- setQuerySource(query)
- }
- }}
- />
- )}
-
- <TableDisplay />
-
- <LemonButton
- icon={<IconGear />}
- type={isChartSettingsPanelOpen ? 'primary' : 'secondary'}
- onClick={() => toggleChartSettingsPanel()}
- tooltip="Visualization settings"
+ <AddVariableButton buttonProps={{ size: controlSize }} />
+
+ {sourceFeatures.has(QueryFeature.dateRangePicker) &&
+ !router.values.location.pathname.includes(urls.sqlEditor()) && ( // decouple this component from insights tab and datawarehouse scene
+ <DateRange
+ key="date-range"
+ size={controlSize}
+ query={query.source}
+ setQuery={(query) => {
+ if (query.kind === NodeKind.HogQLQuery) {
+ setQuerySource(query)
+ }
+ }}
/>
+ )}
- {props.exportContext && (
- <ExportButton
- disabledReason={
- effectiveVisualizationType !== ChartDisplayType.ActionsTable &&
- 'Only table results are exportable'
- }
- type="secondary"
- items={[
- {
- export_format: ExporterFormat.CSV,
- export_context: props.exportContext,
- },
- {
- export_format: ExporterFormat.XLSX,
- export_context: props.exportContext,
- },
- ]}
- />
- )}
- </div>
+ <div className={props.context?.chartTypeSelectorClassName}>
+ <TableDisplay size={controlSize} />
</div>
+
+ <LemonButton
+ size={controlSize}
+ icon={<IconGear />}
+ type={isChartSettingsPanelOpen ? 'primary' : 'secondary'}
+ onClick={() => toggleChartSettingsPanel()}
+ tooltip="Visualization settings"
+ />
+
+ {props.exportContext && (
+ <ExportButton
+ size={controlSize}
+ disabledReason={
+ effectiveVisualizationType !== ChartDisplayType.ActionsTable &&
+ 'Only table results are exportable'
+ }
+ type="secondary"
+ items={[
+ {
+ export_format: ExporterFormat.CSV,
+ export_context: props.exportContext,
+ },
+ {
+ export_format: ExporterFormat.XLSX,
+ export_context: props.exportContext,
+ },
+ ]}
+ />
+ )}
</div>
</>
)}
{!props.embedded && <VariablesForInsight />}
- <div className="flex flex-1 flex-row gap-4">
+ <div className="flex min-h-0 min-w-0 flex-1 flex-row gap-2">
{/* The gear above toggles this panel (Series/Display tabs) — same layout the
SQL editor's OutputPane builds around its own visualization fork. */}
{!readOnly && showResultControls && isChartSettingsPanelOpen && (
@@ -518,7 +550,7 @@ function InternalDataTableVisualization(props: DataTableVisualizationProps): JSX
<LemonDivider vertical className="h-full" />
</>
)}
- <div className="w-full h-full flex-1 overflow-auto">{component}</div>
+ <div className="min-h-0 min-w-0 w-full h-full flex-1 overflow-auto pb-3">{component}</div>
</div>
</div>
</div>
diff --git a/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.ts b/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.ts
index ce3d85295738..b7b1856d503d 100644
--- a/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.ts
+++ b/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.ts
@@ -1455,7 +1455,8 @@ export const dataVisualizationLogic = kea<dataVisualizationLogicType>([
(key: string, dashboardId, activeSceneId: string | null) => {
// Keys for SQL editor visualizations can render outside the SQLEditor scene,
// e.g. in embedded mode, so key matching keeps sizing consistent.
- const sqlEditorVisualization =
+ const editorVisualization =
+ activeSceneId === Scene.BusinessIntelligence ||
activeSceneId === Scene.SQLEditor ||
key.includes('SQLEditor') ||
key.startsWith('data-warehouse-editor-data-node-')
@@ -1464,7 +1465,7 @@ export const dataVisualizationLogic = kea<dataVisualizationLogicType>([
return true
}
- return !key.includes('new-SQL') && !dashboardId && !sqlEditorVisualization
+ return !key.includes('new-SQL') && !dashboardId && !editorVisualization
},
],
sourceFeatures: [
diff --git a/frontend/src/queries/types.ts b/frontend/src/queries/types.ts
index 87676e1b2099..fbec3be99759 100644
--- a/frontend/src/queries/types.ts
+++ b/frontend/src/queries/types.ts
@@ -105,6 +105,8 @@ export interface QueryContext<Q extends QuerySchema = QuerySchema> {
includeHiddenEvents?: boolean
/** Drop axis ticks and titles, for thumbnail-sized renders such as the chart type gallery. */
hideAxes?: boolean
+ /** Hide or resize the visualization selector when the host provides its own chart picker. */
+ chartTypeSelectorClassName?: string
}
export type QueryContextColumnTitleComponent = ComponentType<{
diff --git a/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.test.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.test.tsx
index ea362387d142..748f75f0d43a 100644
--- a/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.test.tsx
+++ b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.test.tsx
@@ -22,6 +22,21 @@ describe('TimeSeriesComboChart', () => {
expect(chart.yTicks().length).toBeGreaterThan(0)
})
+ it('reserves the requested bottom margin for axis overlays', () => {
+ let bottomMargin: number | undefined
+ function Measure(): null {
+ const { dimensions } = useChartLayout()
+ bottomMargin = dimensions.height - dimensions.plotTop - dimensions.plotHeight
+ return null
+ }
+ renderHogChart(
+ <TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} config={{ margins: { bottom: 76 } }}>
+ <Measure />
+ </TimeSeriesComboChart>
+ )
+ expect(bottomMargin).toBe(76)
+ })
+
describe('config.xAxis', () => {
it('hides x-axis ticks when xAxis.hide is true', () => {
const { chart } = renderHogChart(
diff --git a/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.tsx
index fb9af736baec..ea92e1a0b066 100644
--- a/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.tsx
+++ b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.tsx
@@ -23,6 +23,8 @@ import { useGoalLines, useTimeSeries } from '../utils/use-time-series'
import type { ValueLabelsConfig } from '../utils/use-value-labels'
export interface TimeSeriesComboChartConfig {
+ /** Reserve space for custom overlays; unspecified sides keep their computed margins. */
+ margins?: ComboChartConfig['margins']
xAxis?: XAxisConfig
/** Single object for a standard left axis; array for dual left+right axes. */
yAxis?: YAxisConfig | YAxisConfig[]
@@ -88,6 +90,7 @@ export function TimeSeriesComboChart<Meta = unknown>({
const {
xAxis,
yAxis,
+ margins,
valueLabels,
goalLines,
defaultSeriesType,
@@ -121,6 +124,7 @@ export function TimeSeriesComboChart<Meta = unknown>({
const trendSeries = useTrendLineSeries(visibleSeries, trendLines)
const comboChartConfig: ComboChartConfig = {
+ margins,
yScaleType: primaryYAxis?.scale,
xTickFormatter,
xTickLabelRotation: xAxis?.tickLabelRotation,
diff --git a/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.test.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.test.tsx
index 0b70c0ca986f..3cfd844862b6 100644
--- a/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.test.tsx
+++ b/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.test.tsx
@@ -38,6 +38,21 @@ describe('TimeSeriesLineChart', () => {
cleanup()
})
+ it('reserves the requested bottom margin for axis overlays', () => {
+ let bottomMargin: number | undefined
+ function Measure(): null {
+ const { dimensions } = useChartLayout()
+ bottomMargin = dimensions.height - dimensions.plotTop - dimensions.plotHeight
+ return null
+ }
+ renderHogChart(
+ <TimeSeriesLineChart series={SERIES} labels={LABELS} theme={THEME} config={{ margins: { bottom: 76 } }}>
+ <Measure />
+ </TimeSeriesLineChart>
+ )
+ expect(bottomMargin).toBe(76)
+ })
+
describe('config.xAxis', () => {
it('hides x-axis ticks when xAxis.hide is true', () => {
const { chart } = renderHogChart(
diff --git a/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.tsx
index 84704e1b3497..0d8727982160 100644
--- a/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.tsx
+++ b/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.tsx
@@ -29,6 +29,8 @@ import type { ValueLabelsConfig } from '../utils/use-value-labels'
export type { ConfidenceIntervalConfig, MovingAverageConfig, TrendLineConfig }
export interface TimeSeriesLineChartConfig {
+ /** Reserve space for custom overlays; unspecified sides keep their computed margins. */
+ margins?: LineChartConfig['margins']
xAxis?: XAxisConfig
/** Single object = one y-axis (today's behavior). Array = one entry per axis for dual y-axis
* charts: set `id` (matches `Series.yAxisId`; first entry defaults to `'left'`) and `position`
@@ -95,6 +97,7 @@ export function TimeSeriesLineChart<Meta = unknown>({
const {
xAxis,
yAxis,
+ margins,
valueLabels,
goalLines,
confidenceIntervals,
@@ -140,6 +143,7 @@ export function TimeSeriesLineChart<Meta = unknown>({
const floatBaseline = primaryYAxis?.startAtZero === false && primaryYAxis?.scale !== 'log'
const lineChartConfig: LineChartConfig = {
+ margins,
yScaleType: primaryYAxis?.scale,
xTickFormatter,
xTickLabelRotation: xAxis?.tickLabelRotation,
diff --git a/packages/quill/packages/charts/src/docs/axes.md b/packages/quill/packages/charts/src/docs/axes.md
index 5e9e1c24413a..7c0104ec2efd 100644
--- a/packages/quill/packages/charts/src/docs/axes.md
+++ b/packages/quill/packages/charts/src/docs/axes.md
@@ -63,7 +63,7 @@ A single object stays single-axis.
- Charts fill their container and need a parent with real dimensions. A zero-height flex child renders nothing. Give the wrapper an explicit height (`h-64`, or `flex-1` in a sized column). `Sparkline` alone takes `height` and `width` props.
- A wrapper that measures under one pixel wide or high does not resize the chart. `useChartCanvas` keeps the last painted frame and waits for the next real size, so a chart whose container collapses for a moment (an ancestor set to `display: none`, Chromium capturing a screenshot taller than the viewport) does not go blank or lay out again.
-- `ChartConfig.margins` overrides only the sides it sets. A side left `undefined` keeps the computed margin, so an object built conditionally (`{ top: reserveOrUndefined }`) is safe. `SlopeChart` merges consumer margins over its computed label gutters with the same rule (`applyMarginOverride`). Pass a module-level constant.
+- `ChartConfig.margins` (also available on all `TimeSeries*` configs) overrides only the sides it sets. A side left `undefined` keeps the computed margin, so an object built conditionally (`{ top: reserveOrUndefined }`) is safe. `SlopeChart` merges consumer margins over its computed label gutters with the same rule (`applyMarginOverride`). Pass a module-level constant.
## When the plot is blank
diff --git a/products/business_intelligence/frontend/BIChartYearLabels.stories.tsx b/products/business_intelligence/frontend/BIChartYearLabels.stories.tsx
new file mode 100644
index 000000000000..a08be1b3860a
--- /dev/null
+++ b/products/business_intelligence/frontend/BIChartYearLabels.stories.tsx
@@ -0,0 +1,86 @@
+import { Meta, StoryObj } from '@storybook/react'
+
+import { DataTableVisualization } from '~/queries/nodes/DataVisualization/DataVisualization'
+import { BIConfig } from '~/queries/schema/schema-business-intelligence'
+import { NodeKind } from '~/queries/schema/schema-general'
+import { ChartDisplayType } from '~/types'
+
+import { buildBIQuery } from './biEditorTypes'
+
+const config: BIConfig = {
+ source: { table: 'events' },
+ rows: [
+ {
+ id: 'timestamp',
+ name: 'timestamp',
+ expression: 'timestamp',
+ type: 'datetime',
+ source: { table: 'events' },
+ dateBucket: 'month',
+ },
+ ],
+ columns: [],
+ values: [
+ {
+ field: {
+ id: 'revenue',
+ name: 'revenue',
+ expression: 'revenue',
+ type: 'float',
+ source: { table: 'events' },
+ },
+ aggregation: 'sum',
+ },
+ ],
+ filters: [],
+ chartType: ChartDisplayType.ActionsBar,
+ limit: 100,
+}
+const dates = [
+ '2025-10-01',
+ '2025-11-01',
+ '2025-12-01',
+ '2026-01-01',
+ '2026-02-01',
+ '2026-03-01',
+ '2026-04-01',
+ '2026-05-01',
+ '2026-06-01',
+ '2026-07-01',
+ '2026-08-01',
+ '2026-09-01',
+]
+const meta: Meta = {
+ title: 'Products/Business intelligence/Chart years',
+ parameters: { layout: 'centered', mockDate: '2026-10-01' },
+}
+export default meta
+
+export const PartialYears: StoryObj = {
+ render: () => (
+ <div className="flex h-96 w-[48rem] flex-col">
+ <DataTableVisualization
+ query={{
+ ...buildBIQuery(config)!.node,
+ kind: NodeKind.BIVisualizationNode,
+ config,
+ chartSettings: {
+ xAxis: { column: 'toStartOfMonth(timestamp)' },
+ yAxis: [{ column: 'sum_revenue' }],
+ },
+ }}
+ setQuery={() => {}}
+ cachedResults={{
+ columns: ['toStartOfMonth(timestamp)', 'sum_revenue'],
+ types: [
+ ['toStartOfMonth(timestamp)', 'DateTime'],
+ ['sum_revenue', 'Float64'],
+ ],
+ results: dates.map((date, index) => [date, 100 + (index % 4) * 50]),
+ }}
+ context={{ insightProps: { dashboardItemId: 'new-SQL-bi-years' } }}
+ readOnly
+ />
+ </div>
+ ),
+}
diff --git a/products/business_intelligence/frontend/BIChartYearLabels.tsx b/products/business_intelligence/frontend/BIChartYearLabels.tsx
new file mode 100644
index 000000000000..258afdde9072
--- /dev/null
+++ b/products/business_intelligence/frontend/BIChartYearLabels.tsx
@@ -0,0 +1,35 @@
+import { useChartLayout } from '@posthog/quill-charts'
+
+import { getBIChartYearGroups } from './biChartDateAxis'
+
+export function BIChartYearLabels({ timezone }: { timezone: string }): JSX.Element {
+ const { labels, scales, dimensions, theme } = useChartLayout()
+ const groups = getBIChartYearGroups(labels, timezone)
+ return (
+ <div className="pointer-events-none" aria-label="Years">
+ {groups.map(({ year, first, last }, index) => {
+ const start = scales.x(first)
+ const end = scales.x(last)
+ if (start === undefined || end === undefined) {
+ return null
+ }
+ return (
+ <span
+ key={`${year}-${index}`}
+ data-attr="bi-chart-year"
+ className="absolute -translate-x-1/2 text-xs whitespace-nowrap"
+ // The year spans chart coordinates, which change with the plot's measured size.
+ // eslint-disable-next-line react/forbid-dom-props
+ style={{
+ left: (start + end) / 2,
+ top: dimensions.plotTop + dimensions.plotHeight + 28,
+ color: theme.axisColor,
+ }}
+ >
+ {year}
+ </span>
+ )
+ })}
+ </div>
+ )
+}
diff --git a/products/business_intelligence/frontend/BIDataSourcePicker.tsx b/products/business_intelligence/frontend/BIDataSourcePicker.tsx
index 3a510696c852..f2b091d1f565 100644
--- a/products/business_intelligence/frontend/BIDataSourcePicker.tsx
+++ b/products/business_intelligence/frontend/BIDataSourcePicker.tsx
@@ -80,7 +80,7 @@ export function BIDataSourcePicker(): JSX.Element {
>
<LemonButton
type="secondary"
- size="small"
+ size="xsmall"
fullWidth
icon={<IconDatabase />}
sideIcon={<IconChevronDown />}
diff --git a/products/business_intelligence/frontend/BIEditor.tsx b/products/business_intelligence/frontend/BIEditor.tsx
index c8223d9b6b30..1222832da196 100644
--- a/products/business_intelligence/frontend/BIEditor.tsx
+++ b/products/business_intelligence/frontend/BIEditor.tsx
@@ -12,12 +12,12 @@ import {
parseBIShelfPillDragData,
} from 'products/business_intelligence/frontend/biEditorTypes'
import { BIFilterControl } from 'products/business_intelligence/frontend/BIFilterControl'
+import { BIChartTypes } from 'products/business_intelligence/frontend/components/BIChartTypes'
import { BIDataPane } from 'products/business_intelligence/frontend/components/BIDataPane'
import { BIFieldPill } from 'products/business_intelligence/frontend/components/BIFieldPill'
import { BIFiltersCard } from 'products/business_intelligence/frontend/components/BIFiltersCard'
import { BIMarksCard } from 'products/business_intelligence/frontend/components/BIMarksCard'
import { BIShelfStrip } from 'products/business_intelligence/frontend/components/BIShelfStrip'
-import { BIShowMe } from 'products/business_intelligence/frontend/components/BIShowMe'
import { BIToolbar } from 'products/business_intelligence/frontend/components/BIToolbar'
import { BIAnalysisControls } from './BIAnalysisControls'
@@ -30,7 +30,7 @@ import { BIResultFiltersCard } from './components/BIResultFiltersCard'
* shelves above the view, and a chart picker on the right.
*/
export function BIEditor({ tabId, children }: { tabId: string; children: ReactNode }): JSX.Element {
- const { config, showMeOpen, dragSessionId } = useValues(biEditorLogic({ tabId }))
+ const { config, chartTypesOpen, dragSessionId } = useValues(biEditorLogic({ tabId }))
const { removeFieldFromShelf, setActiveDropShelf } = useActions(biEditorLogic({ tabId }))
const containerRef = useRef<HTMLDivElement>(null)
const cardsRef = useRef<HTMLDivElement>(null)
@@ -130,7 +130,7 @@ export function BIEditor({ tabId, children }: { tabId: string; children: ReactNo
</BIShelfStrip>
<div className="flex min-h-0 flex-1 flex-col">{children}</div>
</div>
- {showMeOpen || config.filters.length > 0 ? (
+ {chartTypesOpen || config.filters.length > 0 ? (
<div className="hidden w-44 shrink-0 flex-col overflow-y-auto border-l bg-surface-primary @3xl/bi-editor:flex @6xl/bi-editor:w-80">
{config.filters.length > 0 && (
<section className="border-b p-2" aria-label="Quick filters">
@@ -142,7 +142,7 @@ export function BIEditor({ tabId, children }: { tabId: string; children: ReactNo
</div>
</section>
)}
- {showMeOpen && <BIShowMe docked />}
+ {chartTypesOpen && <BIChartTypes docked />}
</div>
) : null}
</div>
diff --git a/products/business_intelligence/frontend/BusinessIntelligenceScene.tsx b/products/business_intelligence/frontend/BusinessIntelligenceScene.tsx
index 591858348aff..cf1c19238806 100644
--- a/products/business_intelligence/frontend/BusinessIntelligenceScene.tsx
+++ b/products/business_intelligence/frontend/BusinessIntelligenceScene.tsx
@@ -17,6 +17,7 @@ import { isDataVisualizationNode } from '~/queries/utils'
import { AccessControlLevel, AccessControlResourceType } from '~/types'
import { BIEditor } from './BIEditor'
+import { biEditorLogic } from './biEditorLogic'
import { biSceneLogic } from './biSceneLogic'
export const scene: SceneExport = {
@@ -29,6 +30,7 @@ export const scene: SceneExport = {
export function BusinessIntelligenceScene({ tabId = 'bi-default' }: { tabId?: string }): JSX.Element {
const { featureFlags } = useValues(featureFlagLogic)
+ const { chartTypesOpen } = useValues(biEditorLogic({ tabId }))
const logic = biSceneLogic({ tabId })
const {
name,
@@ -170,6 +172,7 @@ export function BusinessIntelligenceScene({ tabId = 'bi-default' }: { tabId?: st
context={{
insightProps: { dashboardItemId: `new-bi-${tabId}` },
showOpenEditorButton: false,
+ chartTypeSelectorClassName: chartTypesOpen ? '@3xl/bi-editor:hidden' : undefined,
}}
/>
) : (
diff --git a/products/business_intelligence/frontend/biChartDateAxis.test.ts b/products/business_intelligence/frontend/biChartDateAxis.test.ts
new file mode 100644
index 000000000000..40c46107cf2a
--- /dev/null
+++ b/products/business_intelligence/frontend/biChartDateAxis.test.ts
@@ -0,0 +1,21 @@
+import { getBIChartDateAxis, getBIChartYearGroups } from './biChartDateAxis'
+
+describe('BI date axis', () => {
+ it.each([
+ ['America/Los_Angeles', ['2025-12-01', '2026-01-01'], [2025, 2026]],
+ ['UTC', ['2025-10-01', '2026-01-01', '2026-04-01'], [2025, 2026]],
+ ['America/Los_Angeles', ['2025-12-31T23:00:00Z', '2026-01-01T09:00:00Z'], [2025, 2026]],
+ ['UTC', ['2026-04-01', '2026-01-01', '2025-10-01'], [2026, 2025]],
+ ])('groups every visible year in %s, including partial years', (timezone, labels, years) => {
+ const groups = getBIChartYearGroups(labels, timezone)
+ expect(groups.map((group) => group.year)).toEqual(years)
+ expect(groups[0].first).toBe(labels[0])
+ expect(groups[groups.length - 1].last).toBe(labels[labels.length - 1])
+ })
+
+ it('keeps January among the month ticks when years have their own row', () => {
+ const labels = ['2025-10-01', '2026-01-01', '2026-04-01']
+ const { tickFormatter } = getBIChartDateAxis(labels, 'UTC', 'month')
+ expect(labels.map((label, index) => tickFormatter?.(label, index))).toEqual(['October', 'January', 'April'])
+ })
+})
diff --git a/products/business_intelligence/frontend/biChartDateAxis.ts b/products/business_intelligence/frontend/biChartDateAxis.ts
new file mode 100644
index 000000000000..0c38ea2e8002
--- /dev/null
+++ b/products/business_intelligence/frontend/biChartDateAxis.ts
@@ -0,0 +1,46 @@
+import { createXAxisTickCallback, type XAxisConfig } from '@posthog/quill-charts'
+
+import { dayjs } from 'lib/dayjs'
+
+import { BIDateBucket } from '~/queries/schema/schema-business-intelligence'
+
+function parseChartDate(label: string, timezone: string): ReturnType<typeof dayjs> {
+ return /^\d{4}-\d{2}-\d{2}$/.test(label) ? dayjs.tz(label, timezone) : dayjs(label).tz(timezone)
+}
+
+export function getBIChartDateAxis(labels: string[], timezone: string, interval?: BIDateBucket): XAxisConfig {
+ const formatter = createXAxisTickCallback({ allDays: labels, timezone, interval })
+ const indices = new Map(labels.map((label, index) => [label, index]))
+ return {
+ tickFormatter: (label) => {
+ const text = formatter ? formatter(label, indices.get(label) ?? 0) : label
+ if (text && /^\d{4}$/.test(text)) {
+ return parseChartDate(label, timezone).format(
+ interval === 'quarter' ? '[Q]Q' : interval === 'month' ? 'MMMM' : 'MMM D'
+ )
+ }
+ return text
+ },
+ }
+}
+
+export function getBIChartYearGroups(
+ labels: string[],
+ timezone: string
+): { year: number; first: string; last: string }[] {
+ const groups: { year: number; first: string; last: string }[] = []
+ for (const label of labels) {
+ const date = parseChartDate(label, timezone)
+ if (!date.isValid()) {
+ continue
+ }
+ const year = date.year()
+ const previous = groups[groups.length - 1]
+ if (previous?.year === year) {
+ previous.last = label
+ } else {
+ groups.push({ year, first: label, last: label })
+ }
+ }
+ return groups
+}
diff --git a/products/business_intelligence/frontend/biEditorLogic.ts b/products/business_intelligence/frontend/biEditorLogic.ts
index e366d526c40a..e49d9d829a16 100644
--- a/products/business_intelligence/frontend/biEditorLogic.ts
+++ b/products/business_intelligence/frontend/biEditorLogic.ts
@@ -299,6 +299,7 @@ export interface biEditorLogicValues {
availableDataSources: BIDataSource[]
calculatedMeasureDraft: BICalculatedMeasureDraft | null
chartFits: Partial<Record<ChartDisplayType, BIChartFit>>
+ chartTypesOpen: boolean
config: BIConfig
dataPaneFields: BIDataPaneFields
dataPaneFieldsError: boolean
@@ -421,6 +422,9 @@ export interface biEditorLogicActions {
setChartType: (chartType: ChartDisplayType) => {
chartType: ChartDisplayType
}
+ setChartTypesOpen: (chartTypesOpen: boolean) => {
+ chartTypesOpen: boolean
+ }
setCompareFilter: (compareFilter: CompareFilter) => {
compareFilter: CompareFilter
}
@@ -497,9 +501,6 @@ export interface biEditorLogicActions {
setMissingDates: (missingDates: BIConfig['missingDates']) => {
missingDates: 'gap' | 'zero' | undefined
}
- setShowMeOpen: (showMeOpen: boolean) => {
- showMeOpen: boolean
- }
setSort: (sort: BISort | null) => {
sort: BISort | null
}
@@ -567,6 +568,7 @@ export interface biEditorLogicActions {
export interface biEditorLogicMeta {
key: string
__keaTypeGenInternalSelectorTypes: {
+ chartTypesOpen: (showMeOpen: boolean) => boolean
availableDataSources: (
allTables: DatabaseSchemaTable[],
posthogTables: DatabaseSchemaTable[],
@@ -645,7 +647,7 @@ export const biEditorLogic = kea<biEditorLogicType>([
}),
swapRowsAndColumns: true,
setAutoUpdate: (autoUpdate: boolean) => ({ autoUpdate }),
- setShowMeOpen: (showMeOpen: boolean) => ({ showMeOpen }),
+ setChartTypesOpen: (chartTypesOpen: boolean) => ({ chartTypesOpen }),
setHoveredChartType: (chartType: ChartDisplayType | null) => ({ chartType }),
setDataPaneSearch: (search: string) => ({ search }),
runAfterChange: true,
@@ -721,10 +723,11 @@ export const biEditorLogic = kea<biEditorLogicType>([
},
],
autoUpdate: [false, { persist: true }, { setAutoUpdate: (_, { autoUpdate }) => autoUpdate }],
- showMeOpen: [true, { persist: true }, { setShowMeOpen: (_, { showMeOpen }) => showMeOpen }],
+ // Pinned storage key: preserve the saved chart picker preference.
+ showMeOpen: [true, { persist: true }, { setChartTypesOpen: (_, { chartTypesOpen }) => chartTypesOpen }],
hoveredChartType: [
null as ChartDisplayType | null,
- { setHoveredChartType: (_, { chartType }) => chartType, setShowMeOpen: () => null },
+ { setHoveredChartType: (_, { chartType }) => chartType, setChartTypesOpen: () => null },
],
activeExpressionEditorTarget: [
'field' as 'field' | 'aggregation',
@@ -909,6 +912,7 @@ export const biEditorLogic = kea<biEditorLogicType>([
],
})),
selectors({
+ chartTypesOpen: [(s) => [s.showMeOpen], (open: boolean): boolean => open],
availableDataSources: [
(selectors) => [selectors.allTables, selectors.posthogTables, selectors.databaseConnectionId],
(
diff --git a/products/business_intelligence/frontend/biEditorTypes.test.ts b/products/business_intelligence/frontend/biEditorTypes.test.ts
index c80262776efb..98b98fce1b71 100644
--- a/products/business_intelligence/frontend/biEditorTypes.test.ts
+++ b/products/business_intelligence/frontend/biEditorTypes.test.ts
@@ -93,7 +93,7 @@ describe('BI editor query generation', () => {
expect(result.query).toContain('toStartOfDay({filters.compareDate(timestamp)}) AS bi_row_timestamp')
expect(result.query).toContain('{filters.previous}')
expect(result.query).toContain("'Current period', bi_row_timestamp, NULL")
- expect(result.query).toContain('ORDER BY bi_comparison_sort DESC, bi_row_timestamp ASC')
+ expect(result.query).toContain('ORDER BY bi_comparison_sort ASC, bi_row_timestamp ASC')
expect(result.node.chartSettings?.seriesBreakdownColumn).toBe('bi_comparison')
expect(parseBIEditorState(BIEditorView.BI, config)?.config.compareFilter).toEqual(config.compareFilter)
expect(
@@ -692,10 +692,15 @@ describe('BI editor query generation', () => {
expect(buildBIQuery({ ...sortableConfig, sort })?.query).toContain(expectedClause)
})
- it('auto-sorts date dimensions newest first', () => {
- const result = buildBIQuery({ ...sortableConfig, rows: [{ ...timestampField, dateBucket: 'day' }] })
+ it.each(['rows', 'columns'] as const)('auto-sorts date dimensions on %s chronologically', (shelf) => {
+ const result = buildBIQuery({
+ ...sortableConfig,
+ rows: shelf === 'columns' ? [browserField] : [],
+ columns: [],
+ [shelf]: [{ ...timestampField, dateBucket: 'day' }],
+ })
- expect(result?.query).toContain('ORDER BY\n toStartOfDay(timestamp) DESC')
+ expect(result?.query).toContain('ORDER BY\n toStartOfDay(timestamp) ASC')
})
it('offers dimensions and values as sort options, and a count fallback without values', () => {
diff --git a/products/business_intelligence/frontend/biEditorTypes.ts b/products/business_intelligence/frontend/biEditorTypes.ts
index c99cf3b7141e..ae3cd0a31219 100644
--- a/products/business_intelligence/frontend/biEditorTypes.ts
+++ b/products/business_intelligence/frontend/biEditorTypes.ts
@@ -351,7 +351,7 @@ export interface BIChartFit {
requirement: string
}
-/** Mirrors the "Show me" panel of desktop BI tools: which chart types suit the fields on the shelves. */
+/** Describes the chart types panel: which chart types suit the fields on the shelves. */
export function getBIChartFit(config: BIConfig, chartType: ChartDisplayType): BIChartFit {
const rowCount = config.rows.length
const columnCount = config.columns.length
@@ -1226,11 +1226,10 @@ function buildOrderByExpression(
return `${selectedOption.expression} ${sort.direction === 'asc' ? 'ASC' : 'DESC'}`
}
- // Auto sort keeps the most relevant rows inside the LIMIT: newest first for date
- // dimensions, largest first otherwise
- const firstDimension = dimensions[0]
- if (isDateTimeBIField(firstDimension.field)) {
- return `${fieldExpression(firstDimension.field)} DESC`
+ // Date dimensions follow chronological order; other dimensions keep the largest values first.
+ const dateDimension = dimensions.find(({ field }) => isDateTimeBIField(field))
+ if (dateDimension) {
+ return `${fieldExpression(dateDimension.field)} ASC`
}
const firstValueAlias =
diff --git a/products/business_intelligence/frontend/components/BIShowMe.tsx b/products/business_intelligence/frontend/components/BIChartTypes.tsx
similarity index 91%
rename from products/business_intelligence/frontend/components/BIShowMe.tsx
rename to products/business_intelligence/frontend/components/BIChartTypes.tsx
index 31ebffd018f7..f737a9e19028 100644
--- a/products/business_intelligence/frontend/components/BIShowMe.tsx
+++ b/products/business_intelligence/frontend/components/BIChartTypes.tsx
@@ -12,9 +12,9 @@ import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorL
import { getChartTypeOptions } from 'products/business_intelligence/frontend/biEditorOptions'
/** Chart picker that highlights the chart types that suit the fields on the shelves. */
-export function BIShowMe({ docked }: { docked: boolean }): JSX.Element {
+export function BIChartTypes({ docked }: { docked: boolean }): JSX.Element {
const { chartFits, config, hoveredChartType } = useValues(biEditorLogic)
- const { setChartType, setShowMeOpen, setHoveredChartType } = useActions(biEditorLogic)
+ const { setChartType, setChartTypesOpen, setHoveredChartType } = useActions(biEditorLogic)
const { featureFlags } = useValues(featureFlagLogic)
const options = getChartTypeOptions(featureFlags)
@@ -26,7 +26,7 @@ export function BIShowMe({ docked }: { docked: boolean }): JSX.Element {
return (
<div className={cn('flex flex-col', docked ? 'w-full' : 'w-44')}>
<div className="flex min-h-7 items-center justify-between px-2 pt-2">
- <span className="text-sm font-semibold">Show me</span>
+ <span className="text-sm font-semibold">Chart types</span>
{docked ? (
<LemonButton
icon={<IconX />}
@@ -34,7 +34,7 @@ export function BIShowMe({ docked }: { docked: boolean }): JSX.Element {
type="tertiary"
tooltip="Hide chart picker"
aria-label="Hide chart picker"
- onClick={() => setShowMeOpen(false)}
+ onClick={() => setChartTypesOpen(false)}
/>
) : null}
</div>
diff --git a/products/business_intelligence/frontend/components/BIConnectionSelector.tsx b/products/business_intelligence/frontend/components/BIConnectionSelector.tsx
index 392ce76c2674..6f73c8043338 100644
--- a/products/business_intelligence/frontend/components/BIConnectionSelector.tsx
+++ b/products/business_intelligence/frontend/components/BIConnectionSelector.tsx
@@ -13,7 +13,7 @@ export function BIConnectionSelector({ tabId }: { tabId: string }): JSX.Element
return (
<LemonSelect
- size="small"
+ size="xsmall"
fullWidth
className="min-w-0"
truncateText={{ maxWidthClass: 'max-w-full' }}
diff --git a/products/business_intelligence/frontend/components/BIDataPane.tsx b/products/business_intelligence/frontend/components/BIDataPane.tsx
index 6d6a337ea275..48cc2fa3d437 100644
--- a/products/business_intelligence/frontend/components/BIDataPane.tsx
+++ b/products/business_intelligence/frontend/components/BIDataPane.tsx
@@ -36,7 +36,7 @@ export function BIDataPane({ tabId }: { tabId: string }): JSX.Element {
{config.source ? (
<LemonInput
type="search"
- size="small"
+ size="xsmall"
value={dataPaneSearch}
onChange={setDataPaneSearch}
placeholder="Search fields"
@@ -92,7 +92,7 @@ export function BIDataPane({ tabId }: { tabId: string }): JSX.Element {
<div className="border-t p-2">
<LemonButton
icon={<IconPlus />}
- size="small"
+ size="xsmall"
fullWidth
type="secondary"
onClick={() => editCalculatedMeasure()}
diff --git a/products/business_intelligence/frontend/components/BIDateControls.tsx b/products/business_intelligence/frontend/components/BIDateControls.tsx
index fec26a1bfdcf..dc3d37f5ac1d 100644
--- a/products/business_intelligence/frontend/components/BIDateControls.tsx
+++ b/products/business_intelligence/frontend/components/BIDateControls.tsx
@@ -24,7 +24,7 @@ export function BIDateControls(): JSX.Element {
return (
<div className="flex flex-wrap items-center gap-1" data-attr="bi-editor-date-controls">
<LemonSelect
- size="small"
+ size="xsmall"
type="tertiary"
value={dateField?.expression ?? null}
options={[
@@ -40,7 +40,7 @@ export function BIDateControls(): JSX.Element {
data-attr="bi-editor-date-field"
/>
<DateFilter
- size="small"
+ size="xsmall"
type="tertiary"
dateFrom={config.dateRange?.date_from ?? 'all'}
dateTo={config.dateRange?.date_to ?? null}
@@ -67,6 +67,7 @@ export function BIDateControls(): JSX.Element {
size="small"
/>
<CompareFilter
+ size="xsmall"
compareFilter={config.compareFilter}
updateCompareFilter={setCompareFilter}
disableReason={getBIComparisonDisabledReason(config)}
diff --git a/products/business_intelligence/frontend/components/BIToolbar.tsx b/products/business_intelligence/frontend/components/BIToolbar.tsx
index 8ffce4840ba9..08b565b75f53 100644
--- a/products/business_intelligence/frontend/components/BIToolbar.tsx
+++ b/products/business_intelligence/frontend/components/BIToolbar.tsx
@@ -12,7 +12,7 @@ import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorL
import { LIMIT_OPTIONS } from 'products/business_intelligence/frontend/biEditorOptions'
import { getBIVisualizationSource } from 'products/business_intelligence/frontend/biQueryResults'
import { biSceneLogic } from 'products/business_intelligence/frontend/biSceneLogic'
-import { BIShowMe } from 'products/business_intelligence/frontend/components/BIShowMe'
+import { BIChartTypes } from 'products/business_intelligence/frontend/components/BIChartTypes'
import { BIDateControls } from './BIDateControls'
@@ -28,8 +28,8 @@ export function BIToolbar(): JSX.Element {
autoLoad: !!lastRunQuery,
})
)
- const { autoUpdate, config, generatedQuery, showMeOpen, sortOptions } = useValues(biEditorLogic)
- const { resetConfig, setAutoUpdate, setLimit, setShowMeOpen, setSort, swapRowsAndColumns } =
+ const { autoUpdate, config, generatedQuery, chartTypesOpen, sortOptions } = useValues(biEditorLogic)
+ const { resetConfig, setAutoUpdate, setLimit, setChartTypesOpen, setSort, swapRowsAndColumns } =
useActions(biEditorLogic)
// Quick sort follows the chosen sort field, or the first measure like desktop BI tools do
@@ -44,7 +44,7 @@ export function BIToolbar(): JSX.Element {
return (
<div className="flex flex-wrap items-center gap-1 border-b px-2 py-1">
<LemonButton
- size="small"
+ size="xsmall"
type="primary"
onClick={responseLoading ? cancelQuery : runQuery}
disabledReason={
@@ -58,9 +58,18 @@ export function BIToolbar(): JSX.Element {
>
{responseLoading ? 'Cancel' : 'Run'}
</LemonButton>
+ <LemonSwitch
+ checked={autoUpdate}
+ onChange={setAutoUpdate}
+ label="Auto-update"
+ size="small"
+ tooltip="Run the query after every change"
+ data-attr="bi-editor-auto-update"
+ />
+ <LemonDivider vertical />
<LemonButton
icon={<IconSwapHoriz />}
- size="small"
+ size="xsmall"
type="tertiary"
tooltip="Swap rows and columns"
aria-label="Swap rows and columns"
@@ -72,7 +81,7 @@ export function BIToolbar(): JSX.Element {
/>
<LemonButton
icon={<IconArrowUp />}
- size="small"
+ size="xsmall"
type="tertiary"
active={config.sort?.direction === 'asc'}
tooltip="Sort ascending"
@@ -83,7 +92,7 @@ export function BIToolbar(): JSX.Element {
/>
<LemonButton
icon={<IconArrowDown />}
- size="small"
+ size="xsmall"
type="tertiary"
active={config.sort?.direction === 'desc'}
tooltip="Sort descending"
@@ -98,8 +107,7 @@ export function BIToolbar(): JSX.Element {
{
value: null,
label: 'Auto',
- tooltip:
- 'Sorts by the newest date or the highest value first, so the top rows stay within the limit.',
+ tooltip: 'Sorts dates from oldest to newest, or other dimensions by the highest value first.',
},
...sortOptions.map((option) => ({ value: option.key, label: option.label })),
]}
@@ -107,7 +115,7 @@ export function BIToolbar(): JSX.Element {
renderButtonContent={(option) => `Sort: ${option?.label ?? 'Auto'}`}
icon={<IconSort />}
aria-label="Sort results by"
- size="small"
+ size="xsmall"
type="tertiary"
dropdownMatchSelectWidth={false}
disabledReason={sortOptions.length === 0 ? 'Add a field to rows or columns first' : undefined}
@@ -119,7 +127,7 @@ export function BIToolbar(): JSX.Element {
onChange={setLimit}
renderButtonContent={(option) => `Limit: ${option?.label ?? config.limit}`}
aria-label="Query row limit"
- size="small"
+ size="xsmall"
type="tertiary"
dropdownMatchSelectWidth={false}
data-attr="bi-editor-query-limit"
@@ -131,7 +139,7 @@ export function BIToolbar(): JSX.Element {
)}
<LemonDivider vertical />
<LemonButton
- size="small"
+ size="xsmall"
type="tertiary"
onClick={resetConfig}
disabledReason={!config.source ? 'Nothing to clear' : undefined}
@@ -140,34 +148,26 @@ export function BIToolbar(): JSX.Element {
Clear sheet
</LemonButton>
<div className="ml-auto flex items-center gap-2">
- <LemonSwitch
- checked={autoUpdate}
- onChange={setAutoUpdate}
- label="Auto-update"
- size="small"
- tooltip="Run the query after every change"
- data-attr="bi-editor-auto-update"
- />
{/* Narrow sheets have no room to dock the chart picker, so it opens as a dropdown */}
- <LemonDropdown overlay={<BIShowMe docked={false} />} placement="bottom-end">
+ <LemonDropdown overlay={<BIChartTypes docked={false} />} placement="bottom-end">
<LemonButton
- size="small"
+ size="xsmall"
type="secondary"
className="@3xl/bi-editor:hidden"
data-attr="bi-editor-show-me"
>
- Show me
+ Chart types
</LemonButton>
</LemonDropdown>
- {!showMeOpen ? (
+ {!chartTypesOpen ? (
<LemonButton
- size="small"
+ size="xsmall"
type="secondary"
className="hidden @3xl/bi-editor:flex"
- onClick={() => setShowMeOpen(true)}
+ onClick={() => setChartTypesOpen(true)}
data-attr="bi-editor-show-me"
>
- Show me
+ Chart types
</LemonButton>
) : null}
</div>