UNPKG

highcharts

Version:
11 lines 4.29 kB
/** * Highcharts JS v12.6.0 (2026-04-13) * @module highcharts/modules/textpath-support * @requires highcharts * * (c) 2009-2026 Highsoft AS * Author: Torstein Hønsi * * A commercial license may be required depending on use. * See www.highcharts.com/license */import*as t from"../highcharts.js";var e={};e.n=t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},e.d=(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let r=t.default;var n=e.n(r);let{doc:o,win:a}=n();function s(t,e,r,o={}){let a="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(a,"hcEvents")||(a.hcEvents={});let l=a.hcEvents;n().Point&&t instanceof n().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let i=t.addEventListener;i&&i.call(t,e,r,!!n().supportsPassiveEvents&&{passive:void 0===o.passive?-1!==e.indexOf("touch"):o.passive,capture:!1}),l[e]||(l[e]=[]);let h={fn:r,order:"number"==typeof o.order?o.order:1/0};return l[e].push(h),l[e].sort((t,e)=>t.order-e.order),function(){!function(t,e,r){function n(e,r){let n=t.removeEventListener;n&&n.call(t,e,r,!1)}function o(r){let o,a;t.nodeName&&(e?(o={})[e]=!0:o=r,c(o,function(t,e){if(r[e])for(a=r[e].length;a--;)n(e,r[e][a].fn)}))}let a="function"==typeof t&&t.prototype||t;if(Object.hasOwnProperty.call(a,"hcEvents")){let t=a.hcEvents;if(e){let a=t[e]||[];r?(t[e]=a.filter(function(t){return r!==t.fn}),n(e,r)):(o(t),t[e]=[])}else o(t),delete a.hcEvents}}(t,e,r)}}function l(t){return i(t)&&"number"==typeof t.nodeType}function i(t,e){let r;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(r=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==r)}function c(t,e,r){for(let n in t)Object.hasOwnProperty.call(t,n)&&e.call(r||t[n],t[n],n,t)}Array.prototype.find;let{deg2rad:h}=n();function f(t,e){e=function(t,...e){let r,n=[t,...e],o={},a=function(t,e){return"object"!=typeof t&&(t={}),c(e,function(r,n){if("__proto__"!==n&&"constructor"!==n){let o;!i(r,!0)||(o=r?.constructor,i(r,!0)&&!l(r)&&o?.name&&"Object"!==o.name)||l(r)?t[n]=e[n]:t[n]=a(t[n]||{},r)}}),t};!0===t&&(o=n[1],n=Array.prototype.slice.call(n,2));let s=n.length;for(r=0;r<s;r++)o=a(o,n[r]);return o}(!0,{enabled:!0,attributes:{dy:-5,startOffset:"50%",textAnchor:"middle"}},e);let n=this.renderer.url,o=this.text||this,a=o.textPath,{attributes:h,enabled:f}=e;if(t=t||a&&a.path,a&&a.undo(),t&&f){let e=s(o,"afterModifyTree",e=>{if(t&&f){let a=t.attr("id");a||t.attr("id",a=(0,r.uniqueKey)());let s={x:0,y:0};null!=h.dx&&(s.dx=h.dx,delete h.dx),null!=h.dy&&(s.dy=h.dy,delete h.dy),o.attr(s),this.attr({transform:""}),this.box&&(this.box=this.box.destroy());let l=e.nodes.slice(0);e.nodes.length=0,e.nodes[0]={tagName:"textPath",attributes:function(t,e){let r;for(r in t||(t={}),e)t[r]=e[r];return t}(h,{"text-anchor":h.textAnchor,href:`${n}#${a}`}),children:l}}});o.textPath={path:t,undo:e}}else o.attr({dx:0,dy:0}),delete o.textPath;return this.added&&(o.textCache="",this.renderer.buildText(o)),this}function u(t){let e=t.bBox,r=this.element?.querySelector("textPath");if(r){let t=[],{b:n,h:o}=this.renderer.fontMetrics(this.element),a=o-n,s=RegExp('(<tspan>|<tspan(?!\\sclass="highcharts-br")[^>]*>|<\\/tspan>)',"g"),l=r.innerHTML.replace(s,"").split(/<tspan class="highcharts-br"[^>]*>/),i=l.length,c=(t,e)=>{let{x:o,y:s}=e,l=(r.getRotationOfChar(t)-90)*h,i=Math.cos(l),c=Math.sin(l);return[[o-a*i,s-a*c],[o+n*i,s+n*c]]};for(let e=0,n=0;n<i;n++){let o=l[n].length;for(let a=0;a<o;a+=5)try{let o=e+a+n,[s,l]=c(o,r.getStartPositionOfChar(o));0===a?(t.push(l),t.push(s)):(0===n&&t.unshift(l),n===i-1&&t.push(s))}catch{break}e+=o-1;try{let o=e+n,a=r.getEndPositionOfChar(o),[s,l]=c(o,a);t.unshift(l),t.unshift(s)}catch{break}}t.length&&t.push(t[0].slice()),e.polygon=t}return e}function d(t){let e=t.labelOptions,r=t.point,n=e[r.formatPrefix+"TextPath"]||e.textPath;n&&!e.useHTML&&(this.setTextPath(r.getDataLabelPath?.(this)||r.graphic,n),r.dataLabelPath&&!n.enabled&&(r.dataLabelPath=r.dataLabelPath.destroy()))}let p=n();p.TextPath={compose:function(t){s(t,"afterGetBBox",u),s(t,"beforeAddingDataLabel",d);let e=t.prototype;e.setTextPath||(e.setTextPath=f)}},p.TextPath.compose(p.SVGElement);let y=n();export{y as default};