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): give charts more space with contextual settings (#116845)

Marius Andraab67e481b834
diff --git a/docs/published/handbook/engineering/data-warehouse.md b/docs/published/handbook/engineering/data-warehouse.md
index c17cd9a7d9ef..480a7aafc25b 100644
--- a/docs/published/handbook/engineering/data-warehouse.md
+++ b/docs/published/handbook/engineering/data-warehouse.md
@@ -34,13 +34,15 @@ Returning to a notebook can reuse completed query results from the last two minu
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.
+**Charts** opens chart types and series controls in the right panel. **Analysis** and the visualization settings button replace that panel with their own controls. The panel starts closed. Close it after editing to return to the chart. The Series/Display settings use the same panel and scroll independently. Row filters appear once above the chart; click a filter to edit it. **AND / OR groups** opens the grouping dialog, and **Result filters** opens a popover. The left pane contains the selected source and its dimensions and measures; **Fields** hides or restores it. The toolbar wraps as the worksheet narrows, and the right panel overlays the chart when there is not enough space to dock it. These layout changes apply only to BI worksheets; SQL and other insights retain their existing settings layout.
+
+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 leaves a blank worksheet, even with auto-update enabled. Add a field to rows or columns before running. A worksheet with dimensions and no selected measure shows **Count of rows** on its shelf and value axis. Turning auto-update off keeps the current result; **Run** applies pending changes.
-**Clear sheet** clears shelves, filters, chart settings, and results while retaining the selected table, connection, date scope, and worksheet-local field definitions. Drag pills onto another pill to reorder them. **Swap rows and columns** exchanges dimensions and measure placement, preserving calculations and sort choices; bar charts switch between vertical and horizontal orientation. The **Show me** picker offers chart types suited to the selected fields.
+**Clear sheet** clears shelves, filters, chart settings, and results while retaining the selected table, connection, date scope, and worksheet-local field definitions. Drag pills onto another pill to reorder them. **Swap rows and columns** exchanges dimensions and measure placement, preserving calculations and sort choices; bar charts switch between vertical and horizontal orientation. The **Charts** picker offers chart types suited to the selected fields.
-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.
+Drag the right edge of the fields pane to resize it. Docked panes each take at most a quarter of a wide worksheet, leaving at least half the width for the chart. Less frequent worksheet actions, including **Save a copy**, **Save as SQL view**, and **Discard changes**, are in the worksheet actions menu beside **Share**.
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 7bc5ba233a65..ad4da97c4f3e 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -10003,73 +10003,73 @@ snapshots:
scenes-app-data-warehouse-sql-editor--bi-calculated-measure-editor--light:
hash: v1.k794b7964.69c71d482b1b19aa18a81b5ba0fc0bb038d8f3bdc9bdb0a7286c9addb4893dc2.LjgKhmcTELX-Cd50ZnnKmKLTGxv3AH0cD5BfLrBKfQ8
scenes-app-data-warehouse-sql-editor--bi-category-groups--dark:
- hash: v1.k794b7964.db5febe752a0c601218161bf584e79b0d77bbbbd12966f8fe961a959c267ee1e.4ZiKbWINQmisbWlQVD6yBgyd5gJ4MOVfe8zokw_Tb0Y
+ hash: v1.k794b7964.93111e77e6be03e5e40918825de43ac2985b6dc34bbe295d9b137957b81d5dcb.UMChg6EYpZ7BXGmh9Tx36jNjZ6ERsNzBGlZ3dYHdnBw
scenes-app-data-warehouse-sql-editor--bi-category-groups--light:
- hash: v1.k794b7964.04625f1c9605316762dff7bd3e46f7b76802083005c8d09a22cd06608c682869.CSZ-F3iT7ug-a7AZjlgN8XSVME0fqP0GicbdBrzoMVM
+ hash: v1.k794b7964.d5e34769fc378768fcf98225dd001e2cf04a6f426e626fe6556bb81397c2b170.Y6etSZ8dq76cbaCMpsCN0b0HSONai8UbCpAsOy-7rpk
scenes-app-data-warehouse-sql-editor--bi-combined-measures--dark:
- hash: v1.k794b7964.2e8dbc1f0bb7bb1dcf836c5d4707c424d0141f0028125a4cb8d7c21090ccc431.5GXasdCC9-YudIAt1e1OtBh5E_I7A-AUg9hKCwbXQcA
+ hash: v1.k794b7964.f1c6c92784061618b6c7232c162cc3b1678c9731089de48f9734d73bd7ddc8f1.uY9ysCPQw7b7gTBpCSfrHv4Don_2GmrtQY1k_ZM_KMM
scenes-app-data-warehouse-sql-editor--bi-combined-measures--light:
- hash: v1.k794b7964.04dd9cdc2ab2406095e54ac83367eb03e934d8077ffc7b91cbcc91c6353464f8.3qw_aAJ3Q9irvPSh21Es3dt_dfn8bAvwujrBfwiCJR0
+ hash: v1.k794b7964.253c420433f95e920e441e7a88464d7c2df1c621e34d92794d4fc3b12f3c0020.O55jRGWBSaPRUUR2AXDNDRWlVutGnZ_s2EZ3iyO8qLk
scenes-app-data-warehouse-sql-editor--bi-connections--dark:
- hash: v1.k794b7964.2c3737b6e5d890efb0669574b681a782c986675ac3df6604be3172b54f7fa1f2.pN-fC2R_SkEl27zDFzyqPErFCM1q7KfMxaZWr_joTAc
+ hash: v1.k794b7964.5ead38bdfedf6a867cccf730ce512bfd81a1207816be9f43b2ff459e1f53f66a.9zBHu_GwPR2mpGP7kurhvZDOBlVzluxXwDloisx_9EA
scenes-app-data-warehouse-sql-editor--bi-connections--light:
- hash: v1.k794b7964.459f184b6ec5bdd3cf9b4e9b7ddacda0463e8ae9ac490073d560f1ce0a51e2fe.BPnn_AzPAIFkpnsA015JwfMExsyL9o80wl-nMAnfgME
+ hash: v1.k794b7964.4349a11054a4e939a512d687e6e79fe9506d06cb7fcfc6ceda1ea08a08cd8b63.CKdN-OxYRnBEd4HPoyStmcVHSgy1ap3TlfzUtSXJPG8
scenes-app-data-warehouse-sql-editor--bi-data-source-picker--dark:
- hash: v1.k794b7964.a1acb6f3170a9596f63792895642e0ed3b586a9f08c38439462711cabba2a246.y22PV6f4Ujxe7EbYAlaLmH0En029zIxy87yjmI6NKE8
+ hash: v1.k794b7964.f04cf1b1590d1eb3ada6a352fe768afc4be283abc92e289b5aeab961cd27f04d.XzgKF1gpUvLVekmsi5Fc2jQzpAg5S_fTPy3dO6bYXjk
scenes-app-data-warehouse-sql-editor--bi-data-source-picker--light:
- hash: v1.k794b7964.cf8e82ca118c7c0f291e6845f5352dfbcbd39f064b6a8a3ead91c273a579bab1.YST8V7RCw2m5rYEqwe6PntWswvzLAFXOf9J6PNNl3LU
+ hash: v1.k794b7964.56e2c6244631e945e8141a5f83d91c27813c3001b823c995e7423ecc1c2f1ae0.1dEbTL3adPyPaL6ggKJr6H9zsdp9qOwspqT1L1B57yM
scenes-app-data-warehouse-sql-editor--bi-drilldown--dark:
- hash: v1.k794b7964.9fd7e2b550133c59d23548fc93ce1fc21d0dd7d27d639dad0c1a7d2c4be19a5c.5lCBDuriW0rgnKdzO1qNP7X_VniN9tGjVd5Qlksn-v4
+ hash: v1.k794b7964.ba29aa7ee46e9d36abf42e48a05532f7a1c29e136dcd0d23e8ada1dfcdb0a309.LrxMD2ghnFj_2mufzrOvzUAeCNtrHtmygqLvHrmflY8
scenes-app-data-warehouse-sql-editor--bi-drilldown--light:
- hash: v1.k794b7964.b2266ab9657760714ace53bafc6dfae78d1ed3756381b80e35aa19b6e14d0b82.8ubL2UjpqJoH1-tlcOEdGRXniFokK5S-DfgWKZQesz0
+ hash: v1.k794b7964.e43a77554e3256a78ae51ef7a04756b1178498ffe1eb66a79c5ec816af394eb7.NHelBdO8fSVLsIQQy_P8BkM9M4fccNiHOVZ-mF1UiVg
scenes-app-data-warehouse-sql-editor--bi-edit-saved-insight--dark:
- hash: v1.k794b7964.dde6db21dad04e4870d7dcf7f38b639ab698eeed34992ec45a397fb21452ebe5.rPCZTPMbg05x1wH9_25RBmOzgm4pMDL_oG0QMvkZlh8
+ hash: v1.k794b7964.8abbc2cad888ce12240e05435b5624c80b511018a5c131f781f32d3e2d2e3559.f6Nzg1-bQqOnCxbokz26r4F2i5NgH-tTrYrZiZuRjTk
scenes-app-data-warehouse-sql-editor--bi-edit-saved-insight--light:
- hash: v1.k794b7964.fbf1fa5ab5874f2d9c4f2624fe6aa4b76cad0a17c264c6853fb2f9a5256220ec.TVT1O281QsSfgk9oewf8sCN5Nv9B3TZZMg4iyOveN3g
+ hash: v1.k794b7964.6915d9dfa8cc8e5b05edb458c20c41f2f3af7a8805579b2cee31a4bd9153ea2f.KAH_Jlm9DnTsHrOnEVrfnERpYcDN8ySDJYm0nCHw4GI
scenes-app-data-warehouse-sql-editor--bi-empty-worksheet--dark:
- hash: v1.k794b7964.e04efd2d904c679ad656e1f2d3488282878630f06ecd0095a1e47e35495e3d9a.DpXUbjEI1TCHqpbQ-C2fobq1FpcTuELnaytl6xL5ZbQ
+ hash: v1.k794b7964.cda73be4adaa1a9fe5d2b3467a11e119e43f0539e25093f778e2f8dfff397d63.SC23lgvHPbwqALOLh7NBSVUAPwYOH148bvzy3RXnhLM
scenes-app-data-warehouse-sql-editor--bi-empty-worksheet--light:
- hash: v1.k794b7964.0fbe28f84f58be50be293c845f98411f085d5f31c31b6f0c4ca6009227c22732.WTvi3OA8bCbV_S8vl-nGOfmZsRrO-Sd5w9ZHnKuop7E
+ hash: v1.k794b7964.078f2e9f2eb8f5bab2ae1f560f3c5025c542fe523c51de8523034414daee979b.XKwLbrExUxHw1neScPMF-2MTUaTxopzeW1dXgjD8OFM
scenes-app-data-warehouse-sql-editor--bi-measure-display--dark:
- hash: v1.k794b7964.dd41e905894dc0aacc8080b7652f205852a6f78a6d70d7467a0ab8b87a1b2f27.y-Nv6h67bqBVn838NeDf5j83Pm4IKE3Ot5udeXgzG00
+ hash: v1.k794b7964.2828dfa1d443110392f59b3da593a4601b875f8bbf62ca8527ddc1d4ef418475.9bwvrKVklCFhbCG1Z5GHw2-0Ar2gH8fMKOV9kFHyHhQ
scenes-app-data-warehouse-sql-editor--bi-measure-display--light:
- hash: v1.k794b7964.7b331ceb80f9a23068ca09166dca0cc16f7421c3c6e0b14dcefe4e1af59f10d3.jJWvOUZAxEuUuoyfb4ZsUGc-bNWQGSf_MdPBaJuwhXc
+ hash: v1.k794b7964.4faecd765886170a0583387013faf029eb7f71deb0f6859b528cc066654d6656.yzzqbwLLtDiTdbJNL8Gqm_2ZNFQR39BI4m1Yh416uEc
scenes-app-data-warehouse-sql-editor--bi-mode-worksheet--dark:
hash: v1.k794b7964.6309ca3f3ecb88032969e856079e14cda460aa306a5172863693ff8a95ea011c.dIXWRHfmipDgezW97RK0MYne72aosXhe0o1S_uXrt_w
scenes-app-data-warehouse-sql-editor--bi-mode-worksheet--light:
hash: v1.k794b7964.d60ca4f154f5b6aa7dfe97f5907d32aeb07d408ef2ccfdd9b86bd8880c17ba6b.m2J3D-2Zw-ub5S6SSZk2MFZf3rAXWA6146N6UMKx2Xo
scenes-app-data-warehouse-sql-editor--bi-named-hierarchy--dark:
- hash: v1.k794b7964.e6f61be03177c256f1bb5dd7a4b5d79cee68d160cc0f989393e93a380cb17cb0.I6dU4AaYdoS1IJpK0NHhf4PY9n_vu8Fh1ZeDfhqYrZY
+ hash: v1.k794b7964.772553a4fdd7f1b78561948daf275d2cd3a7d8858896efce9d3ec59f4cce0a6d.KQ5s82aUfIBfbmL7cTcEK9uVtvDiXuvpv439cpkGUV4
scenes-app-data-warehouse-sql-editor--bi-named-hierarchy--light:
- hash: v1.k794b7964.dc0afaa3d657c1d8a0e9b67fb1fd33456dd609953cafa443523c4f199eb3fdc9.siBkKwoFyxSMYhoa_pWeSnxWi4P6_zKPVocTkH14Vow
+ hash: v1.k794b7964.7553e70c3976b08a1431cac63043fd6094da73427b6e199c26d7673fdf2a6c17.48MISiCYuPBYgYcflxFw9TEFpoQAwIY56SlQLyFCz6g
scenes-app-data-warehouse-sql-editor--bi-numeric-bins--dark:
- hash: v1.k794b7964.ce7f9b0758d844ef7e601584ccf4e00bd56e11fc4e3a99d79a41a11e2f4bbc25.o-zb8OLX9Kvxf9mxobVialeZLI6s6H2J-fKiC2Oxokg
+ hash: v1.k794b7964.141a2d5cd4618612186479990546e28b62a678f75a16f8125ab91715b17a2c24.GBAI_3lKqJFwiq8MmFwccYxwunjhA1HtRUNiRJdcmcA
scenes-app-data-warehouse-sql-editor--bi-numeric-bins--light:
- hash: v1.k794b7964.9b234c135dad525901107f80bc445c7b89af51a3c134f9150dc10d046431843f.hph6byvyMOb86wmhGzrpDsK1Kcfnu2zaxnAlwQTP8ls
+ hash: v1.k794b7964.120de8b3789e5492ac3109cdc6eaf76114df2156b2486bff88236a060d9bece9.ZHUJRbOG3tikk_4SFDkft_ftpPa-eo4SCuqElDiDH3A
scenes-app-data-warehouse-sql-editor--bi-one-click-comparison--dark:
- hash: v1.k794b7964.2df94a5485dcafae44f3d5809fc628beaa922709115b7054e7efb718586d45bc.egZdKfplib4AJI3CBOZujqfjklXOm8uHI9Lmf0u98Ps
+ hash: v1.k794b7964.5fb032db5e0ff22ff76520b490b9092f042486b78430a790a8142d2ff6d88e5c.PvhceGy_sR_NpCeWfDb-UIyH_l-x6uoL__Xjwl57gOM
scenes-app-data-warehouse-sql-editor--bi-one-click-comparison--light:
- hash: v1.k794b7964.a3926ec3e83f1cef8fe147b81cf08283f51c3aad4920bfea1c085aeee40b946b.8CViwZqXmORumx6eOxuwKRdUt5D-6Q0z9CpWrsASbDs
+ hash: v1.k794b7964.b6aa7dff9cddfde3d5da97dbcfdec0d305f6d8fbc94a5027d74cbaad24f116bd.6QCvuv8yYGKcomriiZ2pYrlx-dTxuG_bbC3BfDRcGmg
scenes-app-data-warehouse-sql-editor--bi-pivot-totals--dark:
- hash: v1.k794b7964.e5736ef2dcfc2608754b7493341cc964e0af8c7788658c90e514b69f26d3b727.TMtZn2SGceTopszPWbY6ztXn5OVT9EdfBu6i2FwYfLc
+ hash: v1.k794b7964.2b51225b78e1abec3c05b28ddca656ef67a2856ef5fd8ceb6391ebed9559c51b.1mRcmUto0Hg-Dj_i4IGGpSknJu9cKF7j5hjRWGyhfqw
scenes-app-data-warehouse-sql-editor--bi-pivot-totals--light:
- hash: v1.k794b7964.3e9e6693cdaec06f1a553f39cf7f97d00984facd799ab56b927fc38888d1f2c4.-VauPY5Ge0wgD6A0KSw6YqfUWySn0aXVeXX52nZAggg
+ hash: v1.k794b7964.18d24a183a1017fa8d139d31de32b68e86e1049ab1f318b46ae2edbd490c70c4.HzZB0G1OCyUgklNlWpVBdqUjYkby8tPdJCHEbt2bIsU
scenes-app-data-warehouse-sql-editor--bi-quick-filters--dark:
- hash: v1.k794b7964.6d873d5abb4a5e222b8a10efbd84fa54add1ade2800fc934d080915f2140ca61.wL5Kxg_Hvcjs-Ym7UEnxjVMq7Kif5dHEYFMOLQkWTEc
+ hash: v1.k794b7964.d4a5dd843d4a01f363e8ca6fc3d4a5c94ebc81f7b7f361e9924cd90f1262de29.BNYObyAQ1MQS0qImL0gZzpxnF5yYlpMA-3DpvK7GQeQ
scenes-app-data-warehouse-sql-editor--bi-quick-filters--light:
- hash: v1.k794b7964.36f528a219125afe7c4b3560c23186d45ccd168c425b71dc7b3aa3ad4eceb75f.DkHc1_D-S2BUrITOk9Pq6PrjOe1PWiBq13riygF45jU
+ hash: v1.k794b7964.533ade7775abc3ddb5ac6e6922dad0d92dbdf50275a1e829bf372355efa0e49a.2Kd_ZwP2ZvRUfHxOrw_-IbAmNX-fJMDLQsK4Fn-402g
scenes-app-data-warehouse-sql-editor--bi-quick-filters-narrow--dark:
- hash: v1.k794b7964.5a454caf96f701bd143857fdb0409b81d61d85478b12c8dd30ec1e24c1f6b797.RL289SkBaWUNGq6w-uAkne1J9mJtwp7YsUydHRnZXnc
+ hash: v1.k794b7964.40ad630f2ee7b3b295d3564765fe358c9002712a2ef27c4060f8e184f4edd280.ESDabwhM4aDhpUOjc7dIClU0gUbKa-FKaIRogX-XMXI
scenes-app-data-warehouse-sql-editor--bi-quick-filters-narrow--light:
- hash: v1.k794b7964.dbf24706c9ab3988200c93b62361d03dca1542bd10c8427b4775d618f55424a5.AOB9fkh4lFm5dTHRVptioJtCTAVPdVxoFj6jvE1zdqo
+ hash: v1.k794b7964.e7db08ce2d5e580cde7a678f00d7783262cbbc9f687624db8e1d1ec06438b643.OpUSKOi-ss50LirtJ06s3OJBw2vnoFnkpAgKOecVdjc
scenes-app-data-warehouse-sql-editor--bi-saved-insight--dark:
hash: v1.k794b7964.06df092616d217a4ebdaf0f5f35015c05fe63f5bc1e9b9c39dcdf6594293c0e3.D8zEjaefT5868HRYC8F6GkfsuMMlcxSxekM5z-VoXyM
scenes-app-data-warehouse-sql-editor--bi-saved-insight--light:
hash: v1.k794b7964.2c5f15b06d4347f767fc34bf934ea1bd53e988c443d528edb457795e778cc556.FcMHWv530RuOEcqg3G_bnos4zzZ4mku3Q9pdsK-VCXU
scenes-app-data-warehouse-sql-editor--bi-table-analysis--dark:
- hash: v1.k794b7964.a7986c7b8b9ad4a0884ba0489f52a8323242a6a53b260e2399d7379d207afade.JkJDxNwruFZswiNwBftXGjW9YagyU6DYgCtRzeTqRb4
+ hash: v1.k794b7964.b0a74ae541fa14e1207ffb16f01757428f1aa32b10fb81265be0412710529412.2FIYisR4fLPZgvBRa3irQQryPcxs9mPxkxzgSvqGj40
scenes-app-data-warehouse-sql-editor--bi-table-analysis--light:
- hash: v1.k794b7964.80a5f32a5368ac18ec4bd247ff941b379e911dc06c7c89c265eb5b4589854560.B6VtR_Glmq1fsWgXY2MqxRVapmAo3EGjgrnAmujymAc
+ hash: v1.k794b7964.ef22f781ac458c833ee217db23e43b8bb55f771236e499705d68e5ebcd41cb5e.LrtZ0JhrOemD838Zh0O5A0Y4fTu2z6ICzWliCf_Kp0Q
scenes-app-data-warehouse-sql-editor--edited-insight--dark:
hash: v1.k794b7964.334b216a8359c768613cdec5b99a8a8ee26b6b5fac76397eaed8d6d1401a23c0.0pI7NMTufzUIfDel9Ngmhv3P3sdBu6IgpSj5xYNmYrY
scenes-app-data-warehouse-sql-editor--edited-insight--light:
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/SideBar.tsx b/frontend/src/queries/nodes/DataVisualization/Components/SideBar.tsx
index 47c2e1c145cc..28d0e89377f1 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/SideBar.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/SideBar.tsx
@@ -39,7 +39,7 @@ const TABS_TO_CONTENT: Record<SideBarTab, TabContent> = {
},
}
-export const SideBar = (): JSX.Element => {
+export const SideBar = ({ className = 'w-72 max-w-[50%] shrink-0' }: { className?: string }): JSX.Element => {
const { activeSideBarTab, effectiveVisualizationType } = useValues(dataVisualizationLogic)
const { setSideBarTab } = useActions(dataVisualizationLogic)
@@ -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-72 min-h-0 max-w-[50%] shrink-0 flex flex-col">
+ <div className={`bg-surface-primary min-h-0 flex flex-col ${className}`}>
<LemonTabs
size="small"
activeKey={activeTab}
diff --git a/frontend/src/queries/nodes/DataVisualization/DataVisualization.test.tsx b/frontend/src/queries/nodes/DataVisualization/DataVisualization.test.tsx
index 829973ddacba..22c53b5c1284 100644
--- a/frontend/src/queries/nodes/DataVisualization/DataVisualization.test.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/DataVisualization.test.tsx
@@ -1,4 +1,6 @@
-import { cleanup, render, waitFor } from '@testing-library/react'
+import { cleanup, render, screen, waitFor, within } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import { useState } from 'react'
import { VisualizationNode, HogQLQueryResponse, NodeKind } from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
@@ -51,6 +53,47 @@ describe('DataTableVisualization', () => {
cleanup()
})
+ it.each([false, true])('opens and closes settings in the correct panel (hosted: %s)', async (hosted) => {
+ function Visualization(): JSX.Element {
+ const [container, setContainer] = useState<HTMLDivElement | null>(null)
+ const [isOpen, setIsOpen] = useState(false)
+ return (
+ <>
+ <div ref={setContainer} data-attr="host-settings" />
+ <DataTableVisualization
+ uniqueKey={`settings-${hosted}`}
+ query={query}
+ setQuery={jest.fn()}
+ cachedResults={cachedResults}
+ editMode
+ context={
+ hosted
+ ? {
+ visualizationSettingsPanel: {
+ container,
+ isOpen,
+ onToggle: () => setIsOpen(!isOpen),
+ },
+ }
+ : undefined
+ }
+ />
+ </>
+ )
+ }
+ const { container } = render(<Visualization />)
+ expect(screen.queryByText('Conditional formatting')).toBeNull()
+ await userEvent.click(screen.getByLabelText('Visualization settings'))
+ const settings = await screen.findByText('Conditional formatting')
+ const host = screen.getByTestId('host-settings')
+ expect(host.contains(settings)).toBe(hosted)
+ expect(container.querySelector('.DataVisualization')!.contains(settings)).toBe(!hosted)
+ await userEvent.click(settings)
+ expect(within(hosted ? host : container).getByText('Add rule')).toBeTruthy()
+ await userEvent.click(screen.getByLabelText('Visualization settings'))
+ expect(screen.queryByText('Conditional formatting')).toBeNull()
+ })
+
test.each([
{ embedded: true, expectedAllowContentScroll: true },
{ embedded: false, expectedAllowContentScroll: false },
diff --git a/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx b/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
index 2063b9be5f75..b56f3bf6b28d 100644
--- a/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
@@ -2,6 +2,7 @@ import clsx from 'clsx'
import { BindLogic, BuiltLogic, LogicWrapper, useActions, useValues } from 'kea'
import { router } from 'kea-router'
import { useCallback, useMemo, useRef, useState } from 'react'
+import { createPortal } from 'react-dom'
import { IconGear } from '@posthog/icons'
import { LemonBanner, LemonButton, LemonDivider } from '@posthog/lemon-ui'
@@ -196,6 +197,7 @@ export function DataTableVisualization({
function InternalDataTableVisualization(props: DataTableVisualizationProps): JSX.Element {
const { readOnly } = props
+ const settingsPanel = props.context?.visualizationSettingsPanel
const {
query,
@@ -480,6 +482,11 @@ function InternalDataTableVisualization(props: DataTableVisualizationProps): JSX
'h-full': effectiveVisualizationType !== ChartDisplayType.ActionsTable,
})}
>
+ {!readOnly &&
+ showResultControls &&
+ settingsPanel?.isOpen &&
+ settingsPanel.container &&
+ createPortal(<SideBar className="w-full flex-1" />, settingsPanel.container)}
<div className="relative min-h-0 min-w-0 w-full flex flex-col gap-2 flex-1 overflow-hidden">
{!readOnly && showResultControls && (
<>
@@ -512,9 +519,10 @@ function InternalDataTableVisualization(props: DataTableVisualizationProps): JSX
<LemonButton
size={controlSize}
icon={<IconGear />}
- type={isChartSettingsPanelOpen ? 'primary' : 'secondary'}
- onClick={() => toggleChartSettingsPanel()}
+ type={(settingsPanel?.isOpen ?? isChartSettingsPanelOpen) ? 'primary' : 'secondary'}
+ onClick={settingsPanel?.onToggle ?? (() => toggleChartSettingsPanel())}
tooltip="Visualization settings"
+ aria-label="Visualization settings"
/>
{props.exportContext && (
@@ -546,7 +554,7 @@ function InternalDataTableVisualization(props: DataTableVisualizationProps): JSX
<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 && (
+ {!readOnly && showResultControls && !settingsPanel && isChartSettingsPanelOpen && (
<>
<SideBar />
<LemonDivider vertical className="h-full" />
diff --git a/frontend/src/queries/types.ts b/frontend/src/queries/types.ts
index fbec3be99759..407f865b3b99 100644
--- a/frontend/src/queries/types.ts
+++ b/frontend/src/queries/types.ts
@@ -107,6 +107,12 @@ export interface QueryContext<Q extends QuerySchema = QuerySchema> {
hideAxes?: boolean
/** Hide or resize the visualization selector when the host provides its own chart picker. */
chartTypeSelectorClassName?: string
+ /** Hosts visualization settings in the scene's own panel instead of opening another sidebar. */
+ visualizationSettingsPanel?: {
+ isOpen: boolean
+ onToggle: () => void
+ container: HTMLElement | null
+ }
}
export type QueryContextColumnTitleComponent = ComponentType<{
diff --git a/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx b/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx
index 3e5a61bbd3a1..10ab449989df 100644
--- a/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/SQLEditorScene.stories.tsx
@@ -1277,7 +1277,9 @@ export const BICombinedMeasures: Story = {
export const BIMeasureDisplay: Story = {
...BICombinedMeasures,
play: async ({ canvasElement }) => {
- await userEvent.click((await within(canvasElement).findAllByRole('button', { name: 'Format and display' }))[0])
+ const canvas = within(canvasElement)
+ await userEvent.click(await canvas.findByRole('button', { name: /^Charts$/ }))
+ await userEvent.click((await canvas.findAllByRole('button', { name: 'Format and display' }))[0])
},
}
diff --git a/products/business_intelligence/frontend/BIEditor.tsx b/products/business_intelligence/frontend/BIEditor.tsx
index 3b6bce8fe924..7a0ecb9044a0 100644
--- a/products/business_intelligence/frontend/BIEditor.tsx
+++ b/products/business_intelligence/frontend/BIEditor.tsx
@@ -1,7 +1,8 @@
import { BindLogic, useActions, useValues } from 'kea'
-import { useRef, type ReactNode } from 'react'
+import { useRef, type ReactNode, type Ref } from 'react'
-import { LemonTag } from '@posthog/lemon-ui'
+import { IconX } from '@posthog/icons'
+import { LemonButton, LemonTag } from '@posthog/lemon-ui'
import { Resizer } from 'lib/components/Resizer/Resizer'
import { resizerLogic, ResizerLogicProps } from 'lib/components/Resizer/resizerLogic'
@@ -13,7 +14,6 @@ import {
BI_SHELF_PILL_DRAG_MIME_TYPE,
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'
@@ -25,17 +25,21 @@ import { BIToolbar } from 'products/business_intelligence/frontend/components/BI
import { BIAnalysisControls } from './BIAnalysisControls'
import { BILocalFieldModal } from './BILocalFieldModal'
import { BIMeasureSettingsModal } from './BIMeasureSettingsModal'
-import { BIResultFiltersCard } from './components/BIResultFiltersCard'
-/**
- * A worksheet laid out like desktop BI tools: data pane, filter and marks cards, rows and columns
- * shelves above the view, and a chart picker on the right.
- */
-export function BIEditor({ tabId, children }: { tabId: string; children: ReactNode }): JSX.Element {
- const { config, chartTypesOpen, dragSessionId } = useValues(biEditorLogic({ tabId }))
- const { removeFieldFromShelf, setActiveDropShelf } = useActions(biEditorLogic({ tabId }))
+export function BIEditor({
+ tabId,
+ children,
+ settingsPanelRef,
+}: {
+ tabId: string
+ children: ReactNode
+ settingsPanelRef: Ref<HTMLDivElement>
+}): JSX.Element {
+ const { config, activePanel, fieldsPaneOpen, dragSessionId } = useValues(biEditorLogic({ tabId }))
+ const { removeFieldFromShelf, setActiveDropShelf, setActivePanel, toggleFieldsPane } = useActions(
+ biEditorLogic({ tabId })
+ )
const containerRef = useRef<HTMLDivElement>(null)
- const cardsRef = useRef<HTMLDivElement>(null)
const biEditorResizerProps: ResizerLogicProps = {
logicKey: 'bi-editor-side-pane',
placement: 'right',
@@ -44,14 +48,6 @@ export function BIEditor({ tabId, children }: { tabId: string; children: ReactNo
}
const { desiredSize } = useValues(resizerLogic(biEditorResizerProps))
const biSidePaneWidth = Math.min(400, Math.max(180, desiredSize ?? 240))
- const cardsResizerProps: ResizerLogicProps = {
- logicKey: 'bi-editor-cards-pane',
- placement: 'right',
- containerRef: cardsRef,
- persistent: true,
- }
- const { desiredSize: cardsDesiredSize } = useValues(resizerLogic(cardsResizerProps))
- const cardsWidth = Math.min(320, Math.max(160, cardsDesiredSize ?? 160))
return (
<BindLogic logic={biEditorLogic} props={{ tabId }}>
@@ -76,35 +72,30 @@ export function BIEditor({ tabId, children }: { tabId: string; children: ReactNo
<BICalculatedMeasureModal />
<BILocalFieldModal />
<BIMeasureSettingsModal />
- <div className="flex min-h-0 flex-1">
- <div
- className="relative flex w-[var(--bi-side-pane-width)] max-w-[50%] shrink-0 flex-col border-r @5xl/bi-editor:w-[calc(var(--bi-side-pane-width)+var(--bi-cards-width))] @5xl/bi-editor:max-w-none @5xl/bi-editor:flex-row"
- // eslint-disable-next-line react/forbid-dom-props
- style={
- {
- '--bi-side-pane-width': `${biSidePaneWidth}px`,
- '--bi-cards-width': `${cardsWidth}px`,
- } as React.CSSProperties
- }
- >
- <div ref={containerRef} className="relative flex min-h-0 min-w-0 flex-1 flex-col">
- <BIDataPane tabId={tabId} />
- <Resizer {...biEditorResizerProps} />
- </div>
+ <div className="relative flex min-h-0 flex-1">
+ {fieldsPaneOpen && (
<div
- ref={cardsRef}
- className="relative flex min-h-0 max-h-[40%] shrink-0 flex-col border-t @5xl/bi-editor:max-h-none @5xl/bi-editor:w-[var(--bi-cards-width)] @5xl/bi-editor:border-l @5xl/bi-editor:border-t-0"
+ ref={containerRef}
+ className="relative flex min-h-0 w-[var(--bi-side-pane-width)] max-w-[40%] shrink-0 flex-col border-r @5xl/bi-editor:max-w-[25%]"
+ style={{ '--bi-side-pane-width': `${biSidePaneWidth}px` } as React.CSSProperties}
+ data-attr="bi-editor-fields-pane"
>
- <div className="min-h-0 overflow-y-auto">
- <BIFiltersCard />
- <BIResultFiltersCard />
- <BIMarksCard />
- <BIAnalysisControls />
+ <div className="flex items-center justify-between px-2 pt-1">
+ <span className="text-sm font-semibold">Data</span>
+ <LemonButton
+ icon={<IconX />}
+ size="xsmall"
+ type="tertiary"
+ aria-label="Hide fields"
+ onClick={toggleFieldsPane}
+ data-attr="bi-editor-close-fields"
+ />
</div>
- <Resizer {...cardsResizerProps} className="hidden @5xl/bi-editor:block" />
+ <BIDataPane tabId={tabId} />
+ <Resizer {...biEditorResizerProps} />
</div>
- </div>
- <div className="flex min-w-0 flex-1 flex-col">
+ )}
+ <div className="flex min-w-0 flex-1 flex-col" data-attr="bi-editor-canvas">
<BIShelfStrip
shelf="columns"
title="Columns"
@@ -162,23 +153,49 @@ export function BIEditor({ tabId, children }: { tabId: string; children: ReactNo
: []),
]}
</BIShelfStrip>
+ <BIFiltersCard />
<div className="flex min-h-0 flex-1 flex-col">{children}</div>
</div>
- {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">
- <h3 className="mb-2 text-xs font-semibold">Row filters</h3>
- <div className="grid grid-cols-1 items-start gap-x-2 gap-y-2 @6xl/bi-editor:grid-cols-2">
- {config.filters.map((filter, index) => (
- <BIFilterControl key={filter.field.id} index={index} />
- ))}
- </div>
- </section>
- )}
- {chartTypesOpen && <BIChartTypes docked />}
- </div>
- ) : null}
+ {activePanel && (
+ <aside
+ className="absolute inset-y-0 right-0 z-10 flex w-72 max-w-full flex-col border-l bg-surface-primary shadow-md @5xl/bi-editor:static @5xl/bi-editor:max-w-[25%] @5xl/bi-editor:shrink-0 @5xl/bi-editor:shadow-none"
+ aria-label={
+ activePanel === 'charts'
+ ? 'Charts'
+ : activePanel === 'analysis'
+ ? 'Analysis'
+ : 'Chart settings'
+ }
+ data-attr="bi-editor-context-panel"
+ >
+ <div className="flex items-center justify-between border-b px-2 py-1">
+ <span className="text-sm font-semibold">
+ {activePanel === 'charts'
+ ? 'Charts'
+ : activePanel === 'analysis'
+ ? 'Analysis'
+ : 'Chart settings'}
+ </span>
+ <LemonButton
+ icon={<IconX />}
+ size="xsmall"
+ type="tertiary"
+ aria-label="Close panel"
+ onClick={() => setActivePanel(null)}
+ data-attr="bi-editor-close-panel"
+ />
+ </div>
+ <div className="flex min-h-0 flex-1 flex-col overflow-y-auto" ref={settingsPanelRef}>
+ {activePanel === 'charts' && (
+ <>
+ <BIChartTypes />
+ <BIMarksCard />
+ </>
+ )}
+ {activePanel === 'analysis' && <BIAnalysisControls />}
+ </div>
+ </aside>
+ )}
</div>
</div>
</BindLogic>
diff --git a/products/business_intelligence/frontend/BusinessIntelligenceScene.tsx b/products/business_intelligence/frontend/BusinessIntelligenceScene.tsx
index c17ff01ac5fc..02f29b073b2f 100644
--- a/products/business_intelligence/frontend/BusinessIntelligenceScene.tsx
+++ b/products/business_intelligence/frontend/BusinessIntelligenceScene.tsx
@@ -1,7 +1,8 @@
import { BindLogic, useActions, useValues } from 'kea'
+import { useState } from 'react'
-import { IconPlus, IconShare } from '@posthog/icons'
-import { LemonBanner, LemonButton, LemonInput, LemonModal, Spinner } from '@posthog/lemon-ui'
+import { IconEllipsis, IconPlus, IconShare } from '@posthog/icons'
+import { LemonBanner, LemonButton, LemonInput, LemonMenu, LemonModal, Spinner } from '@posthog/lemon-ui'
import { AccessDenied } from 'lib/components/AccessDenied'
import { NotFound } from 'lib/components/NotFound'
@@ -31,7 +32,9 @@ export const scene: SceneExport = {
export function BusinessIntelligenceScene({ tabId = 'bi-default' }: { tabId?: string }): JSX.Element {
const { featureFlags } = useValues(featureFlagLogic)
- const { chartTypesOpen } = useValues(biEditorLogic({ tabId }))
+ const { activePanel } = useValues(biEditorLogic({ tabId }))
+ const { setActivePanel } = useActions(biEditorLogic({ tabId }))
+ const [settingsContainer, setSettingsContainer] = useState<HTMLDivElement | null>(null)
const logic = biSceneLogic({ tabId })
const {
name,
@@ -86,7 +89,7 @@ export function BusinessIntelligenceScene({ tabId = 'bi-default' }: { tabId?: st
return (
<BindLogic logic={biSceneLogic} props={{ tabId }}>
<div className="flex h-full min-h-0 flex-col" data-attr="bi-worksheet">
- <header className="flex flex-wrap items-center gap-2 border-b px-3 py-2">
+ <header className="flex flex-wrap items-center gap-1 border-b px-2 py-1">
<LemonButton size="small" to={urls.businessIntelligence()}>
Worksheets
</LemonButton>
@@ -98,6 +101,7 @@ export function BusinessIntelligenceScene({ tabId = 'bi-default' }: { tabId?: st
value={name}
onChange={setName}
maxLength={400}
+ size="small"
className="min-w-40 flex-1"
/>
<LemonButton size="small" onClick={undo} disabledReason={!canUndo ? 'Nothing to undo' : undefined}>
@@ -106,15 +110,6 @@ export function BusinessIntelligenceScene({ tabId = 'bi-default' }: { tabId?: st
<LemonButton size="small" onClick={redo} disabledReason={!canRedo ? 'Nothing to redo' : undefined}>
Redo
</LemonButton>
- <LemonButton
- size="small"
- onClick={() => saveInsight({ asCopy: true })}
- loading={insightLoading}
- disabledReason={copyDisabledReason}
- data-attr="bi-save-copy"
- >
- Save a copy
- </LemonButton>
<LemonButton
size="small"
icon={<IconShare />}
@@ -123,27 +118,42 @@ export function BusinessIntelligenceScene({ tabId = 'bi-default' }: { tabId?: st
>
Share
</LemonButton>
- <LemonButton
- size="small"
- onClick={() => setExportViewOpen(true)}
- disabledReason={
- saveDisabledReason ||
- (!userHasAccess(AccessControlResourceType.WarehouseObjects, AccessControlLevel.Editor)
- ? 'You do not have permission to create warehouse views'
- : undefined)
- }
- data-attr="bi-export-sql-view"
- >
- Save as SQL view
- </LemonButton>
- <LemonButton
- size="small"
- onClick={discardChanges}
- disabledReason={!hasUnsavedChanges ? 'No changes to discard' : undefined}
- data-attr="bi-discard-changes"
+ <LemonMenu
+ items={[
+ {
+ label: 'Save a copy',
+ onClick: () => saveInsight({ asCopy: true }),
+ disabledReason: insightLoading ? 'Saving worksheet' : copyDisabledReason,
+ 'data-attr': 'bi-save-copy',
+ },
+ {
+ label: 'Save as SQL view',
+ onClick: () => setExportViewOpen(true),
+ disabledReason:
+ saveDisabledReason ||
+ (!userHasAccess(
+ AccessControlResourceType.WarehouseObjects,
+ AccessControlLevel.Editor
+ )
+ ? 'You do not have permission to create warehouse views'
+ : undefined),
+ 'data-attr': 'bi-export-sql-view',
+ },
+ {
+ label: 'Discard changes',
+ onClick: discardChanges,
+ disabledReason: !hasUnsavedChanges ? 'No changes to discard' : undefined,
+ 'data-attr': 'bi-discard-changes',
+ },
+ ]}
>
- Discard changes
- </LemonButton>
+ <LemonButton
+ icon={<IconEllipsis />}
+ size="small"
+ aria-label="Worksheet actions"
+ data-attr="bi-worksheet-actions"
+ />
+ </LemonMenu>
<LemonButton
type="primary"
size="small"
@@ -162,7 +172,7 @@ export function BusinessIntelligenceScene({ tabId = 'bi-default' }: { tabId?: st
<Spinner />
</div>
) : (
- <BIEditor tabId={tabId}>
+ <BIEditor tabId={tabId} settingsPanelRef={setSettingsContainer}>
{lastRunQuery ? (
<Query
query={lastRunQuery}
@@ -176,7 +186,12 @@ export function BusinessIntelligenceScene({ tabId = 'bi-default' }: { tabId?: st
context={{
insightProps: { dashboardItemId: `new-bi-${tabId}` },
showOpenEditorButton: false,
- chartTypeSelectorClassName: chartTypesOpen ? '@3xl/bi-editor:hidden' : undefined,
+ chartTypeSelectorClassName: 'hidden',
+ visualizationSettingsPanel: {
+ isOpen: activePanel === 'display',
+ onToggle: () => setActivePanel(activePanel === 'display' ? null : 'display'),
+ container: settingsContainer,
+ },
}}
/>
) : (
diff --git a/products/business_intelligence/frontend/biEditorLogic.ts b/products/business_intelligence/frontend/biEditorLogic.ts
index ad4375ca1fcf..462c07b43206 100644
--- a/products/business_intelligence/frontend/biEditorLogic.ts
+++ b/products/business_intelligence/frontend/biEditorLogic.ts
@@ -352,6 +352,8 @@ function setFieldDateBucketInConfig(
}
}
+export type BIPanel = 'charts' | 'analysis' | 'display'
+
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface biEditorLogicValues {
allTables: DatabaseSchemaTable[] // databaseTableListLogic
@@ -363,12 +365,12 @@ export interface biEditorLogicValues {
activeExpressionEditorId: string | null
activeExpressionEditorTarget: 'aggregation' | 'field'
activeMeasureSettingsIndex: number | null
+ activePanel: BIPanel | null
autoUpdate: boolean
availableDataSources: BIDataSource[]
calculatedFieldError: string | undefined
calculatedMeasureDraft: BICalculatedMeasureDraft | null
chartFits: Partial<Record<ChartDisplayType, BIChartFit>>
- chartTypesOpen: boolean
config: BIConfig
dataPaneFields: BIDataPaneFields
dataPaneFieldsError: boolean
@@ -376,12 +378,12 @@ export interface biEditorLogicValues {
dataPaneSearch: string
dragSessionId: string
editorView: BIEditorView
+ fieldsPaneOpen: boolean
filteredDataPaneFields: BIDataPaneFields
generatedQuery: BIQueryBuildResult | null
hoveredChartType: ChartDisplayType | null
localFieldDraft: BIField | null
selectableDataSources: BIDataSource[]
- showMeOpen: boolean
sortOptions: BISortOption[]
}
@@ -508,6 +510,9 @@ export interface biEditorLogicActions {
fieldId: string | null
target: 'aggregation' | 'field'
}
+ setActivePanel: (panel: BIPanel | null) => {
+ panel: BIPanel | null
+ }
setAutoUpdate: (autoUpdate: boolean) => {
autoUpdate: boolean
}
@@ -517,9 +522,6 @@ export interface biEditorLogicActions {
setChartType: (chartType: ChartDisplayType) => {
chartType: ChartDisplayType
}
- setChartTypesOpen: (chartTypesOpen: boolean) => {
- chartTypesOpen: boolean
- }
setColorBy: (colorBy: string | null | undefined) => {
colorBy: string | null | undefined
}
@@ -648,6 +650,9 @@ export interface biEditorLogicActions {
swapRowsAndColumns: () => {
value: true
}
+ toggleFieldsPane: () => {
+ value: true
+ }
updateFilter: (
index: number,
update: Partial<Pick<BIFilter, 'enabled' | 'values' | 'valueTo'>>
@@ -689,7 +694,6 @@ export interface biEditorLogicMeta {
calculatedMeasureDraft: BICalculatedMeasureDraft | null,
config: BIConfig
) => string | undefined
- chartTypesOpen: (showMeOpen: boolean) => boolean
availableDataSources: (
allTables: DatabaseSchemaTable[],
posthogTables: DatabaseSchemaTable[],
@@ -787,7 +791,8 @@ export const biEditorLogic = kea<biEditorLogicType>([
}),
convertMeasureToDimension: (index: number) => ({ index }),
setAutoUpdate: (autoUpdate: boolean) => ({ autoUpdate }),
- setChartTypesOpen: (chartTypesOpen: boolean) => ({ chartTypesOpen }),
+ setActivePanel: (panel: BIPanel | null) => ({ panel }),
+ toggleFieldsPane: true,
setHoveredChartType: (chartType: ChartDisplayType | null) => ({ chartType }),
setDataPaneSearch: (search: string) => ({ search }),
runAfterChange: true,
@@ -863,11 +868,11 @@ export const biEditorLogic = kea<biEditorLogicType>([
},
],
autoUpdate: [false, { persist: true }, { setAutoUpdate: (_, { autoUpdate }) => autoUpdate }],
- // Pinned storage key: preserve the saved chart picker preference.
- showMeOpen: [true, { persist: true }, { setChartTypesOpen: (_, { chartTypesOpen }) => chartTypesOpen }],
+ activePanel: [null as BIPanel | null, { setActivePanel: (_, { panel }) => panel }],
+ fieldsPaneOpen: [true, { toggleFieldsPane: (open) => !open }],
hoveredChartType: [
null as ChartDisplayType | null,
- { setHoveredChartType: (_, { chartType }) => chartType, setChartTypesOpen: () => null },
+ { setHoveredChartType: (_, { chartType }) => chartType, setActivePanel: () => null },
],
activeExpressionEditorTarget: [
'field' as 'field' | 'aggregation',
@@ -1239,7 +1244,6 @@ export const biEditorLogic = kea<biEditorLogicType>([
}
},
],
- chartTypesOpen: [(s) => [s.showMeOpen], (open: boolean): boolean => open],
availableDataSources: [
(selectors) => [selectors.allTables, selectors.posthogTables, selectors.databaseConnectionId],
(
diff --git a/products/business_intelligence/frontend/components/BIChartTypes.tsx b/products/business_intelligence/frontend/components/BIChartTypes.tsx
index 111b59920a14..52628ecd3dc2 100644
--- a/products/business_intelligence/frontend/components/BIChartTypes.tsx
+++ b/products/business_intelligence/frontend/components/BIChartTypes.tsx
@@ -1,10 +1,8 @@
import { useActions, useValues } from 'kea'
-import { IconX } from '@posthog/icons'
import { LemonButton } from '@posthog/lemon-ui'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
-import { cn } from 'lib/utils/css-classes'
import { ChartDisplayType } from '~/types'
@@ -12,9 +10,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 BIChartTypes({ docked }: { docked: boolean }): JSX.Element {
+export function BIChartTypes(): JSX.Element {
const { chartFits, config, hoveredChartType } = useValues(biEditorLogic)
- const { setChartType, setChartTypesOpen, setHoveredChartType } = useActions(biEditorLogic)
+ const { setChartType, setHoveredChartType } = useActions(biEditorLogic)
const { featureFlags } = useValues(featureFlagLogic)
const options = getChartTypeOptions(featureFlags)
@@ -24,21 +22,8 @@ export function BIChartTypes({ docked }: { docked: boolean }): JSX.Element {
const describedFit = describedOption ? chartFits[describedOption.value] : undefined
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>
- {docked ? (
- <LemonButton
- icon={<IconX />}
- size="xsmall"
- type="tertiary"
- tooltip="Hide chart picker"
- aria-label="Hide chart picker"
- onClick={() => setChartTypesOpen(false)}
- />
- ) : null}
- </div>
- <div className="grid grid-cols-3 gap-1 p-2 @6xl/bi-editor:grid-cols-6" role="group" aria-label="Chart type">
+ <div className="flex flex-col">
+ <div className="grid grid-cols-4 gap-1 p-2" role="group" aria-label="Chart type">
{options.map((option) => {
const fits = chartFits[option.value]?.fits ?? true
const selected = config.chartType === option.value
@@ -49,7 +34,7 @@ export function BIChartTypes({ docked }: { docked: boolean }): JSX.Element {
active={selected}
icon={option.icon}
size="small"
- className={cn('justify-center', !fits && !selected && 'opacity-40')}
+ className={!fits && !selected ? 'justify-center opacity-40' : 'justify-center'}
tooltip={option.label}
aria-label={option.label}
aria-pressed={selected}
diff --git a/products/business_intelligence/frontend/components/BIDataPane.tsx b/products/business_intelligence/frontend/components/BIDataPane.tsx
index c2d659c5ecfb..ef8e22cd6dbe 100644
--- a/products/business_intelligence/frontend/components/BIDataPane.tsx
+++ b/products/business_intelligence/frontend/components/BIDataPane.tsx
@@ -28,9 +28,6 @@ export function BIDataPane({ tabId }: { tabId: string }): JSX.Element {
return (
<div className="flex min-h-0 flex-1 flex-col">
- <div className="flex items-center justify-between gap-1 px-2 pt-2">
- <span className="text-sm font-semibold">Data</span>
- </div>
<div className="flex flex-col gap-1.5 p-2">
<BIConnectionSelector tabId={tabId} />
<BIDataSourcePicker />
diff --git a/products/business_intelligence/frontend/components/BIFilterPill.tsx b/products/business_intelligence/frontend/components/BIFilterPill.tsx
index b92b81615678..47ba5e28c080 100644
--- a/products/business_intelligence/frontend/components/BIFilterPill.tsx
+++ b/products/business_intelligence/frontend/components/BIFilterPill.tsx
@@ -36,19 +36,25 @@ export function BIFilterPill({ index }: { index: number }): JSX.Element | null {
visible={visible}
onVisibilityChange={(nextVisible) => (nextVisible ? setActiveExpressionEditorId(editorKey) : close())}
closeOnClickInside={false}
- placement="right-start"
+ placement="bottom-start"
overlay={<BIFilterEditor index={index} onDone={close} />}
>
<BIPill
kind="filter"
label={label}
- detail={getBIFilterValidationError(filter) ? 'Invalid' : filter.enabled === false ? 'Off' : undefined}
+ detail={
+ getBIFilterValidationError(filter)
+ ? 'Invalid'
+ : filter.enabled === false
+ ? 'Off'
+ : getBIFilterSummary(filter)
+ }
title={`${label}: ${getBIFilterSummary(filter)}`}
shelf="filters"
index={index}
incomplete={!filter.field.expression.trim() && !filter.customExpression?.trim()}
className={cn(
- 'h-5 w-full justify-between px-1.5 font-normal',
+ 'h-5 max-w-64 justify-between px-1.5 font-normal',
filter.enabled === false && 'opacity-50'
)}
aria-label={`${label} filter`}
diff --git a/products/business_intelligence/frontend/components/BIFiltersCard.tsx b/products/business_intelligence/frontend/components/BIFiltersCard.tsx
index 2b596de71017..15f24eafafbe 100644
--- a/products/business_intelligence/frontend/components/BIFiltersCard.tsx
+++ b/products/business_intelligence/frontend/components/BIFiltersCard.tsx
@@ -1,29 +1,32 @@
import { useActions, useValues } from 'kea'
-import { IconPlus } from '@posthog/icons'
-import { LemonButton } from '@posthog/lemon-ui'
+import { IconFilter, IconPlus } from '@posthog/icons'
+import { LemonButton, LemonDropdown } from '@posthog/lemon-ui'
import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
-import { BIFilterPill } from 'products/business_intelligence/frontend/components/BIFilterPill'
-import { BIShelfCard } from 'products/business_intelligence/frontend/components/BIShelfCard'
-import { BIShelfDropTarget } from 'products/business_intelligence/frontend/components/BIShelfDropTarget'
import { getBIFieldPillLabel, getBIFilterSummary } from '../biEditorTypes'
import { BIConditionGroups } from './BIConditionGroups'
+import { BIFilterPill } from './BIFilterPill'
+import { BIResultFiltersCard } from './BIResultFiltersCard'
+import { BIShelfDropTarget } from './BIShelfDropTarget'
export function BIFiltersCard(): JSX.Element {
const { config } = useValues(biEditorLogic)
const { addBlankFieldToShelf, setFilterGroup } = useActions(biEditorLogic)
return (
- <BIShelfCard title="Row filters">
- <BIShelfDropTarget shelf="filters" className="flex min-h-6 flex-col gap-0.5">
- {config.filters.length > 0 ? (
- config.filters.map((filter, index) => <BIFilterPill key={filter.field.id} index={index} />)
- ) : (
- <span className="p-1 text-xs text-tertiary">Drop fields here to filter rows</span>
- )}
- </BIShelfDropTarget>
+ <BIShelfDropTarget
+ shelf="filters"
+ className="flex min-h-9 flex-wrap items-center gap-1 rounded-none border-b px-2 py-1"
+ >
+ <span className="flex items-center gap-1 text-xs font-semibold text-secondary">
+ <IconFilter />
+ Row filters
+ </span>
+ {config.filters.map((filter, index) => (
+ <BIFilterPill key={filter.field.id} index={index} />
+ ))}
<LemonButton
icon={<IconPlus />}
size="xsmall"
@@ -34,15 +37,30 @@ export function BIFiltersCard(): JSX.Element {
>
Add filter
</LemonButton>
- <BIConditionGroups
- title="Row filter groups"
- group={config.rowFilterGroup}
- options={config.filters.map((filter) => ({
- value: filter.field.id,
- label: `${getBIFieldPillLabel(filter.field)}: ${getBIFilterSummary(filter)}`,
- }))}
- onChange={(group) => setFilterGroup('row', group)}
- />
- </BIShelfCard>
+ {config.filters.length > 1 && (
+ <BIConditionGroups
+ title="Row filter groups"
+ group={config.rowFilterGroup}
+ options={config.filters.map((filter) => ({
+ value: filter.field.id,
+ label: `${getBIFieldPillLabel(filter.field)}: ${getBIFilterSummary(filter)}`,
+ }))}
+ onChange={(group) => setFilterGroup('row', group)}
+ />
+ )}
+ <LemonDropdown
+ closeOnClickInside={false}
+ placement="bottom-end"
+ overlay={
+ <div className="w-72">
+ <BIResultFiltersCard />
+ </div>
+ }
+ >
+ <LemonButton size="xsmall" type="tertiary" className="ml-auto" data-attr="bi-editor-result-filters">
+ <span>Result filters{config.resultFilters?.length ? ` (${config.resultFilters.length})` : ''}</span>
+ </LemonButton>
+ </LemonDropdown>
+ </BIShelfDropTarget>
)
}
diff --git a/products/business_intelligence/frontend/components/BIMarksCard.tsx b/products/business_intelligence/frontend/components/BIMarksCard.tsx
index 3478e1ab6887..f89f4806a34d 100644
--- a/products/business_intelligence/frontend/components/BIMarksCard.tsx
+++ b/products/business_intelligence/frontend/components/BIMarksCard.tsx
@@ -2,10 +2,7 @@ import { useActions, useValues } from 'kea'
import { LemonButton, LemonLabel, LemonSelect } from '@posthog/lemon-ui'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
-
import { biEditorLogic } from 'products/business_intelligence/frontend/biEditorLogic'
-import { getChartTypeOptions } from 'products/business_intelligence/frontend/biEditorOptions'
import { getBIFieldPillLabel, isDateTimeBIField } from 'products/business_intelligence/frontend/biEditorTypes'
import { BIShelfCard } from 'products/business_intelligence/frontend/components/BIShelfCard'
@@ -13,25 +10,10 @@ import { BIMeasureAnalysis } from '../BIMeasureAnalysis'
export function BIMarksCard(): JSX.Element {
const { config } = useValues(biEditorLogic)
- const { setChartType, combineMeasures, setColorBy } = useActions(biEditorLogic)
- const { featureFlags } = useValues(featureFlagLogic)
+ const { combineMeasures, setColorBy } = useActions(biEditorLogic)
return (
- <BIShelfCard title="Marks">
- <LemonSelect
- value={config.chartType}
- options={getChartTypeOptions(featureFlags).map((option) => ({
- value: option.value,
- label: option.label,
- icon: option.icon,
- }))}
- onChange={setChartType}
- size="xsmall"
- fullWidth
- aria-label="Mark type"
- data-attr="bi-editor-mark-type"
- tooltip="Choose how to display the worksheet's measures"
- />
+ <BIShelfCard title="Series">
<LemonLabel className="mt-2 text-xs">Color</LemonLabel>
<LemonSelect
value={config.colorBy === undefined ? '__automatic' : config.colorBy}
diff --git a/products/business_intelligence/frontend/components/BIToolbar.tsx b/products/business_intelligence/frontend/components/BIToolbar.tsx
index 0e68f97c541e..18952a8939ad 100644
--- a/products/business_intelligence/frontend/components/BIToolbar.tsx
+++ b/products/business_intelligence/frontend/components/BIToolbar.tsx
@@ -1,7 +1,7 @@
import { useActions, useValues, useMountedLogic } from 'kea'
import { IconSort } from '@posthog/icons'
-import { LemonButton, LemonDivider, LemonDropdown, LemonSelect, LemonSwitch } from '@posthog/lemon-ui'
+import { LemonButton, LemonDivider, LemonSelect, LemonSwitch } from '@posthog/lemon-ui'
import { IconArrowDown, IconArrowUp, IconSwapHoriz } from 'lib/lemon-ui/icons'
@@ -12,7 +12,6 @@ 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 { BIChartTypes } from 'products/business_intelligence/frontend/components/BIChartTypes'
import { BIDateControls } from './BIDateControls'
@@ -28,8 +27,8 @@ export function BIToolbar(): JSX.Element {
autoLoad: !!lastRunQuery,
})
)
- const { autoUpdate, config, generatedQuery, chartTypesOpen, sortOptions } = useValues(biEditorLogic)
- const { resetConfig, setAutoUpdate, setLimit, setChartTypesOpen, setSort, swapRowsAndColumns } =
+ const { autoUpdate, config, generatedQuery, activePanel, fieldsPaneOpen, sortOptions } = useValues(biEditorLogic)
+ const { resetConfig, setAutoUpdate, setLimit, setActivePanel, toggleFieldsPane, setSort, swapRowsAndColumns } =
useActions(biEditorLogic)
// Quick sort follows the chosen sort field, or the first measure like desktop BI tools do
@@ -152,29 +151,37 @@ export function BIToolbar(): JSX.Element {
>
Clear sheet
</LemonButton>
- <div className="ml-auto flex items-center gap-2">
- {/* Narrow sheets have no room to dock the chart picker, so it opens as a dropdown */}
- <LemonDropdown overlay={<BIChartTypes docked={false} />} placement="bottom-end">
- <LemonButton
- size="xsmall"
- type="secondary"
- className="@3xl/bi-editor:hidden"
- data-attr="bi-editor-show-me"
- >
- Show me
- </LemonButton>
- </LemonDropdown>
- {!chartTypesOpen ? (
- <LemonButton
- size="xsmall"
- type="secondary"
- className="hidden @3xl/bi-editor:flex"
- onClick={() => setChartTypesOpen(true)}
- data-attr="bi-editor-show-me"
- >
- Show me
- </LemonButton>
- ) : null}
+ <div className="ml-auto flex flex-wrap items-center gap-1">
+ <LemonButton
+ size="xsmall"
+ type="secondary"
+ active={fieldsPaneOpen}
+ onClick={toggleFieldsPane}
+ aria-pressed={fieldsPaneOpen}
+ data-attr="bi-editor-toggle-fields"
+ >
+ Fields
+ </LemonButton>
+ <LemonButton
+ size="xsmall"
+ type="secondary"
+ active={activePanel === 'charts'}
+ onClick={() => setActivePanel(activePanel === 'charts' ? null : 'charts')}
+ aria-expanded={activePanel === 'charts'}
+ data-attr="bi-editor-show-me"
+ >
+ Charts
+ </LemonButton>
+ <LemonButton
+ size="xsmall"
+ type="secondary"
+ active={activePanel === 'analysis'}
+ onClick={() => setActivePanel(activePanel === 'analysis' ? null : 'analysis')}
+ aria-expanded={activePanel === 'analysis'}
+ data-attr="bi-editor-analysis"
+ >
+ Analysis
+ </LemonButton>
</div>
</div>
)