UNPKG

igniteui-react-charts

Version:

Ignite UI React charting components for building rich data visualizations using TypeScript APIs.

52 lines (51 loc) 2.12 kB
/* 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 * as React from 'react'; import { TypeRegistrar } from "igniteui-react-core"; function getSliceLabel(series, item) { return item[series.labelMemberPath]; } function getValue(series, item) { return item[getValueMemberPath(series)]; } function getValueMemberPath(series) { return series.valueMemberPath; } function getBrush(i) { if (i.slice.background) return i.slice.background.fill; return "black"; } const DoughnutSliceTooltip = (props) => { if (!props.dataContext) { return null; } if (!props.dataContext.item) { return null; } const series = props.dataContext.series; const item = props.dataContext.item; return (React.createElement("div", { className: 'ui-chart-default-tooltip-content' }, React.createElement("span", { style: { color: getBrush(props.dataContext.i) } }, getSliceLabel(series, item)), React.createElement("br", null), React.createElement("span", { className: "ui-tooltip-priority" }, getValueMemberPath(series), " : ", getValue(series, item)))); }; export class IgrDoughnutChartDefaultTooltips { constructor() { this.doughnutSliceTooltip = DoughnutSliceTooltip; } ensureDefaultTooltip(series) { if (series.showDefaultTooltip) { series.tooltipTemplate = this.doughnutSliceTooltip; } else { if (series.tooltipTemplate === this.doughnutSliceTooltip) { series.tooltipTemplate = null; } } } static register() { TypeRegistrar.registerCons("IgrDoughnutChartDefaultTooltips", IgrDoughnutChartDefaultTooltips); } }