UNPKG

highcharts

Version:
11 lines 3.34 kB
!/** * Highcharts JS v13.0.1 (2026-08-17) * @module highcharts/modules/textpath * @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,r={944(e){e.exports=t}};let a={};function h(t){let e=a[t];if(void 0!==e)return e.exports;let n=a[t]={exports:{}};return r[t](n,n.exports,h),n.exports}h.n=t=>{let e=t&&t.__esModule?()=>t.default:()=>t;return h.d(e,{a:e}),e},h.d=(t,e)=>{if(Array.isArray(e))for(var r=0;r<e.length;){var a=e[r++],n=e[r++];h.o(t,a)?0===n&&r++:0===n?Object.defineProperty(t,a,{enumerable:!0,value:e[r++]}):Object.defineProperty(t,a,{enumerable:!0,get:n})}else for(var a in e)h.o(e,a)&&!h.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},h.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let n={};h.d(n,{default:()=>l});var s=h(944),o=h.n(s);let{composed:i,deg2rad:d}=o();e=o().SVGElement,(0,s.pushUnique)(i,"TextPath")&&((0,s.addEvent)(e,"afterGetBBox",function(t){let e=t.bBox,r=this.element?.querySelector("textPath");if(r){let t=[],{b:a,h}=this.renderer.fontMetrics(this.element),n=h-a,s=RegExp('(<tspan>|<tspan(?!\\sclass="highcharts-br")[^>]*>|<\\/tspan>)',"g"),o=r.innerHTML.replace(s,"").split(/<tspan class="highcharts-br"[^>]*>/),i=o.length,l=(t,e)=>{let{x:h,y:s}=e,o=(r.getRotationOfChar(t)-90)*d,i=Math.cos(o),l=Math.sin(o);return[[h-n*i,s-n*l],[h+a*i,s+a*l]]};for(let e=0,a=0;a<i;a++){let h=o[a].length;for(let n=0;n<h;n+=5)try{let h=e+n+a,[s,o]=l(h,r.getStartPositionOfChar(h));0===n?(t.push(o),t.push(s)):(0===a&&t.unshift(o),a===i-1&&t.push(s))}catch{break}e+=h-1;try{let h=e+a,n=r.getEndPositionOfChar(h),[s,o]=l(h,n);t.unshift(o),t.unshift(s)}catch{break}}t.length&&t.push(t[0].slice()),e.polygon=t}return e}),(0,s.addEvent)(e,"beforeAddingDataLabel",function(t){let e=t.labelOptions,r=t.point,a=e[r.formatPrefix+"TextPath"]||e.textPath;a&&!e.useHTML&&(this.setTextPath(r.getDataLabelPath?.(this)||r.graphic,a),r.dataLabelPath&&!a.enabled&&(r.dataLabelPath=r.dataLabelPath.destroy()))}),e.prototype.setTextPath=e.prototype.setTextPath??function(t,e){let r=this.renderer.url,a=this.text||this,h=a.textPath,{attributes:n,enabled:o}=(0,s.merge)({enabled:!0,attributes:{dy:-5,startOffset:"50%",textAnchor:"middle"}},e);if(t=t||h&&h.path,h?.undo(),t&&o){let e=(0,s.addEvent)(a,"afterModifyTree",e=>{if(t&&o){let h=t.attr("id");h||t.attr("id",h=(0,s.uniqueKey)());let o={x:0,y:0};(0,s.defined)(n.dx)&&(o.dx=n.dx,delete n.dx),(0,s.defined)(n.dy)&&(o.dy=n.dy,delete n.dy),a.attr(o),this.attr({transform:""}),this.box&&(this.box=this.box.destroy());let i=e.nodes.slice(0);e.nodes.length=0,e.nodes[0]={tagName:"textPath",attributes:(0,s.extend)(n,{"text-anchor":n.textAnchor,href:`${r}#${h}`}),children:i}}});a.textPath={path:t,undo:e}}else a.attr({dx:0,dy:0}),delete a.textPath;return this.added&&(a.textCache="",this.renderer.buildText(a)),this});let l=o();return n.default})());