@progress/kendo-react-charts
Version:
React Chart renders a wide range of high-quality data visualizations. KendoReact Charts package
9 lines (8 loc) • 1.97 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react"),m=require("@progress/kendo-react-common"),f=require("@progress/kendo-charts"),O=require("./Popup.js"),C=require("../ChartContext.js");function b(s){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const e in s)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(s,e);Object.defineProperty(t,e,o.get?o:{enumerable:!0,get:()=>s[e]})}}return t.default=s,Object.freeze(t)}const i=b(S),y="k-chart-crosshair-tooltip",T="k-chart-tooltip-inverse",a=class a extends i.Component{constructor(t,e){super(t,e),this.context=null,this.state={popupShown:!1},this.chartObserver=new f.InstanceObserver(this,{showTooltip:"onShowTooltip",hideTooltip:"onHideTooltip"}),e.observersStore.dispatch({type:"add",payload:this.chartObserver})}render(){const{popupContend:t,className:e,...o}=this.state,n=this.state.popupShown?()=>t:Function.prototype,p=m.classNames({[y]:!0,[T]:!!e});return i.createElement(O.TooltipPopup,{...o,popupContent:n,className:p})}componentWillUnmount(){var t;(t=this.context)==null||t.observersStore.dispatch({type:"remove",payload:this.chartObserver})}onShowTooltip(t){const{anchor:e,style:o,className:n,crosshair:p,axisName:c,axisIndex:l,value:u}=t,{name:h,index:d}=this.props;p&&c===h&&l===d&&this.setState({popupShown:!0,popupAlign:e.align,popupOffset:e.point,popupContend:u,popupStyles:o,className:n})}onHideTooltip(){this.setState({popupShown:!1,popupStyles:{},className:void 0})}};a.contextType=C.ChartContext;let r=a;exports.CrosshairTooltip=r;