Skip to content

Commit 7108b19

Browse files
committed
[WIP]
1 parent dbeec50 commit 7108b19

File tree

54 files changed

+266
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+266
-1
lines changed

packages/o-spreadsheet-engine/src/helpers/figures/charts/abstract_chart.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ export abstract class AbstractChart {
2525
abstract readonly type: ChartType;
2626
protected readonly getters: CoreGetters;
2727
readonly humanize: boolean;
28+
readonly annotationText?: string;
29+
readonly annotationLink?: string;
2830

2931
constructor(definition: ChartDefinition, sheetId: UID, getters: CoreGetters) {
3032
this.title = definition.title;
3133
this.sheetId = sheetId;
3234
this.getters = getters;
3335
this.humanize = definition.humanize ?? true;
36+
this.annotationText = definition.annotationText;
37+
this.annotationLink = definition.annotationLink;
3438
}
3539

3640
/**

packages/o-spreadsheet-engine/src/helpers/figures/charts/scorecard_chart.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ export class ScorecardChart extends AbstractChart {
287287
: undefined,
288288
keyDescr: this.keyDescr,
289289
humanize: this.humanize,
290+
annotationText: this.annotationText,
291+
annotationLink: this.annotationLink,
290292
};
291293
}
292294

packages/o-spreadsheet-engine/src/types/chart/common_chart.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ export interface CommonChartDefinition {
1515
readonly axesDesign?: AxesDesign;
1616
readonly showValues?: boolean;
1717
readonly humanize?: boolean;
18+
readonly annotationText?: string;
19+
readonly annotationLink?: string;
1820
}

packages/o-spreadsheet-engine/src/types/chart/funnel_chart.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export interface FunnelChartDefinition {
1818
readonly funnelColors?: FunnelChartColors;
1919
readonly cumulative?: boolean;
2020
readonly humanize?: boolean;
21+
readonly annotationText?: string;
22+
readonly annotationLink?: string;
2123
}
2224

2325
export type FunnelChartRuntime = {

packages/o-spreadsheet-engine/src/types/chart/gauge_chart.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export interface GaugeChartDefinition {
99
readonly sectionRule: SectionRule;
1010
readonly background?: Color;
1111
readonly humanize?: boolean;
12+
readonly annotationText?: string;
13+
readonly annotationLink?: string;
1214
}
1315

1416
export interface SectionRule {

packages/o-spreadsheet-engine/src/types/chart/scorecard_chart.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export interface ScorecardChartDefinition {
1313
readonly baselineColorUp: Color;
1414
readonly baselineColorDown: Color;
1515
readonly humanize?: boolean;
16+
readonly annotationText?: string;
17+
readonly annotationLink?: string;
1618
}
1719

1820
export type BaselineMode = "text" | "difference" | "percentage" | "progress";

packages/o-spreadsheet-engine/src/types/chart/sunburst_chart.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export interface SunburstChartDefinition {
1717
readonly groupColors?: (Color | undefined | null)[];
1818
readonly pieHolePercentage?: number;
1919
readonly humanize?: boolean;
20+
readonly annotationText?: string;
21+
readonly annotationLink?: string;
2022
}
2123

2224
export type SunburstChartRuntime = {

packages/o-spreadsheet-engine/src/types/chart/tree_map_chart.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export interface TreeMapChartDefinition {
1919
readonly valuesDesign?: TitleDesign;
2020
readonly coloringOptions?: TreeMapColoringOptions;
2121
readonly humanize?: boolean;
22+
readonly annotationText?: string;
23+
readonly annotationLink?: string;
2224
}
2325

2426
export type TreeMapCategoryColorOptions = {

src/components/figures/figure/figure.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from "../../../types/index";
1414
import { getRefBoundingRect, keyboardEventToShortcutString } from "../../helpers/dom_helpers";
1515
import { withZoom } from "../../helpers/zoom";
16+
import { InfoPopover, InfoState } from "../../info_popover/info_popover";
1617
import { MenuPopover, MenuState } from "../../menu_popover/menu_popover";
1718

1819
type ResizeAnchor =
@@ -49,17 +50,19 @@ export class FigureComponent extends Component<Props, SpreadsheetChildEnv> {
4950
onMouseDown: { type: Function, optional: true },
5051
onClickAnchor: { type: Function, optional: true },
5152
};
52-
static components = { MenuPopover };
53+
static components = { MenuPopover, InfoPopover };
5354
static defaultProps = {
5455
onMouseDown: () => {},
5556
onClickAnchor: () => {},
5657
};
5758

5859
private menuState: MenuState = useState({ isOpen: false, anchorRect: null, menuItems: [] });
60+
private infoState: InfoState = useState({ isOpen: false, anchorRect: null });
5961

6062
private figureRef = useRef("figure");
6163
private figureWrapperRef = useRef("figureWrapper");
6264
private menuButtonRef = useRef("menuButton");
65+
private infoButtonRef = useRef("infoButton");
6366

6467
private borderWidth!: number;
6568

@@ -280,4 +283,19 @@ export class FigureComponent extends Component<Props, SpreadsheetChildEnv> {
280283
!this.env.model.getters.isCurrentSheetLocked()
281284
);
282285
}
286+
287+
showInfo() {
288+
this.infoState.isOpen = true;
289+
this.infoState.anchorRect = getRefBoundingRect(this.infoButtonRef);
290+
}
291+
292+
getAnnotationText() {
293+
const chart = this.env.model.getters.getChartFromFigureId(this.props.figureUI.id);
294+
return chart?.annotationText;
295+
}
296+
297+
getAnnotationLink() {
298+
const chart = this.env.model.getters.getChartFromFigureId(this.props.figureUI.id);
299+
return chart?.annotationLink;
300+
}
283301
}

src/components/figures/figure/figure.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@
2525
openContextMenu.bind="openContextMenu"
2626
/>
2727
<div class="o-figure-menu position-absolute m-2" t-if="!env.isDashboard()">
28+
<div
29+
class="o-info-icon d-flex flex-row align-items-center text-muted me-2"
30+
t-if="getAnnotationText() or getAnnotationLink()"
31+
t-on-click="showInfo"
32+
t-ref="infoButton">
33+
<t t-call="o-spreadsheet-Icon.CIRCLE_INFO"/>
34+
</div>
35+
<InfoPopover
36+
t-if="infoState.isOpen"
37+
anchorRect="infoState.anchorRect"
38+
onClose="() => this.infoState.isOpen=false"
39+
infoText="getAnnotationText()"
40+
infoLink="getAnnotationLink()"
41+
/>
2842
<div
2943
class="o-figure-menu-item d-flex-align-items-center"
3044
t-if="!env.model.getters.isReadonly() and props.figureUI.tag !== 'carousel'"

0 commit comments

Comments
 (0)