UNPKG

highcharts

Version:
152 lines (124 loc) 31.3 kB
!/** * Highmaps JS v12.6.0 (2026-04-13) * @module highcharts/modules/contour * @requires highcharts * * (c) 2009-2025 Highsoft AS * * License: www.highcharts.com/license */function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(e._Highcharts,e._Highcharts.Axis,e._Highcharts.Color,e._Highcharts.SeriesRegistry):"function"==typeof define&&define.amd?define("highcharts/modules/contour",["highcharts/highcharts"],function(e){return t(e,e.Axis,e.Color,e.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/modules/contour"]=t(e._Highcharts,e._Highcharts.Axis,e._Highcharts.Color,e._Highcharts.SeriesRegistry):e.Highcharts=t(e.Highcharts,e.Highcharts.Axis,e.Highcharts.Color,e.Highcharts.SeriesRegistry)}("u"<typeof window?this:window,(e,t,i,r)=>(()=>{"use strict";var o,s,n,l,a={512:e=>{e.exports=r},532:e=>{e.exports=t},620:e=>{e.exports=i},944:t=>{t.exports=e}},h={};function u(e){var t=h[e];if(void 0!==t)return t.exports;var i=h[e]={exports:{}};return a[e](i,i.exports,u),i.exports}u.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return u.d(t,{a:t}),t},u.d=(e,t)=>{for(var i in t)u.o(t,i)&&!u.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var f={};u.d(f,{default:()=>K});var c=u(944),d=u.n(c),p=u(532),g=u.n(p),m=u(620),v=u.n(m);let{doc:x,win:y}=d();function C(e,t,i,r={}){let o="function"==typeof e&&e.prototype||e;Object.hasOwnProperty.call(o,"hcEvents")||(o.hcEvents={});let s=o.hcEvents;d().Point&&e instanceof d().Point&&e.series&&e.series.chart&&(e.series.chart.runTrackerClick=!0);let n=e.addEventListener;n&&n.call(e,t,i,!!d().supportsPassiveEvents&&{passive:void 0===r.passive?-1!==t.indexOf("touch"):r.passive,capture:!1}),s[t]||(s[t]=[]);let l={fn:i,order:"number"==typeof r.order?r.order:1/0};return s[t].push(l),s[t].sort((e,t)=>e.order-t.order),function(){!function(e,t,i){function r(t,i){let r=e.removeEventListener;r&&r.call(e,t,i,!1)}function o(i){let o,s;e.nodeName&&(t?(o={})[t]=!0:o=i,O(o,function(e,t){if(i[t])for(s=i[t].length;s--;)r(t,i[t][s].fn)}))}let s="function"==typeof e&&e.prototype||e;if(Object.hasOwnProperty.call(s,"hcEvents")){let e=s.hcEvents;if(t){let s=e[t]||[];i?(e[t]=s.filter(function(e){return i!==e.fn}),r(t,i)):(o(e),e[t]=[])}else o(e),delete s.hcEvents}}(e,t,i)}}function b(e,t,i,r){let o={};return!function e(t,o,s,n){let l=i?o:t;O(t,function(i,a){if(!n&&r&&r.indexOf(a)>-1&&o[a]){var h;i=w(h=i)?h:[h],s[a]=[];for(let t=0;t<Math.max(i.length,o[a].length);t++)o[a][t]&&(void 0===i[t]?s[a][t]=o[a][t]:(s[a][t]={},e(i[t],o[a][t],s[a][t],n+1)))}else I(i,!0)&&!i.nodeType?(s[a]=w(i)?[]:{},e(i,o[a]||{},s[a],n+1),0===Object.keys(s[a]).length&&("colorAxis"!==a||0!==n)&&delete s[a]):(t[a]!==o[a]||a in t&&!(a in o))&&"__proto__"!==a&&"constructor"!==a&&(s[a]=l[a])})}(e,t,o,0),o}function U(e,t){let i;for(i in e||(e={}),t)e[i]=t[i];return e}function A(e){return I(e)&&"number"==typeof e.nodeType}function w(e){let t=Object.prototype.toString.call(e);return"[object Array]"===t||"[object Array Iterator]"===t}function I(e,t){return!!e&&"object"==typeof e&&(!t||!w(e))}function E(e,...t){let i,r=[e,...t],o={},s=function(e,t){return"object"!=typeof e&&(e={}),O(t,function(i,r){if("__proto__"!==r&&"constructor"!==r){let o;!I(i,!0)||(o=i?.constructor,I(i,!0)&&!A(i)&&o?.name&&"Object"!==o.name)||A(i)?e[r]=t[r]:e[r]=s(e[r]||{},i)}}),e};!0===e&&(o=r[1],r=Array.prototype.slice.call(r,2));let n=r.length;for(i=0;i<n;i++)o=s(o,r[i]);return o}function O(e,t,i){for(let r in e)Object.hasOwnProperty.call(e,r)&&t.call(i||e[r],e[r],r,e)}function P(){let e=arguments,t=e.length;for(let i=0;i<t;i++){let t=e[i];if(null!=t)return t}}function S(e,t,i){return/%$/.test(e)?t*parseFloat(e)/100+(i||0):parseFloat(e)}Array.prototype.find;let{parse:M}=v();(o=s||(s={})).initDataClasses=function(e){let t=this.chart,i=this.legendItem=this.legendItem||{},r=this.options,o=e.dataClasses||[],s,n,l=t.options.chart.colorCount,a=0,h;this.dataClasses=n=[],i.labels=[];for(let e=0,i=o.length;e<i;++e)s=E(s=o[e]),n.push(s),(t.styledMode||!s.color)&&("category"===r.dataClassColor?(t.styledMode||(l=(h=t.options.colors||[]).length,s.color=h[a]),s.colorIndex=a,++a===l&&(a=0)):s.color=M(r.minColor).tweenTo(M(r.maxColor),i<2?.5:e/(i-1)))},o.initStops=function(){let e=this.options,t=this.stops=e.stops||[[0,e.minColor||""],[1,e.maxColor||""]];for(let e=0,i=t.length;e<i;++e)t[e].color=M(t[e][1])},o.normalizedValue=function(e){let t=this.max||0,i=this.min||0;return this.logarithmic&&(e=this.logarithmic.log2lin(e)),1-(t-e)/(t-i||1)},o.toColor=function(e,t){let i,r,o,s,n,l,a=this.dataClasses,h=this.stops;if(a){for(l=a.length;l--;)if(r=(n=a[l]).from,o=n.to,(void 0===r||e>=r)&&(void 0===o||e<=o)){s=n.color,t&&(t.dataClass=l,t.colorIndex=n.colorIndex);break}}else{for(i=this.normalizedValue(e),l=h.length;l--&&!(i>h[l][0]););r=h[l]||h[l+1],i=1-((o=h[l+1]||r)[0]-i)/(o[0]-r[0]||1),s=r.color.tweenTo(o.color,i)}return s};let L=s,{parse:B}=v();!function(e){let t;function i(){let{userOptions:e}=this;if(this.colorAxis=[],e.colorAxis){var i;e.colorAxis=w(i=e.colorAxis)?i:[i],e.colorAxis.map(e=>new t(this,e))}}function r(e){let t=this.chart.colorAxis||[],i=t=>{let i=e.allItems.indexOf(t);-1!==i&&(this.destroyItem(e.allItems[i]),e.allItems.splice(i,1))},r=[],o,s;for(t.forEach(function(e){o=e.options,o?.showInLegend&&(o.dataClasses&&o.visible?r=r.concat(e.getDataClassLegendSymbols()):o.visible&&r.push(e),e.series.forEach(function(e){(!e.options.showInLegend||o.dataClasses)&&("point"===e.options.legendType?e.points.forEach(function(e){i(e)}):i(e))}))}),s=r.length;s--;)e.allItems.unshift(r[s])}function o(e){e.visible&&e.item.legendColor&&e.item.legendItem.symbol.attr({fill:e.item.legendColor})}function s(e){this.chart.colorAxis?.forEach(t=>{t.update({},e.redraw)})}function n(){(this.chart.colorAxis?.length||this.colorAttribs)&&this.translateColors()}function l(){let e=this.axisTypes;e?-1===e.indexOf("colorAxis")&&e.push("colorAxis"):this.axisTypes=["colorAxis"]}function a(e){let t=this,i=e?"show":"hide";t.visible=t.options.visible=!!e,["graphic","dataLabel"].forEach(function(e){t[e]&&t[e][i]()}),this.series.buildKDTree()}function h(){let e=this,t=this.getPointsCollection(),i=this.options.nullColor,r=this.colorAxis,o=this.colorKey;t.forEach(t=>{let s=t.getNestedProperty(o),n=t.options.color||(t.isNull||null===t.value?i:r&&void 0!==s?r.toColor(s,t):t.color||e.color);n&&t.color!==n&&(t.color=n,"point"===e.options.legendType&&t.legendItem&&t.legendItem.label&&e.chart.legend.colorizeItem(t,t.visible))})}function u(){this.elem.attr("fill",B(this.start).tweenTo(B(this.end),this.pos),void 0,!0)}function f(){this.elem.attr("stroke",B(this.start).tweenTo(B(this.end),this.pos),void 0,!0)}e.compose=function(e,c,d,p,g){var m;let v,x=c.prototype,y=d.prototype,b=g.prototype;x.collectionsWithUpdate.includes("colorAxis")||(t=e,x.collectionsWithUpdate.push("colorAxis"),x.collectionsWithInit.colorAxis=[x.addColorAxis],C(c,"afterCreateAxes",i),v=(m=c).prototype.createAxis,m.prototype.createAxis=function(e,i){if("colorAxis"!==e)return v.apply(this,arguments);let r=new t(this,E(i.axis,{index:this[e].length,isX:!1}));return this.isDirtyLegend=!0,this.axes.forEach(e=>{e.series=[]}),this.series.forEach(e=>{e.bindAxes(),e.isDirtyData=!0}),P(i.redraw,!0)&&this.redraw(i.animation),r},y.fillSetter=u,y.strokeSetter=f,C(p,"afterGetAllItems",r),C(p,"afterColorizeItem",o),C(p,"afterUpdate",s),U(b,{optionalAxis:"colorAxis",translateColors:h}),U(b.pointClass.prototype,{setVisible:a}),C(g,"afterTranslate",n,{order:1}),C(g,"bindAxes",l))},e.pointSetVisible=a}(n||(n={}));let T=n;var F=u(512),N=u.n(F);let{defaultOptions:V}=d(),{series:_}=N();V.colorAxis=E(V.xAxis,{lineWidth:0,minPadding:0,maxPadding:0,gridLineColor:"#ffffff",gridLineWidth:1,tickPixelInterval:72,startOnTick:!0,endOnTick:!0,offset:0,marker:{animation:{duration:50},width:.01,color:"#999999"},labels:{distance:8,overflow:"justify",rotation:0},minColor:"#e6e9ff",maxColor:"#0022ff",tickLength:5,title:{margin:5},showInLegend:!0});class D extends g(){static compose(e,t,i,r){T.compose(D,e,t,i,r)}constructor(e,t){super(e,t),this.coll="colorAxis",this.visible=!0,this.init(e,t)}init(e,t){let i=e.options.legend||{},r=t.layout?"vertical"!==t.layout:"vertical"!==i.layout;this.side=t.side||r?2:1,this.reversed=t.reversed,this.opposite=!r,super.init(e,t,"colorAxis"),this.userOptions=t,w(e.userOptions.colorAxis)&&(e.userOptions.colorAxis[this.index]=t),t.dataClasses&&this.initDataClasses(t),this.initStops(),this.horiz=r,this.zoomEnabled=!1}hasData(){return!!(this.tickPositions||[]).length}setTickPositions(){if(!this.dataClasses)return super.setTickPositions()}setOptions(e){let t=this.chart.options.legend||{},i=V.colorAxis,r=E("vertical"!==(e.layout||t.layout||i.layout)?{title:{rotation:0}}:{title:{rotation:90,margin:10}},i,e,{showEmpty:!1,visible:this.chart.options.legend.enabled&&!1!==e.visible});super.setOptions(r),this.options.crosshair=this.options.marker}setAxisSize(){let e=this.chart,t=this.legendItem?.symbol,{width:i,height:r}=this.getSize();t&&(this.left=+t.attr("x"),this.top=+t.attr("y"),this.width=i=+t.attr("width"),this.height=r=+t.attr("height"),this.right=e.chartWidth-this.left-i,this.bottom=e.chartHeight-this.top-r,this.pos=this.horiz?this.left:this.top),this.len=(this.horiz?i:r)||D.defaultLegendLength}getOffset(){let e=this.legendItem?.group,t=this.chart.axisOffset[this.side];if(e){this.axisParent=e,super.getOffset();let i=this.chart.legend;i.allItems.forEach(function(e){e instanceof D&&e.drawLegendSymbol(i,e)}),i.render(),this.chart.getMargins(!0),this.added||(this.added=!0),this.labelLeft=0,this.labelRight=this.width,this.chart.axisOffset[this.side]=t}}setLegendColor(){let e=this.horiz,t=this.reversed,i=+!!t,r=+!t,o=e?[i,0,r,0]:[0,r,0,i];this.legendColor={linearGradient:{x1:o[0],y1:o[1],x2:o[2],y2:o[3]},stops:this.stops}}drawLegendSymbol(e,t){let i=t.legendItem||{},r=e.padding,o=e.options,s=this.options.labels,n=P(o.itemDistance,10),l=this.horiz,{width:a,height:h}=this.getSize(),u=P(o.labelPadding,l?16:30);this.setLegendColor();let f=0,c=0;if(this.options.title?.text&&!this.axisTitle){this.axisGroup||(this.axisParent=i.group,this.createGroups());let e=this.len,t=this.top,r=this.left,o=this.width;this.len=l?a:h,this.top=0,this.left=0,this.width=a,this.addTitle(!0),this.len=e,this.top=t,this.left=r,this.width=o}if(this.axisTitle){let e=this.axisTitle.getBBox();f=e.height,c=e.width}let d=this.options.title||{},p=this.axisTitle?d.margin??0:0,g=l?f+p:0;i.symbol||(i.symbol=this.chart.renderer.symbol("roundedRect").attr({r:o.symbolRadius??3,zIndex:1}).add(i.group)),i.symbol.attr({x:0,y:(e.baseline||0)-11+g,width:a,height:h}),l?(i.labelWidth=Math.max(a+r+n,c||0),i.labelHeight=h+r+u+f+p):(i.labelWidth=a+r+(s.x??s.distance??0)+(this.maxLabelLength||0)+(c||0)+p,i.labelHeight=Math.max(h+r,f||0))}getTitlePosition(e){let t=super.getTitlePosition(e),i=this.options.title?.margin??0;if(this.horiz&&e)t.y=this.top-i;else if(!this.horiz&&e){let e=this.options.labels||{},r=e.x??e.distance??0;t.x=this.left+this.width+r+(this.maxLabelLength||0)+i}return t}setState(e){this.series.forEach(function(t){t.setState(e)})}setVisible(){}getSeriesExtremes(){let e=this.series,t,i,r,o,s=e.length;for(this.dataMin=1/0,this.dataMax=-1/0;s--;){for(let n of(i=(o=e[s]).colorKey=P(o.options.colorKey,o.colorKey,o.pointValKey,o.zoneAxis,"y"),r=o[i+"Min"]&&o[i+"Max"],[i,"value","y"]))if((t=o.getColumn(n)).length)break;if(r)o.minColorValue=o[i+"Min"],o.maxColorValue=o[i+"Max"];else{let e=_.prototype.getExtremes.call(o,t);o.minColorValue=e.dataMin,o.maxColorValue=e.dataMax}null!=o.minColorValue&&null!=o.maxColorValue&&(this.dataMin=Math.min(this.dataMin,o.minColorValue),this.dataMax=Math.max(this.dataMax,o.maxColorValue)),r||_.prototype.applyExtremes.call(o)}}drawCrosshair(e,t){let i,r=this.legendItem||{},o=t?.plotX,s=t?.plotY,n=this.pos,l=this.len;t&&((i=this.toPixels(t.getNestedProperty(t.series.colorKey)))<n?i=n-2:i>n+l&&(i=n+l+2),t.plotX=i,t.plotY=this.len-i,super.drawCrosshair(e,t),t.plotX=o,t.plotY=s,this.cross&&!this.cross.addedToColorAxis&&r.group&&(this.cross.addClass("highcharts-coloraxis-marker").add(r.group),this.cross.addedToColorAxis=!0,this.chart.styledMode||"object"!=typeof this.crosshair||this.cross.attr({fill:this.crosshair.color})))}getPlotLinePath(e){let t=this.left,i=e.translatedValue,r=this.top;return"number"==typeof i&&!isNaN(i)&&i<1/0&&i>-1/0?this.horiz?[["M",i-4,r-6],["L",i+4,r-6],["L",i,r],["Z"]]:[["M",t,i],["L",t-6,i+6],["L",t-6,i-6],["Z"]]:super.getPlotLinePath(e)}update(e,t){let i=this.chart.legend;this.series.forEach(e=>{e.isDirtyData=!0}),(e.dataClasses&&i.allItems||this.dataClasses)&&this.destroyItems(),super.update(e,t),this.legendItem?.label&&(this.setLegendColor(),i.colorizeItem(this,!0))}destroyItems(){let e=this.chart,t=this.legendItem||{};if(t.label)e.legend.destroyItem(this);else if(t.labels)for(let i of t.labels)e.legend.destroyItem(i);e.isDirtyLegend=!0}destroy(){this.chart.isDirtyLegend=!0,this.destroyItems(),super.destroy(...[].slice.call(arguments))}remove(e){this.destroyItems(),super.remove(e)}getDataClassLegendSymbols(){let e,t=this,i=t.chart,r=t.legendItem&&t.legendItem.labels||[],o=i.options.legend,s=P(o.valueDecimals,-1),n=P(o.valueSuffix,""),l=e=>t.series.reduce((t,i)=>(t.push(...i.points.filter(t=>t.dataClass===e)),t),[]);return r.length||t.dataClasses.forEach((o,a)=>{let h=o.from,u=o.to,{numberFormatter:f}=i,c=!0;e="",void 0===h?e="< ":void 0===u&&(e="> "),void 0!==h&&(e+=f(h,s)+n),void 0!==h&&void 0!==u&&(e+=" - "),void 0!==u&&(e+=f(u,s)+n),r.push(U({chart:i,name:e,options:{},drawLegendSymbol:_.prototype.drawLegendSymbol,visible:!0,isDataClass:!0,setState:e=>{for(let t of l(a))t.setState(e)},setVisible:function(){this.visible=c=t.visible=!c;let e=[];for(let t of l(a))t.setVisible(c),t.hiddenInDataClass=!c,-1===e.indexOf(t.series)&&e.push(t.series);i.legend.colorizeItem(this,c),e.forEach(e=>{!function(e,t,i,r){if(i=i||{},x?.createEvent&&(e.dispatchEvent||e.fireEvent&&e!==d())){let r=x.createEvent("Events");r.initEvent(t,!0,!0),i=U(r,i),e.dispatchEvent?e.dispatchEvent(i):e.fireEvent(t,i)}else if(e.hcEvents){i.target||U(i,{preventDefault:function(){i.defaultPrevented=!0},target:e,type:t});let r=[],o=e,s=!1;for(;o.hcEvents;)Object.hasOwnProperty.call(o,"hcEvents")&&o.hcEvents[t]&&(r.length&&(s=!0),r.unshift.apply(r,o.hcEvents[t])),o=Object.getPrototypeOf(o);s&&r.sort((e,t)=>e.order-t.order),r.forEach(t=>{!1===t.fn.call(e,i,e)&&i.preventDefault()})}}(e,"afterDataClassLegendClick")})}},o))}),r}getSize(){let{chart:e,horiz:t}=this,{height:i,width:r}=this.options,{legend:o}=e.options;return{width:P(null!=r?S(r,e.chartWidth):void 0,o?.symbolWidth,t?D.defaultLegendLength:12),height:P(null!=i?S(i,e.chartHeight):void 0,o?.symbolHeight,t?12:D.defaultLegendLength)}}}D.defaultLegendLength=200,D.keepProps=["legendItem"],U(D.prototype,L),Array.prototype.push.apply(g().keepProps,D.keepProps);/** * @license Highcharts JS v12.6.0 (2026-04-13) * @module highcharts/modules/color-axis * @requires highcharts * * ColorAxis module * * (c) 2012-2026 Highsoft AS * Author: Paweł Potaczek * * A commercial license may be required depending on use. * See www.highcharts.com/license */let z=d();z.ColorAxis=z.ColorAxis||D,z.ColorAxis.compose(z.Chart,z.Fx,z.Legend,z.Series);let{scatter:{prototype:{pointClass:G}}}=N().seriesTypes,j=` struct VertexInput { @location(0) pos: vec3f } struct VertexOutput { @builtin(position) pos: vec4f, @location(0) originalPos: vec3f, @location(1) valExtremes: vec2f, } @group(0) @binding(0) var<uniform> uExtremes: vec4f; @group(0) @binding(1) var<uniform> uValueExtremes: vec2f; @group(0) @binding(9) var<uniform> uIsInverted: u32; @vertex fn vertexMain(input: VertexInput) -> VertexOutput { var output: VertexOutput; let pos = input.pos; let xMin = uExtremes[0]; let xMax = uExtremes[1]; let yMin = uExtremes[2]; let yMax = uExtremes[3]; var posX: f32; var posY: f32; if (uIsInverted > 0u) { posX = (1.0 - (pos.y - yMin) / (yMax - yMin)) * 2.0 - 1.0; posY = (1.0 - (pos.x - xMin) / (xMax - xMin)) * 2.0 - 1.0; } else { posX = (pos.x - xMin) / (xMax - xMin) * 2.0 - 1.0; posY = (pos.y - yMin) / (yMax - yMin) * 2.0 - 1.0; } output.valExtremes = uValueExtremes; output.originalPos = pos.xyz; output.pos = vec4f(posX, posY, 0, 1); return output; } // ------------------------------------------------ struct FragmentInput { @location(0) originalPos: vec3f, @location(1) valExtremes: vec2f } @group(0) @binding(2) var<storage> uColorStops: array<vec4<f32>>; @group(0) @binding(3) var<uniform> uColorStopsCount: u32; @group(0) @binding(4) var<uniform> uContourInterval: f32; @group(0) @binding(5) var<uniform> uContourOffset: f32; @group(0) @binding(6) var<uniform> uSmoothColoring: u32; @group(0) @binding(7) var<uniform> uContourLineWidth: f32; @group(0) @binding(8) var<uniform> uContourLineColor: vec3f; fn getColor(value: f32) -> vec3<f32> { let stopCount = uColorStopsCount; if (stopCount == 0u) { return vec3<f32>(1.0, 1.0, 1.0); } for (var i: u32 = 0u; i < stopCount - 1u; i = i + 1u) { if (value < uColorStops[i + 1u].x) { let t = (value - uColorStops[i].x) / (uColorStops[i + 1u].x - uColorStops[i].x); return mix(uColorStops[i].yzw, uColorStops[i + 1u].yzw, t); } } return uColorStops[stopCount - 1u].yzw; } @fragment fn fragmentMain(input: FragmentInput) -> @location(0) vec4f { let val = input.originalPos.z; // Contour lines let lineWidth: f32 = uContourLineWidth; let val_dx: f32 = dpdx(val); let val_dy: f32 = dpdy(val); let gradient: f32 = length(vec2f(val_dx, val_dy)); let epsilon: f32 = max(uContourInterval * 1.0e-6, 1.0e-12); let adjustedLineWidth: f32 = lineWidth * gradient + epsilon; let adjustedVal: f32 = val - uContourOffset; let valDiv: f32 = adjustedVal / uContourInterval; let valMod: f32 = adjustedVal - uContourInterval * floor(valDiv); let lineMask: f32 = smoothstep(0.0, adjustedLineWidth, valMod) * ( 1.0 - smoothstep( uContourInterval - adjustedLineWidth, uContourInterval, valMod ) ); // Background color let minHeight: f32 = input.valExtremes.x; let maxHeight: f32 = input.valExtremes.y; var bgColor: vec3f; if (uSmoothColoring > 0u) { bgColor = getColor((val - minHeight) / (maxHeight - minHeight)); } else { let adjustedVal: f32 = val - uContourOffset; let averageValInBand: f32 = floor( adjustedVal / uContourInterval ) * uContourInterval + uContourOffset + uContourInterval / 2.0; bgColor = getColor( (averageValInBand - minHeight) / (maxHeight - minHeight) ); } // Mix var pixelColor = bgColor; if (lineWidth > 0.0) { pixelColor = mix(uContourLineColor, pixelColor, lineMask); } return vec4(pixelColor, 1.0); } `,{composed:k}=d();function W(e,t,i,r){return[["M",e,t],["L",e+i,t+r],["M",e+i,t],["L",e,t+r],["Z"]]}(l||(l={})).compose=function(e){0>k.indexOf("Series.CrossSymbol")&&k.push("Series.CrossSymbol")&&(e.prototype.symbols.cross=W)};let R=l,H=class{constructor(e){this.points=e;const t=e.length>>>1;this.epsilon=4*Number.EPSILON;let i=1/0,r=-1/0,o=1/0,s=-1/0;for(let n=0;n<t;n++){const t=e[n<<1],l=e[(n<<1)+1];t<i&&(i=t),t>r&&(r=t),l<o&&(o=l),l>s&&(s=l)}const n=r-i||1,l=s-o||1;this.minX=i,this.minY=o,this.invScaleX=1/n,this.invScaleY=1/l;const a=new Uint32Array(t),h=t=>(e[t<<1]-i)*this.invScaleX,u=t=>(e[(t<<1)+1]-o)*this.invScaleY;for(let e=0;e<t;e++)a[e]=e;a.sort((e,t)=>h(e)-h(t)||u(e)-u(t));let f=+!!t,c,d;for(let e=1;e<t;++e)c=a[f-1],d=a[e],(h(c)!==h(d)||u(c)!==u(d))&&(a[f++]=d);this.ids=a.subarray(0,f),this.triangles=this.triangulate()}triangulate(){let e,t,i=this.ids.length;if(i<3)return new Uint32Array(0);let r=this.points,{minX:o,minY:s,invScaleX:n,invScaleY:l}=this,a=e=>(r[e<<1]-o)*n,h=e=>(r[(e<<1)+1]-s)*l,u=(e,t,i)=>{let r=a(e),o=h(e),s=a(t)-r,n=h(t)-o,l=a(i)-r,u=h(i)-o,f=(Math.abs(s*u)+Math.abs(n*l))*this.epsilon;return s*u-n*l>f},f=(e,t,i,r)=>{if(e===r||t===r||i===r)return!1;let o=a(e)-a(r),s=h(e)-h(r),n=a(t)-a(r),l=h(t)-h(r),u=a(i)-a(r),f=h(i)-h(r),c=o*o+s*s,d=n*n+l*l,p=u*u+f*f,g=l*p-d*f,m=n*p-d*u,v=n*f-l*u,x=(Math.abs(o*g)+Math.abs(s*m)+Math.abs(c*v))*this.epsilon;return o*g-s*m+c*v>x},c=Math.max(32,8*i+7&-4),d=new Int32Array(c),p=new Int32Array(c),g=new Uint32Array(c),m=new Uint8Array(c),v=0,x=e=>p[p[e]],y=e=>x(p[e]),C=e=>g[x(e)],b=e=>p[d[y(e)]],U=e=>p[d[p[e]]],A=e=>d[x(e)],w=(e,t)=>u(e,g[t],C(t)),I=(e,t)=>u(e,C(t),g[t]),E=(e,t)=>I(C(e),t),O=(e,t)=>{(e=>{if(e<=c)return;let t=c<<1;for(;t<e;)t<<=1;let i=new Int32Array(t),r=new Int32Array(t),o=new Uint32Array(t),s=new Uint8Array(t);i.set(d),r.set(p),o.set(g),s.set(m),d=i,p=r,g=o,m=s,c=t})(v+4);let i=v,r=v+1,o=v+2,s=v+3;return v+=4,p[i]=r,p[r]=o,p[o]=s,p[s]=i,d[i]=i,d[o]=o,d[r]=s,d[s]=r,g[i]=e,g[o]=t,g[r]=0xffffffff,g[s]=0xffffffff,i},P=(e,t)=>{let i=p[d[e]],r=p[d[t]],o=d[e],s=d[r],n=d[i];d[e]=d[t],d[t]=o,d[i]=s,d[r]=n},S=(e,t)=>{let i=O(C(e),g[t]);return P(i,b(e)),P(x(i),t),i},M=e=>{P(e,U(e));let t=x(e);P(t,U(t))},L=this.ids,B=(e,t)=>{let i=t-e;if(2===i){let t=O(L[e],L[e+1]);return[t,x(t)]}if(3===i){let t=O(L[e],L[e+1]),i=O(L[e+1],L[e+2]);P(x(t),i);let r=L[e],o=L[e+1],s=L[e+2];if(u(r,o,s))return S(i,t),[t,x(i)];if(u(r,s,o)){let e=S(i,t);return[x(e),e]}return[t,x(i)]}let r=e+(i+1>>>1),o=B(e,r),s=B(r,t),n=o[0],l=o[1],a=s[0],h=s[1];for(;;)if(w(g[a],l))l=b(l);else if(I(g[l],a))a=A(a);else break;let c=S(x(a),l);for(g[l]===g[n]&&(n=x(c)),g[a]===g[h]&&(h=c);;){let e=d[x(c)];if(E(e,c))for(;f(C(c),g[c],C(e),C(d[e]));){let t=d[e];M(e),e=t}let t=U(c);if(E(t,c))for(;f(C(c),g[c],C(t),C(U(t)));){let e=U(t);M(t),t=e}if(!E(e,c)&&!E(t,c))break;c=!E(e,c)||E(t,c)&&f(C(e),g[e],g[t],C(t))?S(t,x(c)):S(x(c),x(e))}return[n,h]},T=B(0,i)[0];for(;w(C(d[T]),T);)T=d[T];let F=[T],N=0;{let e=T;do F.push(x(e)),m[e]=1,e=b(e);while(e!==T)}let V=[];for(;N<F.length;){let i=F[N++];if(!m[i]){e=i;do V.push(g[e]),m[t=x(e)]||F.push(t),m[e]=1,e=b(e);while(e!==i)}}return new Uint32Array(V)}},{seriesTypes:{scatter:Y}}=N();class q extends Y{static compose(e){R.compose(e)}getContourData(){let e=this.points,t=e.length,i=new Float32Array(3*t),r=new Float64Array(2*t);for(let o=0;o<t;o++){let{x:t,y:s=0,value:n}=e[o],l=2*o,a=3*o;r[l]=t,r[l+1]=s,i[a]=t,i[a+1]=s,i[a+2]=n??0}return[new H(r).triangles,i]}update(e,t){e=b(e,this.userOptions);let i=["smoothColoring","contourInterval","contourOffset","lineColor","lineWidth"],r=Object.keys(e).some(e=>!i.includes(e)),o=r?void 0:this.setOptions(E(this.userOptions,e)),s=!!o&&Object.keys(b(o,this.options)).some(e=>!i.includes(e));r||s?super.update(e,t):(this.options=o,this.setUniforms())}drawPoints(){let{group:e}=this;if(!e)return;this.canvas||(this.foreignObject=document.createElementNS("http://www.w3.org/2000/svg","foreignObject"),e.element.appendChild(this.foreignObject),this.canvas=document.createElement("canvas"),this.foreignObject.appendChild(this.canvas));let{canvas:t,xAxis:i,yAxis:r}=this,o=this.foreignObject,s=o.width.baseVal.value,n=o.height.baseVal.value,{devicePixelRatio:l}=window,a=i.len,h=r.len;this.chart.inverted&&([a,h]=[h,a]),s!==a&&(o.setAttribute("width",a),t.width=a*l,t.style.width=a+"px"),n!==h&&(o.setAttribute("height",h),t.height=h*l,t.style.height=h+"px"),this.renderFrame?this.renderFrame():this.run()}async run(){let e=this.chart,t=e.renderer,i=this.canvas,r=navigator.gpu,o=this.context=i.getContext("webgpu");if(!r||!o)return void(0,c.error)(37,!1,e);if(t.asyncCounter+=1,o){let e=this.device;this.adapter||(this.adapter=await r.requestAdapter()),!e&&this.adapter&&(e=this.device=await this.adapter.requestDevice());let t=r.getPreferredCanvasFormat();if(e){o.configure({device:e,format:t,colorSpace:"display-p3",alphaMode:"premultiplied",usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC});let[i,r]=this.getContourData(),{vertex:s,index:n,extremesUniform:l,valueExtremesUniform:a,contourIntervalUniform:h,contourOffsetUniform:u,smoothColoringUniform:f,lineWidthUniform:c,contourLineColor:d,colorAxisStopsCountUniform:p,colorAxisStopsUniform:g,isInvertedUniform:m}=this.buffers={vertex:e.createBuffer({size:r.byteLength,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST}),index:e.createBuffer({size:i.byteLength,usage:GPUBufferUsage.INDEX|GPUBufferUsage.COPY_DST}),extremesUniform:e.createBuffer({size:4*Float32Array.BYTES_PER_ELEMENT,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),valueExtremesUniform:e.createBuffer({size:2*Float32Array.BYTES_PER_ELEMENT,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),contourIntervalUniform:e.createBuffer({size:4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),contourOffsetUniform:e.createBuffer({size:4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),smoothColoringUniform:e.createBuffer({size:4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),lineWidthUniform:e.createBuffer({size:4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),contourLineColor:e.createBuffer({size:12,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),colorAxisStopsCountUniform:e.createBuffer({size:4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),colorAxisStopsUniform:e.createBuffer({size:64*Float32Array.BYTES_PER_ELEMENT,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),isInvertedUniform:e.createBuffer({size:4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST})};e.queue.writeBuffer(s,0,r),e.queue.writeBuffer(n,0,i);let v=e.createShaderModule({code:j}),x=e.createRenderPipeline({layout:"auto",vertex:{module:v,entryPoint:"vertexMain",buffers:[{arrayStride:12,attributes:[{format:"float32x3",offset:0,shaderLocation:0}]}]},fragment:{module:v,entryPoint:"fragmentMain",targets:[{format:t}]},primitive:{topology:"triangle-list"}}),y=e.createBindGroup({layout:x.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:l,label:"extremesUniformBuffer"}},{binding:1,resource:{buffer:a,label:"valueExtremesUniformBuffer"}},{binding:2,resource:{buffer:g,label:"colorAxisStopsBuffer"}},{binding:3,resource:{buffer:p,label:"colorAxisStopsCountBuffer"}},{binding:4,resource:{buffer:h,label:"contourIntervalUniformBuffer"}},{binding:5,resource:{buffer:u,label:"contourOffsetUniformBuffer"}},{binding:6,resource:{buffer:f,label:"smoothColoringUniformBuffer"}},{binding:7,resource:{buffer:c,label:"lineWidthUniformBuffer"}},{binding:8,resource:{buffer:d,label:"contourLineColorBuffer"}},{binding:9,resource:{buffer:m,label:"isInvertedUniformBuffer"}}]});this.renderFrame=function(){this.setUniforms(!1);let t=e.createCommandEncoder(),r=o.getCurrentTexture(),l=t.beginRenderPass({colorAttachments:[{view:r.createView(),loadOp:"clear",clearValue:[0,0,0,0],storeOp:"store"}]});l.setPipeline(x),l.setVertexBuffer(0,s),l.setIndexBuffer(n,"uint32"),l.setBindGroup(0,y),l.drawIndexed(i.length),l.end(),e.queue.submit([t.finish()])},this.renderFrame()}}t.asyncCounter--,t.asyncCounter||!e||e.hasLoaded||e.onload()}destroy(){this.canvas?.parentElement?.remove(),super.destroy()}drawGraph(){}setUniforms(e=!0){this.setFrameExtremesUniform(!1),this.setValueExtremesUniform(!1),this.setColorAxisStopsUniforms(!1),this.setContourIntervalUniform(!1),this.setContourOffsetUniform(!1),this.setSmoothColoringUniform(!1),this.setLineWidthUniform(!1),this.setContourLineColorUniform(!1),this.setIsInvertedUniform(e)}setContourIntervalUniform(e=!0){this.device&&this.buffers?.contourIntervalUniform&&(this.device.queue.writeBuffer(this.buffers.contourIntervalUniform,0,new Float32Array([this.getContourInterval()])),e&&this.renderFrame?.())}setContourOffsetUniform(e=!0){this.device&&this.buffers?.contourOffsetUniform&&(this.device.queue.writeBuffer(this.buffers.contourOffsetUniform,0,new Float32Array([this.getContourOffset()])),e&&this.renderFrame?.())}setSmoothColoringUniform(e=!0){this.device&&this.buffers?.smoothColoringUniform&&(this.device.queue.writeBuffer(this.buffers.smoothColoringUniform,0,new Float32Array([this.getSmoothColoring()])),e&&this.renderFrame?.())}setLineWidthUniform(e=!0){this.device&&this.buffers?.lineWidthUniform&&(this.device.queue.writeBuffer(this.buffers.lineWidthUniform,0,new Float32Array([this.getLineWidth()])),e&&this.renderFrame?.())}setContourLineColorUniform(e=!0){this.device&&this.buffers?.contourLineColor&&(this.device.queue.writeBuffer(this.buffers.contourLineColor,0,new Float32Array(this.getContourLineColor())),e&&this.renderFrame?.())}setFrameExtremesUniform(e=!0){this.device&&this.buffers?.extremesUniform&&(this.device.queue.writeBuffer(this.buffers.extremesUniform,0,new Float32Array(this.getFrameExtremes())),e&&this.renderFrame?.())}setValueExtremesUniform(e=!0){this.device&&this.buffers?.valueExtremesUniform&&(this.device.queue.writeBuffer(this.buffers.valueExtremesUniform,0,new Float32Array(this.getValueAxisExtremes())),e&&this.renderFrame?.())}setColorAxisStopsUniforms(e=!0){let t=this.buffers?.colorAxisStopsUniform,i=this.buffers?.colorAxisStopsCountUniform;if(this.device&&t&&i){let{array:r,length:o}=this.getColorAxisStopsData();this.device.queue.writeBuffer(t,0,r),this.device.queue.writeBuffer(i,0,new Uint32Array([o])),e&&this.renderFrame?.()}}setIsInvertedUniform(e=!0){this.device&&this.buffers?.isInvertedUniform&&(this.device.queue.writeBuffer(this.buffers.isInvertedUniform,0,new Uint32Array([+!!this.chart.inverted])),e&&this.renderFrame?.())}getContourInterval(){let e=this.options.contourInterval??(()=>{let[e,t]=this.getValueAxisExtremes();return function(e,t,i,r,o){var s,n;let l,a=e;i=P(i,Math.pow(10,Math.floor(Math.log(e)/Math.LN10)));let h=e/i;for(t||(t=[1,2,2.5,5,10]),l=0;l<t.length&&(a=t[l],!(h<=(t[l]+(t[l+1]||t[l]))/2));l++);return s=a*i,n=-Math.round(Math.log(.001)/Math.LN10),a=s>1e14?s:parseFloat(s.toPrecision(n||14))}((t-e)/10)})();return isNaN(e)||e<=0?-1:e}getContourOffset(){let e=this.options.contourOffset??0;return isNaN(e)||e<=0?0:e}getSmoothColoring(){return+!!this.options.smoothColoring}getLineWidth(){return this.userOptions.lineWidth??1}getContourLineColor(){let{lineColor:e="#000000"}=this.options;return q.rgbaAsFrac(new(v())(e).rgba)}getFrameExtremes(){let{xAxis:e,yAxis:t}=this;return[e.toValue(0,!0),e.toValue(e.len,!0),t.toValue(t.len,!0),t.toValue(0,!0)]}getValueAxisExtremes(){let e=this.valueMin;isNaN(e||NaN)&&isNaN((e=this.colorAxis?.min)||NaN)&&(e=Math.min(...this.points.map(e=>e.value||0)));let t=this.valueMax;return isNaN(t||NaN)&&isNaN((t=this.colorAxis?.max)||NaN)&&(t=Math.max(...this.points.map(e=>e.value||0))),[e||0,t||0]}getColorAxisStopsData(){let e,t=this.colorAxis?.stops;if(t)for(let i of(e=[],t)){let t=i?.color?.rgba;t&&e.push(i[0],...q.rgbaAsFrac(t))}return{array:new Float32Array(e??[0,0,0,0,1,1,1,1]),length:t?.length||2}}static rgbaAsFrac(e){return[e[0],e[1],e[2]].map(e=>e/255)}}q.defaultOptions=E(Y.defaultOptions,{colorKey:"value",clip:!1,marker:{symbol:"cross",states:{hover:{lineColor:"black"}}},states:{hover:{halo:void 0}},zIndex:0}),U(q.prototype,{pointClass:class extends G{},pointArrayMap:["y","value"],keysAffectYAxis:["y"],invertible:!1}),N().registerSeriesType("contour",q);let X=d();q.compose(X.Renderer);let K=d();return f.default})());