@progress/kendo-vue-charts
Version:
9 lines (8 loc) • 3.61 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2026 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue"),l=require("@progress/kendo-vue-common"),u=require("@progress/kendo-charts"),a=require("./Point.js"),h=require("./SharedTooltipContent.js"),d=require("./Popup.js");function c(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!s.isVNode(t)}const f="k-chart-shared-tooltip",S="k-chart-tooltip-inverse",m=s.defineComponent({name:"KendoSeriesTooltip",data(){return{popupShown:!1,popupAlign:void 0,popupOffset:void 0,popupContext:{},popupStyles:void 0,className:void 0,shared:void 0}},inject:{optionsState:{default:{}},observersState:{default:null},dispatchObservers:{default:null}},mounted(){this.chartObserver=new u.InstanceObserver(this,{showTooltip:"onShowTooltip",hideTooltip:"onHideTooltip"}),this.dispatchObservers({type:"add",payload:this.chartObserver})},unmounted(){this.dispatchObservers({type:"remove",payload:this.chartObserver})},render(){let t;const e=this.popupShown?function(){const n=this.findRenderFunction();if(this.shared){const p=s.createVNode(h.SharedTooltipContent,{categoryText:this.popupContext.categoryText,colorMarker:this.popupContext.colorMarker,colspan:this.popupContext.colspan,nameColumn:this.popupContext.nameColumn,points:this.popupContext.points},null);return l.getTemplate.call(this,{h:s.h,template:n,defaultRendering:p,additionalProps:Object.assign({},this.popupContext)})}else{const p=this.popupContext.point,i=this.findRenderFunctionByIndex(p.series.index),o=s.h("span",{innerHTML:this.popupContext.point.formattedValue});return i!==null?l.getTemplate.call(this,{h:s.h,template:i,defaultRendering:o,additionalProps:Object.assign({},this.popupContext)}):n!==null?l.getTemplate.call(this,{h:s.h,template:n,defaultRendering:o,additionalProps:Object.assign({},this.popupContext)}):o}}:Function.prototype,r=l.classNames({[f]:this.shared,[S]:!!this.className});return s.createVNode(d.TooltipPopup,{popupShown:this.popupShown,popupAlign:this.popupAlign,popupOffset:this.popupOffset,popupStyles:this.popupStyles,className:r},c(t=e.call(this))?t:{default:()=>[t]})},methods:{onShowTooltip(t){const{anchor:e,style:r,shared:n,className:p,crosshair:i}=t;let o;i||(n?o=this.createSharedTooltipContext(t):o=this.createTooltipContext(t),this.popupShown=!0,this.popupAlign=e.align,this.popupOffset=e.point,this.popupContext=o,this.popupStyles=r,this.className=p,this.shared=n)},onHideTooltip(){this.popupShown=!1,this.popupStyles={},this.className=void 0},createSharedTooltipContext(t){const{points:e,categoryText:r}=t,n=e.filter(o=>typeof o.series.name!="undefined").length>0,p=t.series.length>1;let i=1;return n&&i++,p&&i++,{categoryText:r,colorMarker:p,colspan:i,nameColumn:n,points:t.points.map(o=>new a.TooltipPoint(o,t.format))}},createTooltipContext(t){const{point:e,format:r}=t;return{point:new a.TooltipPoint(e,r)}},findRenderFunctionByIndex(t){const e=this.optionsState.series;return e!==void 0&&Array.isArray(e)&&e[t]!==void 0&&e[t].hasOwnProperty("tooltip")&&e[t].tooltip.hasOwnProperty("render")?e[t].tooltip.render:null},findRenderFunction(){const t=this.optionsState.tooltip;return t!==void 0&&t.hasOwnProperty("render")?t.render:null}}});exports.SeriesTooltip=m;