UNPKG

highcharts

Version:
13 lines 15.2 kB
/** * Highcharts JS v12.6.0 (2026-04-13) * @module highcharts/modules/pictorial * @requires highcharts * * Pictorial graph series type for Highcharts * * (c) 2010-2026 Highsoft AS * Author: Torstein Hønsi, Magdalena Gut * * 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 i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let r=t.default;var i=e.n(r);e.d({},{});let{doc:a,win:o}=i();function n(t,e,r,a={}){let o="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(o,"hcEvents")||(o.hcEvents={});let s=o.hcEvents;i().Point&&t instanceof i().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let h=t.addEventListener;h&&h.call(t,e,r,!!i().supportsPassiveEvents&&{passive:void 0===a.passive?-1!==e.indexOf("touch"):a.passive,capture:!1}),s[e]||(s[e]=[]);let l={fn:r,order:"number"==typeof a.order?a.order:1/0};return s[e].push(l),s[e].sort((t,e)=>t.order-e.order),function(){f(t,e,r)}}function s(t,e){let r;for(r in t||(t={}),e)t[r]=e[r];return t}function h(t){return l(t)&&"number"==typeof t.nodeType}function l(t,e){let r;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(r=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==r)}function p(t,...e){let r,i=[t,...e],a={},o=function(t,e){return"object"!=typeof t&&(t={}),d(e,function(r,i){if("__proto__"!==i&&"constructor"!==i){let a;!l(r,!0)||(a=r?.constructor,l(r,!0)&&!h(r)&&a?.name&&"Object"!==a.name)||h(r)?t[i]=e[i]:t[i]=o(t[i]||{},r)}}),t};!0===t&&(a=i[1],i=Array.prototype.slice.call(i,2));let n=i.length;for(r=0;r<n;r++)a=o(a,i[r]);return a}function d(t,e,r){for(let i in t)Object.hasOwnProperty.call(t,i)&&e.call(r||t[i],t[i],i,t)}function c(){let t=arguments,e=t.length;for(let r=0;r<e;r++){let e=t[r];if(null!=e)return e}}function f(t,e,r){function i(e,r){let i=t.removeEventListener;i&&i.call(t,e,r,!1)}function a(r){let a,o;t.nodeName&&(e?(a={})[e]=!0:a=r,d(a,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)):(a(t),t[e]=[])}else a(t),delete o.hcEvents}}Array.prototype.find;let{animObject:u}=i(),{getOptions:g}=i(),m=function(){let t=[],e=g().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 x(t,e){let r=JSON.stringify(t),i=r.length||0,a=0,o=0,n;if(e){n=Math.max(Math.floor(i/500),1);for(let t=0;t<i;t+=n)a+=r.charCodeAt(t);a&=a}for(;o<i;++o)a=(a<<5)-a+r.charCodeAt(o),a&=a;return a.toString(16).replace("-","1")}function y(){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 w(){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 b(){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=p(this.series.options.color,t))}function A(t){let e=t.args[0],r=t.args[1],i=t.args[2],a=this.chartIndex||0,o=e.pattern,n="#333333";if(void 0!==e.patternIndex&&m&&(o=m[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)&&M.call({graphic:{element:i}},o),t||!o.id||o.anchorToPoint){let t,e;(o=p({},o)).anchorToPoint&&(t=p({},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-"+a+"-"+x(o)+x(o,!0)+(o.anchorToPoint?"-anchored":"")}this.addPattern(o,!this.forExport&&c(o.animation,this.globalAnimation,{duration:100})),n=`url(${this.url}#${o.id+(this.forExport?"-export":"")})`}else n=o.color||n;return i.setAttribute(r,n),e.toString=function(){return n},!1}function v(){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 M(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 E(t,e){let r=c(e,!0),i=u(r),a=t.color||"#333333",o=t.height||("number"==typeof t._height?t._height:0)||32,n=t.width||("number"==typeof t._width?t._width:0)||32,s=t.anchorToPoint?"userSpaceOnUse":t.patternContentUnits||"userSpaceOnUse",h=t=>this.rect(0,0,n,o).attr({fill:t}).add(x),p,d=t.id,g;if(!d&&(this.idCounter=this.idCounter||0,d="highcharts-pattern-"+this.idCounter+"-"+(this.chartIndex||0),++this.idCounter),this.forExport&&(d+="-export"),this.defIds=this.defIds||[],this.defIds.indexOf(d)>-1)return;this.defIds.push(d);let m={id:d,patternUnits:"userSpaceOnUse",patternContentUnits:s,width:n,height:o,x:t._x||t.x||0,y:t._y||t.y||0};t._inverted&&(m.patternTransform="scale(1, -1)",t.patternTransform&&(t.patternTransform+=" scale(1, -1)")),t.patternTransform&&(m.patternTransform=t.patternTransform);let x=this.createElement("pattern").attr(m).add(this.defs);return x.id=d,t.path?(g=l(t.path)?t.path:{d:t.path},t.backgroundColor&&h(t.backgroundColor),p={d:g.d},this.styledMode||(p.stroke=g.stroke||a,p["stroke-width"]=c(g.strokeWidth,2),p.fill=g.fill||"none"),g.transform&&(p.transform=g.transform),this.createElement("path").attr(p).add(x),x.color=a):t.image&&(r?this.image(t.image,0,0,n,o,function(){this.animate({opacity:c(t.opacity,1)},i),f(this.element,"load")}).attr({opacity:0}).add(x):this.image(t.image,0,0,n,o).add(x)),t.image&&r||void 0===t.opacity||[].forEach.call(x.element.childNodes,e=>{e.setAttribute("opacity",t.opacity)}),this.patternElements=this.patternElements||{},this.patternElements[d]=x,x}function _(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 C(){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 k=t.default.Chart;var O=e.n(k);let L=t.default.SeriesRegistry;var S=e.n(L);let P={rescalePatternFill:function(t,e,r,i,a=1){let o=t&&t.attr("fill"),n=o&&o.match(/url\(([^)]+)\)/);if(n){let o=document.querySelector(`${n[1]} path`);if(o){let n=o.getBBox();if(0===n.width){let e=o.parentElement;t.renderer.box.appendChild(o),n=o.getBBox(),e.appendChild(o)}let s=1/(n.width+a),h=e/i/n.height,l=n.width/n.height,p=r/e,d=-n.width/2;l<p&&(s=s*l/p),o.setAttribute("stroke-width",a/(r*s)),o.setAttribute("transform",`translate(0.5, 0)scale(${s} ${h}) translate(${d+a*s/2}, ${-n.y})`)}}},invertShadowGroup:function(t,e){let r=e.chart.inverted;r&&t.attr({rotation:90*!!r,scaleX:r?-1:1})},getStackMetrics:function(t,e){let r=t.len,i=0;return e&&null!=e.max&&(i=t.toPixels(e.max,!0),r=t.len-i),{height:r,y:i}}},T=S().seriesTypes.column.prototype.pointClass,{rescalePatternFill:B,getStackMetrics:G}=P,j=class extends T{setState(){super.setState.apply(this,arguments);let t=this.series,e=t.options.paths;if(this.graphic&&this.shapeArgs&&e){let r=e[this.index%e.length];B(this.graphic,G(t.yAxis,r).height,this.shapeArgs.width||0,this.shapeArgs.height||1/0,this.series.options.borderWidth||0)}}},I=t.default.Series;var W=e.n(I);let D=t.default.StackItem;var R=e.n(D);let U=t.default.SVGRenderer;var X=e.n(U);let $=S().seriesTypes.column;({compose:function(t,e,r){let i=e.prototype.pointClass,a=i.prototype;if(!a.calculatePatternDimensions){var o,h;let l;n(t,"endResize",y),n(t,"redraw",w),s(a,{calculatePatternDimensions:M}),n(i,"afterInit",b),n(e,"render",v),o=e.prototype,l=o[h="getColor"],o[h]=function(){let t=arguments,e=this;return _.apply(this,[function(){return l.apply(e,arguments.length?arguments:t)}].concat([].slice.call(arguments)))},n(e,"afterRender",C),n(e,"mapZoomComplete",C),s(r.prototype,{addPattern:E}),n(r,"complexColor",A)}},patterns:m}).compose(O(),W(),X());let{animObject:Y}=i(),{getStackMetrics:F,invertShadowGroup:N,rescalePatternFill:V}=P;class H extends ${animate(t){let{chart:e,group:r}=this,i=Y(this.options.animation),a=[this.getSharedClipKey(),i.duration,i.easing,i.defer].join(","),o=e.sharedClips[a];if(t&&r){let t=e.getClipBox(this);o||(t.y=t.height,t.height=0,o=e.renderer.clipRect(t),e.sharedClips[a]=o),r.clip(o)}else if(o&&!o.hasClass("highcharts-animating")){let t=e.getClipBox(this);o.addClass("highcharts-animating").animate(t,i)}}animateDrilldown(){}animateDrillupFrom(){}pointAttribs(t){let e=super.pointAttribs.apply(this,arguments),r=this.options.paths;if(t&&t.shapeArgs&&r){let i=r[t.index%r.length],{y:a,height:o}=F(this.yAxis,i),n=i.definition;n!==t.pathDef?(t.pathDef=n,e.fill={pattern:{path:{d:n,fill:e.fill,strokeWidth:e["stroke-width"],stroke:e.stroke},x:t.shapeArgs.x,y:a,width:t.shapeArgs.width||0,height:o,patternContentUnits:"objectBoundingBox",backgroundColor:"none",color:"#ff0000"}}):t.pathDef&&t.graphic&&delete e.fill}return delete e.stroke,delete e.strokeWidth,e}getExtremes(){let t=super.getExtremes.apply(this,arguments),e=this.options.paths;return e&&e.forEach(function(e){null!=e.max&&null!=t.dataMax&&e.max>t.dataMax&&(t.dataMax=e.max)}),t}}function q(t){let e=Object.keys(t.points).filter(t=>t.split(",").length>1),r=t.axis.chart.series,i=e.map(t=>parseFloat(t.split(",")[0])),a=-1;i.forEach(t=>{r[t]&&r[t].visible&&(a=t)});let o=t.axis.chart.series[a];if(o&&o.is("pictorial")&&t.axis.hasData()&&o.xAxis.hasData()){let e=o.xAxis,r=t.axis.options,i=t.axis.chart,a=t.shadow,n=e.toPixels(t.x,!0),s=i.inverted?e.len-n:n,h=o.options.paths||[],l=t.x%h.length,p=h[l],d=o.getColumnMetrics&&o.getColumnMetrics().width,{height:f,y:u}=F(o.yAxis,p),g=r.stackShadow,m=c(g&&g.borderWidth,o.options.borderWidth,1);if(!a&&g&&g.enabled&&p)t.shadowGroup||(t.shadowGroup=i.renderer.g("shadow-group").add()),t.shadowGroup.attr({translateX:i.inverted?t.axis.pos:e.pos,translateY:i.inverted?e.pos:t.axis.pos}),t.shadow=i.renderer.rect(s,u,d,f).attr({fill:{pattern:{path:{d:p.definition,fill:g.color||"#dedede",strokeWidth:m,stroke:g.borderColor||"transparent"},x:s,y:u,width:d,height:f,patternContentUnits:"objectBoundingBox",backgroundColor:"none",color:"#dedede"}}}).add(t.shadowGroup),N(t.shadowGroup,t.axis),V(t.shadow,f,d,f,m),t.setOffset(o.pointXOffset||0,o.barW||0);else if(a&&t.shadowGroup){a.animate({x:s,y:u,width:d,height:f});let r=a.attr("fill"),n=r&&r.match(/url\(([^)]+)\)/);n&&i.renderer.patternElements&&i.renderer.patternElements[n[1].slice(1)].animate({x:s,y:u,width:d,height:f}),t.shadowGroup.animate({translateX:i.inverted?t.axis.pos:e.pos,translateY:i.inverted?e.pos:t.axis.pos}),N(t.shadowGroup,t.axis),V(a,f,d,f,m),t.setOffset(o.pointXOffset||0,o.barW||0)}}else t.shadow&&t.shadowGroup&&(t.shadow.destroy(),t.shadow=void 0,t.shadowGroup.destroy(),t.shadowGroup=void 0)}function z(t,e){t.axes&&t.axes.forEach(function(t){t.stacking&&d(t.stacking.stacks,function(t){d(t,function(t){e(t)})})})}function Z(t){z(t,function(t){t.shadow&&t.shadowGroup&&(t.shadow.destroy(),t.shadowGroup.destroy(),delete t.shadow,delete t.shadowGroup)})}H.defaultOptions=p($.defaultOptions,{borderWidth:0}),n(H,"afterRender",function(){let t=this,e=t.options.paths,r=/url\(([^)]+)\)/;t.points.forEach(function(i){if(i.graphic&&i.shapeArgs&&e){let a=e[i.index%e.length],o=i.graphic.attr("fill"),n=o&&o.match(r),{y:s,height:h}=F(t.yAxis,a);if(n&&t.chart.renderer.patternElements){let e=t.chart.renderer.patternElements[n[1].slice(1)];e&&e.animate({x:i.shapeArgs.x,y:s,width:i.shapeArgs.width||0,height:h})}V(i.graphic,F(t.yAxis,a).height,i.shapeArgs.width||0,i.shapeArgs.height||1/0,t.options.borderWidth||0)}})}),n(O(),"render",function(){z(this,q)}),n(R(),"afterSetOffset",function(t){if(this.shadow){let{chart:e,len:r}=this.axis,{xOffset:i,width:a}=t,o=e.inverted?i-e.xAxis[0].len:i,n=e.inverted?-r:0;this.shadow.attr({translateX:o,translateY:n}),this.shadow.animate({width:a})}}),n(O(),"afterDrilldown",function(){Z(this)}),n(O(),"afterDrillUp",function(){Z(this)}),H.prototype.pointClass=j,S().registerSeriesType("pictorial",H);let J=i();export{J as default};