UNPKG

highcharts

Version:
11 lines 4.81 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 */function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(t._Highcharts):"function"==typeof define&&define.amd?define("highcharts/modules/textpath",["highcharts/highcharts"],function(t){return e(t)}):"object"==typeof exports?exports["highcharts/modules/textpath"]=e(t._Highcharts):t.Highcharts=e(t.Highcharts)}("u"<typeof window?this:window,t=>(()=>{"use strict";var e={944:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var a=r[t]={exports:{}};return e[t](a,a.exports,n),a.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var o={};n.d(o,{default:()=>g});var a=n(944),s=n.n(a);let{doc:i,win:l}=s();function h(t,e,r,n={}){let o="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(o,"hcEvents")||(o.hcEvents={});let a=o.hcEvents;s().Point&&t instanceof s().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let i=t.addEventListener;i&&i.call(t,e,r,!!s().supportsPassiveEvents&&{passive:void 0===n.passive?-1!==e.indexOf("touch"):n.passive,capture:!1}),a[e]||(a[e]=[]);let l={fn:r,order:"number"==typeof n.order?n.order:1/0};return a[e].push(l),a[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,u(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 c(t){return f(t)&&"number"==typeof t.nodeType}function f(t,e){let r;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(r=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==r)}function u(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:d}=s();function p(t,e){e=function(t,...e){let r,n=[t,...e],o={},a=function(t,e){return"object"!=typeof t&&(t={}),u(e,function(r,n){if("__proto__"!==n&&"constructor"!==n){let o;!f(r,!0)||(o=r?.constructor,f(r,!0)&&!c(r)&&o?.name&&"Object"!==o.name)||c(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 r=this.renderer.url,n=this.text||this,o=n.textPath,{attributes:s,enabled:i}=e;if(t=t||o&&o.path,o&&o.undo(),t&&i){let e=h(n,"afterModifyTree",e=>{if(t&&i){let o=t.attr("id");o||t.attr("id",o=(0,a.uniqueKey)());let i={x:0,y:0};null!=s.dx&&(i.dx=s.dx,delete s.dx),null!=s.dy&&(i.dy=s.dy,delete s.dy),n.attr(i),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}(s,{"text-anchor":s.textAnchor,href:`${r}#${o}`}),children:l}}});n.textPath={path:t,undo:e}}else n.attr({dx:0,dy:0}),delete n.textPath;return this.added&&(n.textCache="",this.renderer.buildText(n)),this}function x(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"),i=r.innerHTML.replace(s,"").split(/<tspan class="highcharts-br"[^>]*>/),l=i.length,h=(t,e)=>{let{x:o,y:s}=e,i=(r.getRotationOfChar(t)-90)*d,l=Math.cos(i),h=Math.sin(i);return[[o-a*l,s-a*h],[o+n*l,s+n*h]]};for(let e=0,n=0;n<l;n++){let o=i[n].length;for(let a=0;a<o;a+=5)try{let o=e+a+n,[s,i]=h(o,r.getStartPositionOfChar(o));0===a?(t.push(i),t.push(s)):(0===n&&t.unshift(i),n===l-1&&t.push(s))}catch{break}e+=o-1;try{let o=e+n,a=r.getEndPositionOfChar(o),[s,i]=h(o,a);t.unshift(i),t.unshift(s)}catch{break}}t.length&&t.push(t[0].slice()),e.polygon=t}return e}function y(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 b=s();b.TextPath={compose:function(t){h(t,"afterGetBBox",x),h(t,"beforeAddingDataLabel",y);let e=t.prototype;e.setTextPath||(e.setTextPath=p)}},b.TextPath.compose(b.SVGElement);let g=s();return o.default})());