igniteui-webcomponents-charts
Version:
Ignite UI Web Components charting components for building rich data visualizations using TypeScript APIs.
53 lines (52 loc) • 2.15 kB
JavaScript
/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { TypeRegistrar } from "igniteui-webcomponents-core";
import { html } from "igniteui-webcomponents-core";
export class IgcDoughnutChartDefaultTooltipsComponent {
constructor() {
this.doughnutSliceTooltip = (context) => {
return html `<div class='ui-chart-default-tooltip-content'>
<span style="color: ${this.getBrush(context.i)}">${this.getSliceLabel(context.series, context.item)}</span>
<br/>
<span class="ui-tooltip-priority">${this.getValueMemberPath(context.series)} : ${this.getValue(context.series, context.item)}</span>
</div>`;
};
this.afterContentInit();
}
ensureDefaultTooltip(series) {
if (series.showDefaultTooltip) {
series.tooltipTemplate = this.doughnutSliceTooltip;
}
else {
if (series.tooltipTemplate === this.doughnutSliceTooltip) {
series.tooltipTemplate = null;
}
}
}
getSliceLabel(series, item) {
return item[series.labelMemberPath];
}
getValue(series, item) {
return item[this.getValueMemberPath(series)];
}
getValueMemberPath(series) {
return series.valueMemberPath;
}
getBrush(i) {
if (i.slice.background)
return i.slice.background.fill;
return "black";
}
static register() {
TypeRegistrar.registerCons("IgcDoughnutChartDefaultTooltipsComponent", IgcDoughnutChartDefaultTooltipsComponent);
}
afterContentInit() {
if (this.onContentReady != null) {
this.onContentReady();
}
}
}