UNPKG

highcharts

Version:
13 lines 10.4 kB
!/** * Highcharts JS v12.6.0 (2026-04-13) * @module highcharts/modules/pattern-fill * @requires highcharts * * Module for adding patterns and images as point fills. * * (c) 2010-2026 Highsoft AS * Author: Torstein Hønsi, Øystein Moseng * * 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/pattern-fill",["highcharts/highcharts"],function(t){return e(t)}):"object"==typeof exports?exports["highcharts/modules/pattern-fill"]=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 i(t){var n=r[t];if(void 0!==n)return n.exports;var o=r[t]={exports:{}};return e[t](o,o.exports,i),o.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var n={};i.d(n,{default:()=>I});var o=i(944),a=i.n(o);let{doc:h,win:s}=a();function l(t,e,r,i={}){let n="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(n,"hcEvents")||(n.hcEvents={});let o=n.hcEvents;a().Point&&t instanceof a().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let h=t.addEventListener;h&&h.call(t,e,r,!!a().supportsPassiveEvents&&{passive:void 0===i.passive?-1!==e.indexOf("touch"):i.passive,capture:!1}),o[e]||(o[e]=[]);let s={fn:r,order:"number"==typeof i.order?i.order:1/0};return o[e].push(s),o[e].sort((t,e)=>t.order-e.order),function(){m(t,e,r)}}function c(t,e){let r;for(r in t||(t={}),e)t[r]=e[r];return t}function p(t){return d(t)&&"number"==typeof t.nodeType}function d(t,e){let r;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(r=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==r)}function f(t,...e){let r,i=[t,...e],n={},o=function(t,e){return"object"!=typeof t&&(t={}),u(e,function(r,i){if("__proto__"!==i&&"constructor"!==i){let n;!d(r,!0)||(n=r?.constructor,d(r,!0)&&!p(r)&&n?.name&&"Object"!==n.name)||p(r)?t[i]=e[i]:t[i]=o(t[i]||{},r)}}),t};!0===t&&(n=i[1],i=Array.prototype.slice.call(i,2));let a=i.length;for(r=0;r<a;r++)n=o(n,i[r]);return n}function u(t,e,r){for(let i in t)Object.hasOwnProperty.call(t,i)&&e.call(r||t[i],t[i],i,t)}function g(){let t=arguments,e=t.length;for(let r=0;r<e;r++){let e=t[r];if(null!=e)return e}}function m(t,e,r){function i(e,r){let i=t.removeEventListener;i&&i.call(t,e,r,!1)}function n(r){let n,o;t.nodeName&&(e?(n={})[e]=!0:n=r,u(n,function(t,e){if(r[e])for(o=r[e].length;o--;)i(e,r[e][o].fn)}))}let o="function"==typeof t&&t.prototype||t;if(Object.hasOwnProperty.call(o,"hcEvents")){let t=o.hcEvents;if(e){let o=t[e]||[];r?(t[e]=o.filter(function(t){return r!==t.fn}),i(e,r)):(n(t),t[e]=[])}else n(t),delete o.hcEvents}}Array.prototype.find;let{animObject:y}=a(),{getOptions:x}=a(),w=function(){let t=[],e=x().colors,r=0;for(let i of["M 0 0 L 5 5 M 4.5 -0.5 L 5.5 0.5 M -0.5 4.5 L 0.5 5.5","M 0 5 L 5 0 M -0.5 0.5 L 0.5 -0.5 M 4.5 5.5 L 5.5 4.5","M 2 0 L 2 5 M 4 0 L 4 5","M 0 2 L 5 2 M 0 4 L 5 4","M 0 1.5 L 2.5 1.5 L 2.5 0 M 2.5 5 L 2.5 3.5 L 5 3.5"])t.push({path:i,color:e[r++],width:5,height:5,patternTransform:"scale(1.4 1.4)"});for(let i of(r=5,["M 0 0 L 5 10 L 10 0","M 3 3 L 8 3 L 8 8 L 3 8 Z","M 5 5 m -4 0 a 4 4 0 1 1 8 0 a 4 4 0 1 1 -8 0","M 0 0 L 10 10 M 9 -1 L 11 1 M -1 9 L 1 11","M 0 10 L 10 0 M -1 1 L 1 -1 M 9 11 L 11 9"]))t.push({path:i,color:e[r++],width:10,height:10});return t}();function b(t,e){let r=JSON.stringify(t),i=r.length||0,n=0,o=0,a;if(e){a=Math.max(Math.floor(i/500),1);for(let t=0;t<i;t+=a)n+=r.charCodeAt(t);n&=n}for(;o<i;++o)n=(n<<5)-n+r.charCodeAt(o),n&=n;return n.toString(16).replace("-","1")}function _(){if(this.renderer&&(this.renderer.defIds||[]).filter(t=>t&&t.indexOf&&0===t.indexOf("highcharts-pattern-")).length){for(let t of this.series)if(t.visible)for(let e of t.points){let t=e.options&&e.options.color;t&&t.pattern&&(t.pattern._width="defer",t.pattern._height="defer")}this.redraw(!1)}}function M(){let t={},e=this.renderer,r=(e.defIds||[]).filter(t=>t.indexOf&&0===t.indexOf("highcharts-pattern-"));if(r.length)for(let i of([].forEach.call(this.renderTo.querySelectorAll('[color^="url("], [fill^="url("], [stroke^="url("]'),r=>{let i=r.getAttribute("fill")||r.getAttribute("color")||r.getAttribute("stroke");i&&(t[i.replace(e.url,"").replace("url(#","").replace(")","")]=!0)}),r))!t[i]&&(!function(t,e){let r=t.length;for(;r--;)if(t[r]===e){t.splice(r,1);break}}(e.defIds,i),e.patternElements[i]&&(e.patternElements[i].destroy(),delete e.patternElements[i]))}function v(){let t=this.options.color;t&&(t.pattern||void 0!==t.patternIndex)&&("string"==typeof t.pattern?.path&&(t.pattern.path={d:t.pattern.path}),this.color=this.options.color=f(this.series.options.color,t))}function L(t){let e=t.args[0],r=t.args[1],i=t.args[2],n=this.chartIndex||0,o=e.pattern,a="#333333";if(void 0!==e.patternIndex&&w&&(o=w[e.patternIndex]),!o)return!0;if(o.image||"string"==typeof o.path||o.path&&o.path.d){let t=i.parentNode&&i.parentNode.getAttribute("class");if(t=t&&t.indexOf("highcharts-legend")>-1,("defer"===o._width||"defer"===o._height)&&E.call({graphic:{element:i}},o),t||!o.id||o.anchorToPoint){let t,e;(o=f({},o)).anchorToPoint&&(t=f({},o),t._x=(e=i.getBBox?i.getBBox():{x:0,y:0,width:32,height:32}).x,t._y=e.y,o=t),o.id="highcharts-pattern-"+n+"-"+b(o)+b(o,!0)+(o.anchorToPoint?"-anchored":"")}this.addPattern(o,!this.forExport&&g(o.animation,this.globalAnimation,{duration:100})),a=`url(${this.url}#${o.id+(this.forExport?"-export":"")})`}else a=o.color||a;return i.setAttribute(r,a),e.toString=function(){return a},!1}function A(){let t=this.chart.isResizing;if(this.isDirtyData||t||!this.chart.hasRendered)for(let e of this.points){let r=e.options&&e.options.color;r&&r.pattern&&(t&&!(e.shapeArgs&&e.shapeArgs.width&&e.shapeArgs.height)?(r.pattern._width="defer",r.pattern._height="defer"):e.calculatePatternDimensions(r.pattern))}}function E(t){if(t.width&&t.height&&!t.anchorToPoint)return;let e=this.graphic&&(this.graphic.getBBox&&this.graphic.getBBox(!0)||this.graphic.element&&this.graphic.element.getBBox())||{},r=this.shapeArgs;if(r&&(e.width=r.width||e.width,e.height=r.height||e.height,e.x=r.x||e.x,e.y=r.y||e.y),t.image){if(!e.width||!e.height){t._width="defer",t._height="defer";let e=this.series.chart.mapView&&this.series.chart.mapView.getSVGTransform().scaleY;null!=e&&e<0&&(t._inverted=!0);return}t.aspectRatio&&(e.aspectRatio=e.width/e.height,t.aspectRatio>e.aspectRatio?e.aspectWidth=e.height*t.aspectRatio:e.aspectHeight=e.width/t.aspectRatio),t._width=t.width||Math.ceil(e.aspectWidth||e.width),t._height=t.height||Math.ceil(e.aspectHeight||e.height)}t.anchorToPoint?(t._x=0,t._y=0,t.width||(t._width=e.width),t.height||(t._height=e.height)):(t.width||(t._x=t.x||0,t._x+=e.x-Math.round(e.aspectWidth?Math.abs(e.aspectWidth-e.width)/2:0)),t.height||(t._y=t.y||0,t._y+=e.y-Math.round(e.aspectHeight?Math.abs(e.aspectHeight-e.height)/2:0)))}function O(t,e){let r=g(e,!0),i=y(r),n=t.color||"#333333",o=t.height||("number"==typeof t._height?t._height:0)||32,a=t.width||("number"==typeof t._width?t._width:0)||32,h=t.anchorToPoint?"userSpaceOnUse":t.patternContentUnits||"userSpaceOnUse",s=t=>this.rect(0,0,a,o).attr({fill:t}).add(u),l,c=t.id,p;if(!c&&(this.idCounter=this.idCounter||0,c="highcharts-pattern-"+this.idCounter+"-"+(this.chartIndex||0),++this.idCounter),this.forExport&&(c+="-export"),this.defIds=this.defIds||[],this.defIds.indexOf(c)>-1)return;this.defIds.push(c);let f={id:c,patternUnits:"userSpaceOnUse",patternContentUnits:h,width:a,height:o,x:t._x||t.x||0,y:t._y||t.y||0};t._inverted&&(f.patternTransform="scale(1, -1)",t.patternTransform&&(t.patternTransform+=" scale(1, -1)")),t.patternTransform&&(f.patternTransform=t.patternTransform);let u=this.createElement("pattern").attr(f).add(this.defs);return u.id=c,t.path?(p=d(t.path)?t.path:{d:t.path},t.backgroundColor&&s(t.backgroundColor),l={d:p.d},this.styledMode||(l.stroke=p.stroke||n,l["stroke-width"]=g(p.strokeWidth,2),l.fill=p.fill||"none"),p.transform&&(l.transform=p.transform),this.createElement("path").attr(l).add(u),u.color=n):t.image&&(r?this.image(t.image,0,0,a,o,function(){this.animate({opacity:g(t.opacity,1)},i),m(this.element,"load")}).attr({opacity:0}).add(u):this.image(t.image,0,0,a,o).add(u)),t.image&&r||void 0===t.opacity||[].forEach.call(u.element.childNodes,e=>{e.setAttribute("opacity",t.opacity)}),this.patternElements=this.patternElements||{},this.patternElements[c]=u,u}function P(t){let e=this.options.color;e&&e.pattern&&!e.pattern.color?(delete this.options.color,t.apply(this,[].slice.call(arguments,1)),e.pattern.color=this.color,this.color=this.options.color=e):t.apply(this,[].slice.call(arguments,1))}function T(){if(!this.chart?.mapView)return;let t=this.chart.renderer,e=t.patternElements;t.defIds?.length&&e&&this.points.filter(function(t){return!!t.graphic&&(t.graphic.element.hasAttribute("fill")||t.graphic.element.hasAttribute("color")||t.graphic.element.hasAttribute("stroke"))&&!t.options.color?.pattern?.image&&!!t.group?.scaleX&&!!t.group?.scaleY}).map(function(e){return{id:(e.graphic?.element.getAttribute("fill")||e.graphic?.element.getAttribute("color")||e.graphic?.element.getAttribute("stroke")||"").replace(t.url,"").replace("url(#","").replace(")",""),x:e.group?.scaleX||1,y:e.group?.scaleY||1}}).filter(function(t,e,r){return""!==t.id&&-1!==t.id.indexOf("highcharts-pattern-")&&!r.some(function(r,i){return r.id===t.id&&i<e})}).forEach(function(t){let r=t.id;e[r].scaleX=1/t.x,e[r].scaleY=1/t.y,e[r].updateTransform("patternTransform")})}let C=a();C.patterns=w,function(t,e,r){let i=e.prototype.pointClass,n=i.prototype;if(!n.calculatePatternDimensions){var o,a;let h;l(t,"endResize",_),l(t,"redraw",M),c(n,{calculatePatternDimensions:E}),l(i,"afterInit",v),l(e,"render",A),o=e.prototype,h=o[a="getColor"],o[a]=function(){let t=arguments,e=this;return P.apply(this,[function(){return h.apply(e,arguments.length?arguments:t)}].concat([].slice.call(arguments)))},l(e,"afterRender",T),l(e,"mapZoomComplete",T),c(r.prototype,{addPattern:O}),l(r,"complexColor",L)}}(C.Chart,C.Series,C.SVGRenderer);let I=a();return n.default})());