Skip to content

Commit

Permalink
feat(core): allow custom labels for total & group in tooltips (carbon…
Browse files Browse the repository at this point in the history
  • Loading branch information
theiliad authored Oct 1, 2020
1 parent 1513c77 commit 4bc8db1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/components/essentials/tooltip-axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class AxisChartsTooltip extends Tooltip {
value: datum[rangeIdentifier]
},
{
label: "Group",
label: options.tooltip.groupLabel || "Group",
value: datum[groupMapsTo],
color: this.model.getStrokeColor(datum[groupMapsTo])
}
Expand All @@ -101,7 +101,7 @@ export class AxisChartsTooltip extends Tooltip {

if (Tools.getProperty(options, "tooltip", "showTotal") === true) {
items.push({
label: "Total",
label: options.tooltip.totalLabel || "Total",
value: this.valueFormatter(
data.reduce(
(accumulator, datum) =>
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/interfaces/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,18 @@ export interface TooltipOptions {
* passed an array or object with the data, and then the default tooltip markup
*/
customHTML?: Function;
/**
* customizes the `Group` label shown inside tooltips
*/
groupLabel?: string;
/**
* show total of items
*/
showTotal?: boolean;
/**
* customizes the `Total` label shown inside tooltips
*/
totalLabel?: string;
truncation?: TruncationOptions;
}

Expand Down

0 comments on commit 4bc8db1

Please sign in to comment.