o-spreadsheet
o-spreadsheet copied to clipboard
[IMP] Chart: Reference cell as title in chart
Description:
Ever wished your chart titles could be more dynamic? Well, wish granted!
This PR allows you to transform your static chart titles and axis labels into something interactive! 🧙♂️💫
Now you can point, click, and voilà—your selected cell becomes the chart title or axis label!
Task: : 3693157
review checklist
- [ ] feature is organized in plugin, or UI components
- [ ] support of duplicate sheet (deep copy)
- [ ] in model/core: ranges are Range object, and can be adapted (adaptRanges)
- [ ] in model/UI: ranges are strings (to show the user)
- [ ] undo-able commands (uses this.history.update)
- [ ] multiuser-able commands (has inverse commands and transformations where needed)
- [ ] new/updated/removed commands are documented
- [ ] exportable in excel
- [ ] translations (_t("qmsdf %s", abc))
- [ ] unit tested
- [ ] clean commented code
- [ ] track breaking changes
- [ ] doc is rebuild (npm run doc)
- [ ] status is correct in Odoo
Hello @hokolomopo,
Thanks for your suggestions. I followed your advice to use only the property to ensure we don't miss anything. I've ensured that the title updates with all operations, just like other ranges in the definition.
I'm encountering a minor issue with TypeScript. I need the title's type to change based on the titleType property. If titleType is 'reference', the type of title should be a Range, and if it's 'value', it should be a string. I want to avoid having to explicitly cast the title as Range or as string every time I use it.
I tried implementing TypeScript's conditional types to achieve this, but it didn't work out. Can you suggest a better way to handle this scenario?
I'm encountering a minor issue with TypeScript. I need the title's type to change based on the titleType property. If titleType is 'reference', the type of title should be a Range, and if it's 'value', it should be a string. I want to avoid having to explicitly cast the title as Range or as string every time I use it.
Hello :wave:
Yeah that part was always gonna be the most annoying :x I' don't think this can be done using TS conditional type ? I could be wrong tho, I'm not very familiar with those.
In the same vein as what you did, you could use typeof this.title
as the condition for your ternaries, it's almost the same thing but now you don't have to cast it. Something like const str = typeof this.title === "string" ? this.title : getTitleRangeValue(...)
A batter soluton would be to combine the title type and the title range/string into a single object, that way it could be typed.
type ChartTitle = { type: "reference", value: Range } | { type: "string", value: string }
that way when checking for title.type === "reference", typescript will detect that title.value is a Range.
Hello @dhrp-odoo It looks like it requires a rebase :/ We merged a big task for chart customization which conflicts