UNPKG

@progress/kendo-vue-charts

Version:
102 lines (101 loc) 2.69 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ import { defineComponent as u, createVNode as h, isVNode as d } from "vue"; import { classNames as c } from "@progress/kendo-vue-common"; import { InstanceObserver as f } from "@progress/kendo-charts"; import { TooltipPopup as m } from "./Popup.mjs"; function S(t) { return typeof t == "function" || Object.prototype.toString.call(t) === "[object Object]" && !d(t); } const O = "k-chart-crosshair-tooltip", b = "k-chart-tooltip-inverse", C = /* @__PURE__ */ u({ name: "KendoCrosshairTooltip", props: { index: Number, name: String }, data() { return { popupShown: !1, popupAlign: void 0, popupOffset: void 0, popupContent: void 0, popupStyles: void 0, className: void 0 }; }, inject: { optionsState: { default: {} }, dispatchOptions: { default: null }, observersStore: { default: null }, dispatchObservers: { default: null }, childrenObserver: { default: null } }, created() { this.chartObserver = new f(this, { showTooltip: "onShowTooltip", hideTooltip: "onHideTooltip" }), this.dispatchObservers({ type: "add", payload: this.chartObserver }); }, unmounted() { this.dispatchObservers({ type: "remove", payload: this.chartObserver }); }, render() { const t = this.popupShown ? this.popupContent : Function.prototype, o = c({ [O]: !0, [b]: !!this.className }); return h(m, { popupShown: this.popupShown, popupAlign: this.popupAlign, popupOffset: this.popupOffset, popupStyles: this.popupStyles, className: o }, S(t) ? t : { default: () => [t] }); }, methods: { onShowTooltip(t) { const { anchor: o, style: e, className: p, crosshair: s, axisName: n, axisIndex: i, value: r } = t, { name: a, index: l } = this.$props; s && n === a && i === l && (this.popupShown = !0, this.popupAlign = o.align, this.popupOffset = o.point, this.popupContent = r, this.popupStyles = e, this.className = p); }, onHideTooltip() { this.popupShown = !1, this.popupStyles = {}, this.className = void 0; } } }); export { C as CrosshairTooltip };