AliIbnBotir opened a new pull request, #45278:
URL: https://github.com/apache/superset/pull/45278

   
   ### SUMMARY
   
   Implements the Spreadsheet chart proposed in SIP #45265.
   
   > **Depends on #45263 and #45275.** This branch contains their commits, so 
until they merge, please review only the last commit, 
`feat(plugin-chart-univer): add a Spreadsheet chart built on Univer`. I will 
rebase once they are in.
   
   Adds a new chart type, **Spreadsheet** (`viz_type: univer_sheet`, category 
Table), built on [Univer](https://github.com/dream-num/univer), an Apache-2.0 
spreadsheet engine.
   
   - **In Explore** the query result loads into a spreadsheet editor (toolbar, 
formula bar, sheet tabs, context menu). Authors can rename headers, format 
cells, write formulas, add rows and sheets. Edits are saved with the chart in 
the `univer_workbook` control.
   - **On dashboards and embedded** the chart is a read-only sheet with the 
saved edits applied on top of fresh data. It uses `appSection` from #45275 to 
tell where it renders.
   - **Query modes:** Aggregate, Raw records, and Pivot (rows, columns, 
metrics, totals). Pivot runs on the backend with the existing `pivot` and 
`flatten` post-processing (which needs the fix in #45263) and shows stacked, 
merged header rows.
   - **Group rows by dimensions** (optional): Excel-style Subtotals groups with 
+/- buttons, level buttons and a Grand Total. The collapsed state is saved.
   - **Refresh data on load** (default on): the query result is rewritten into 
the data area each time the chart loads, keeping formatting, formulas outside 
the data area and other sheets. Query values are stripped before saving, so the 
saved state only holds the user's edits.
   
   Design notes:
   - Only Univer's open source packages are used: `@univerjs/presets` and 
`@univerjs/preset-sheets-core` 1.0.4. No Univer Pro packages. The 93 new 
lockfile packages are all ASF Category A licences (MIT, Apache-2.0, 
BSD-3-Clause, ISC).
   - Univer is lazy-loaded (`loadChart: () => import('../UniverChart')`), so it 
is only downloaded when a Spreadsheet chart renders. Nothing Univer-related is 
in the entry bundles.
   - All Univer calls live in `src/univer/mountUniver.ts`. Grid, layout, 
saved-state and group logic is plain TypeScript with unit tests.
   - The saved state has a `version` field so its format can change later.
   - Frontend only. The Excel export with edits is a separate follow-up PR. 
Until it lands, "Export to Excel" on this chart exports the raw query result 
like other charts.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   <img width="1088" height="620" alt="01-explore-editor" 
src="https://github.com/user-attachments/assets/babff4b2-1699-442b-9324-57af3bc726fe";
 />
   _Editing in Explore: rename headers, fill the header row, add an Average row 
with formulas, save._
   
   <img width="1440" height="640" alt="02-dashboard" 
src="https://github.com/user-attachments/assets/1a4c0d5d-cd66-4eed-9f7b-7d12801d736b";
 />
   _The same chart on a dashboard: read-only, saved edits on fresh data._
   
   <img width="1440" height="520" alt="03-pivot" 
src="https://github.com/user-attachments/assets/9f8476ca-67c1-4cb8-9551-87b6d632b2b7";
 />
   _Pivot mode: stacked, merged column headers and totals._
   <img width="1070" height="470" alt="04-row-groups" 
src="https://github.com/user-attachments/assets/1a8a87e1-faad-480f-9236-8969a08cd877";
 />
   _Row groups: Subtotals rows, collapsing with -/+ and the level buttons, 
Grand Total._
   
   ### TESTING INSTRUCTIONS
   
   Automated:
   - `npm run test -- plugins/plugin-chart-univer 
src/components/Chart/ChartRenderer.test.tsx`
   - `npm run plugins:build && npm run type`
   
   Manual:
   1. Create a chart on `video_game_sales` (or any dataset) and pick 
**Spreadsheet**.
   2. Aggregate mode: add `genre` as a dimension and a few metrics, then run 
the query.
   3. In the sheet, rename a header, give the header row a fill colour, insert 
a row under the data and type a formula such as `=AVERAGE(B2:B13)`. Save the 
chart.
   4. Reload Explore: the edits are kept and the data is fresh.
   5. Add the chart to a dashboard: it renders read-only with the edits.
   6. Switch to Pivot mode with Rows = `genre`, Columns = `platform`: check the 
merged headers and totals.
   7. Back in Aggregate mode, add a second dimension and tick **Group rows by 
dimensions**: check the Subtotals rows, the -/+ and level buttons, and that the 
collapsed state survives a save.
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: SIP #45265
   - [ ] Required feature flags:
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   The chart is registered unconditionally. If maintainers prefer, it can go 
behind a feature flag (for example `SPREADSHEET_CHART`) until it has had wider 
use.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to