UNPKG

highcharts

Version:
13 lines 14.6 kB
!/** * 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 */function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(t._Highcharts,t._Highcharts.Axis,t._Highcharts.Color,t._Highcharts.SeriesRegistry):"function"==typeof define&&define.amd?define("highcharts/modules/coloraxis",["highcharts/highcharts"],function(t){return e(t,t.Axis,t.Color,t.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/modules/coloraxis"]=e(t._Highcharts,t._Highcharts.Axis,t._Highcharts.Color,t._Highcharts.SeriesRegistry):t.Highcharts=e(t.Highcharts,t.Highcharts.Axis,t.Highcharts.Color,t.Highcharts.SeriesRegistry)}("u"<typeof window?this:window,(t,e,i,s)=>(()=>{"use strict";var o,r,l,n={512:t=>{t.exports=s},532:t=>{t.exports=e},620:t=>{t.exports=i},944:e=>{e.exports=t}},a={};function h(t){var e=a[t];if(void 0!==e)return e.exports;var i=a[t]={exports:{}};return n[t](i,i.exports,h),i.exports}h.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return h.d(e,{a:e}),e},h.d=(t,e)=>{for(var i in e)h.o(e,i)&&!h.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},h.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var c={};h.d(c,{default:()=>_});var d=h(944),p=h.n(d),f=h(532),u=h.n(f),g=h(620),m=h.n(g);let{doc:x,win:y}=p();function b(t,e,i,s={}){let o="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(o,"hcEvents")||(o.hcEvents={});let r=o.hcEvents;p().Point&&t instanceof p().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let l=t.addEventListener;l&&l.call(t,e,i,!!p().supportsPassiveEvents&&{passive:void 0===s.passive?-1!==e.indexOf("touch"):s.passive,capture:!1}),r[e]||(r[e]=[]);let n={fn:i,order:"number"==typeof s.order?s.order:1/0};return r[e].push(n),r[e].sort((t,e)=>t.order-e.order),function(){!function(t,e,i){function s(e,i){let s=t.removeEventListener;s&&s.call(t,e,i,!1)}function o(i){let o,r;t.nodeName&&(e?(o={})[e]=!0:o=i,E(o,function(t,e){if(i[e])for(r=i[e].length;r--;)s(e,i[e][r].fn)}))}let r="function"==typeof t&&t.prototype||t;if(Object.hasOwnProperty.call(r,"hcEvents")){let t=r.hcEvents;if(e){let r=t[e]||[];i?(t[e]=r.filter(function(t){return i!==t.fn}),s(e,i)):(o(t),t[e]=[])}else o(t),delete r.hcEvents}}(t,e,i)}}function v(t,e){let i;for(i in t||(t={}),e)t[i]=e[i];return t}function C(t){return I(t)&&"number"==typeof t.nodeType}function A(t){let e=Object.prototype.toString.call(t);return"[object Array]"===e||"[object Array Iterator]"===e}function I(t,e){return!!t&&"object"==typeof t&&(!e||!A(t))}function w(t,...e){let i,s=[t,...e],o={},r=function(t,e){return"object"!=typeof t&&(t={}),E(e,function(i,s){if("__proto__"!==s&&"constructor"!==s){let o;!I(i,!0)||(o=i?.constructor,I(i,!0)&&!C(i)&&o?.name&&"Object"!==o.name)||C(i)?t[s]=e[s]:t[s]=r(t[s]||{},i)}}),t};!0===t&&(o=s[1],s=Array.prototype.slice.call(s,2));let l=s.length;for(i=0;i<l;i++)o=r(o,s[i]);return o}function E(t,e,i){for(let s in t)Object.hasOwnProperty.call(t,s)&&e.call(i||t[s],t[s],s,t)}function L(){let t=arguments,e=t.length;for(let i=0;i<e;i++){let e=t[i];if(null!=e)return e}}function P(t,e,i){return/%$/.test(t)?e*parseFloat(t)/100+(i||0):parseFloat(t)}Array.prototype.find;let{parse:O}=m();(o=r||(r={})).initDataClasses=function(t){let e=this.chart,i=this.legendItem=this.legendItem||{},s=this.options,o=t.dataClasses||[],r,l,n=e.options.chart.colorCount,a=0,h;this.dataClasses=l=[],i.labels=[];for(let t=0,i=o.length;t<i;++t)r=w(r=o[t]),l.push(r),(e.styledMode||!r.color)&&("category"===s.dataClassColor?(e.styledMode||(n=(h=e.options.colors||[]).length,r.color=h[a]),r.colorIndex=a,++a===n&&(a=0)):r.color=O(s.minColor).tweenTo(O(s.maxColor),i<2?.5:t/(i-1)))},o.initStops=function(){let t=this.options,e=this.stops=t.stops||[[0,t.minColor||""],[1,t.maxColor||""]];for(let t=0,i=e.length;t<i;++t)e[t].color=O(e[t][1])},o.normalizedValue=function(t){let e=this.max||0,i=this.min||0;return this.logarithmic&&(t=this.logarithmic.log2lin(t)),1-(e-t)/(e-i||1)},o.toColor=function(t,e){let i,s,o,r,l,n,a=this.dataClasses,h=this.stops;if(a){for(n=a.length;n--;)if(s=(l=a[n]).from,o=l.to,(void 0===s||t>=s)&&(void 0===o||t<=o)){r=l.color,e&&(e.dataClass=n,e.colorIndex=l.colorIndex);break}}else{for(i=this.normalizedValue(t),n=h.length;n--&&!(i>h[n][0]););s=h[n]||h[n+1],i=1-((o=h[n+1]||s)[0]-i)/(o[0]-s[0]||1),r=s.color.tweenTo(o.color,i)}return r};let S=r,{parse:T}=m();!function(t){let e;function i(){let{userOptions:t}=this;if(this.colorAxis=[],t.colorAxis){var i;t.colorAxis=A(i=t.colorAxis)?i:[i],t.colorAxis.map(t=>new e(this,t))}}function s(t){let e=this.chart.colorAxis||[],i=e=>{let i=t.allItems.indexOf(e);-1!==i&&(this.destroyItem(t.allItems[i]),t.allItems.splice(i,1))},s=[],o,r;for(e.forEach(function(t){o=t.options,o?.showInLegend&&(o.dataClasses&&o.visible?s=s.concat(t.getDataClassLegendSymbols()):o.visible&&s.push(t),t.series.forEach(function(t){(!t.options.showInLegend||o.dataClasses)&&("point"===t.options.legendType?t.points.forEach(function(t){i(t)}):i(t))}))}),r=s.length;r--;)t.allItems.unshift(s[r])}function o(t){t.visible&&t.item.legendColor&&t.item.legendItem.symbol.attr({fill:t.item.legendColor})}function r(t){this.chart.colorAxis?.forEach(e=>{e.update({},t.redraw)})}function l(){(this.chart.colorAxis?.length||this.colorAttribs)&&this.translateColors()}function n(){let t=this.axisTypes;t?-1===t.indexOf("colorAxis")&&t.push("colorAxis"):this.axisTypes=["colorAxis"]}function a(t){let e=this,i=t?"show":"hide";e.visible=e.options.visible=!!t,["graphic","dataLabel"].forEach(function(t){e[t]&&e[t][i]()}),this.series.buildKDTree()}function h(){let t=this,e=this.getPointsCollection(),i=this.options.nullColor,s=this.colorAxis,o=this.colorKey;e.forEach(e=>{let r=e.getNestedProperty(o),l=e.options.color||(e.isNull||null===e.value?i:s&&void 0!==r?s.toColor(r,e):e.color||t.color);l&&e.color!==l&&(e.color=l,"point"===t.options.legendType&&e.legendItem&&e.legendItem.label&&t.chart.legend.colorizeItem(e,e.visible))})}function c(){this.elem.attr("fill",T(this.start).tweenTo(T(this.end),this.pos),void 0,!0)}function d(){this.elem.attr("stroke",T(this.start).tweenTo(T(this.end),this.pos),void 0,!0)}t.compose=function(t,p,f,u,g){var m;let x,y=p.prototype,C=f.prototype,A=g.prototype;y.collectionsWithUpdate.includes("colorAxis")||(e=t,y.collectionsWithUpdate.push("colorAxis"),y.collectionsWithInit.colorAxis=[y.addColorAxis],b(p,"afterCreateAxes",i),x=(m=p).prototype.createAxis,m.prototype.createAxis=function(t,i){if("colorAxis"!==t)return x.apply(this,arguments);let s=new e(this,w(i.axis,{index:this[t].length,isX:!1}));return this.isDirtyLegend=!0,this.axes.forEach(t=>{t.series=[]}),this.series.forEach(t=>{t.bindAxes(),t.isDirtyData=!0}),L(i.redraw,!0)&&this.redraw(i.animation),s},C.fillSetter=c,C.strokeSetter=d,b(u,"afterGetAllItems",s),b(u,"afterColorizeItem",o),b(u,"afterUpdate",r),v(A,{optionalAxis:"colorAxis",translateColors:h}),v(A.pointClass.prototype,{setVisible:a}),b(g,"afterTranslate",l,{order:1}),b(g,"bindAxes",n))},t.pointSetVisible=a}(l||(l={}));let M=l;var z=h(512),k=h.n(z);let{defaultOptions:D}=p(),{series:j}=k();D.colorAxis=w(D.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 H extends u(){static compose(t,e,i,s){M.compose(H,t,e,i,s)}constructor(t,e){super(t,e),this.coll="colorAxis",this.visible=!0,this.init(t,e)}init(t,e){let i=t.options.legend||{},s=e.layout?"vertical"!==e.layout:"vertical"!==i.layout;this.side=e.side||s?2:1,this.reversed=e.reversed,this.opposite=!s,super.init(t,e,"colorAxis"),this.userOptions=e,A(t.userOptions.colorAxis)&&(t.userOptions.colorAxis[this.index]=e),e.dataClasses&&this.initDataClasses(e),this.initStops(),this.horiz=s,this.zoomEnabled=!1}hasData(){return!!(this.tickPositions||[]).length}setTickPositions(){if(!this.dataClasses)return super.setTickPositions()}setOptions(t){let e=this.chart.options.legend||{},i=D.colorAxis,s=w("vertical"!==(t.layout||e.layout||i.layout)?{title:{rotation:0}}:{title:{rotation:90,margin:10}},i,t,{showEmpty:!1,visible:this.chart.options.legend.enabled&&!1!==t.visible});super.setOptions(s),this.options.crosshair=this.options.marker}setAxisSize(){let t=this.chart,e=this.legendItem?.symbol,{width:i,height:s}=this.getSize();e&&(this.left=+e.attr("x"),this.top=+e.attr("y"),this.width=i=+e.attr("width"),this.height=s=+e.attr("height"),this.right=t.chartWidth-this.left-i,this.bottom=t.chartHeight-this.top-s,this.pos=this.horiz?this.left:this.top),this.len=(this.horiz?i:s)||H.defaultLegendLength}getOffset(){let t=this.legendItem?.group,e=this.chart.axisOffset[this.side];if(t){this.axisParent=t,super.getOffset();let i=this.chart.legend;i.allItems.forEach(function(t){t instanceof H&&t.drawLegendSymbol(i,t)}),i.render(),this.chart.getMargins(!0),this.added||(this.added=!0),this.labelLeft=0,this.labelRight=this.width,this.chart.axisOffset[this.side]=e}}setLegendColor(){let t=this.horiz,e=this.reversed,i=+!!e,s=+!e,o=t?[i,0,s,0]:[0,s,0,i];this.legendColor={linearGradient:{x1:o[0],y1:o[1],x2:o[2],y2:o[3]},stops:this.stops}}drawLegendSymbol(t,e){let i=e.legendItem||{},s=t.padding,o=t.options,r=this.options.labels,l=L(o.itemDistance,10),n=this.horiz,{width:a,height:h}=this.getSize(),c=L(o.labelPadding,n?16:30);this.setLegendColor();let d=0,p=0;if(this.options.title?.text&&!this.axisTitle){this.axisGroup||(this.axisParent=i.group,this.createGroups());let t=this.len,e=this.top,s=this.left,o=this.width;this.len=n?a:h,this.top=0,this.left=0,this.width=a,this.addTitle(!0),this.len=t,this.top=e,this.left=s,this.width=o}if(this.axisTitle){let t=this.axisTitle.getBBox();d=t.height,p=t.width}let f=this.options.title||{},u=this.axisTitle?f.margin??0:0,g=n?d+u: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:(t.baseline||0)-11+g,width:a,height:h}),n?(i.labelWidth=Math.max(a+s+l,p||0),i.labelHeight=h+s+c+d+u):(i.labelWidth=a+s+(r.x??r.distance??0)+(this.maxLabelLength||0)+(p||0)+u,i.labelHeight=Math.max(h+s,d||0))}getTitlePosition(t){let e=super.getTitlePosition(t),i=this.options.title?.margin??0;if(this.horiz&&t)e.y=this.top-i;else if(!this.horiz&&t){let t=this.options.labels||{},s=t.x??t.distance??0;e.x=this.left+this.width+s+(this.maxLabelLength||0)+i}return e}setState(t){this.series.forEach(function(e){e.setState(t)})}setVisible(){}getSeriesExtremes(){let t=this.series,e,i,s,o,r=t.length;for(this.dataMin=1/0,this.dataMax=-1/0;r--;){for(let l of(i=(o=t[r]).colorKey=L(o.options.colorKey,o.colorKey,o.pointValKey,o.zoneAxis,"y"),s=o[i+"Min"]&&o[i+"Max"],[i,"value","y"]))if((e=o.getColumn(l)).length)break;if(s)o.minColorValue=o[i+"Min"],o.maxColorValue=o[i+"Max"];else{let t=j.prototype.getExtremes.call(o,e);o.minColorValue=t.dataMin,o.maxColorValue=t.dataMax}null!=o.minColorValue&&null!=o.maxColorValue&&(this.dataMin=Math.min(this.dataMin,o.minColorValue),this.dataMax=Math.max(this.dataMax,o.maxColorValue)),s||j.prototype.applyExtremes.call(o)}}drawCrosshair(t,e){let i,s=this.legendItem||{},o=e?.plotX,r=e?.plotY,l=this.pos,n=this.len;e&&((i=this.toPixels(e.getNestedProperty(e.series.colorKey)))<l?i=l-2:i>l+n&&(i=l+n+2),e.plotX=i,e.plotY=this.len-i,super.drawCrosshair(t,e),e.plotX=o,e.plotY=r,this.cross&&!this.cross.addedToColorAxis&&s.group&&(this.cross.addClass("highcharts-coloraxis-marker").add(s.group),this.cross.addedToColorAxis=!0,this.chart.styledMode||"object"!=typeof this.crosshair||this.cross.attr({fill:this.crosshair.color})))}getPlotLinePath(t){let e=this.left,i=t.translatedValue,s=this.top;return"number"==typeof i&&!isNaN(i)&&i<1/0&&i>-1/0?this.horiz?[["M",i-4,s-6],["L",i+4,s-6],["L",i,s],["Z"]]:[["M",e,i],["L",e-6,i+6],["L",e-6,i-6],["Z"]]:super.getPlotLinePath(t)}update(t,e){let i=this.chart.legend;this.series.forEach(t=>{t.isDirtyData=!0}),(t.dataClasses&&i.allItems||this.dataClasses)&&this.destroyItems(),super.update(t,e),this.legendItem?.label&&(this.setLegendColor(),i.colorizeItem(this,!0))}destroyItems(){let t=this.chart,e=this.legendItem||{};if(e.label)t.legend.destroyItem(this);else if(e.labels)for(let i of e.labels)t.legend.destroyItem(i);t.isDirtyLegend=!0}destroy(){this.chart.isDirtyLegend=!0,this.destroyItems(),super.destroy(...[].slice.call(arguments))}remove(t){this.destroyItems(),super.remove(t)}getDataClassLegendSymbols(){let t,e=this,i=e.chart,s=e.legendItem&&e.legendItem.labels||[],o=i.options.legend,r=L(o.valueDecimals,-1),l=L(o.valueSuffix,""),n=t=>e.series.reduce((e,i)=>(e.push(...i.points.filter(e=>e.dataClass===t)),e),[]);return s.length||e.dataClasses.forEach((o,a)=>{let h=o.from,c=o.to,{numberFormatter:d}=i,f=!0;t="",void 0===h?t="< ":void 0===c&&(t="> "),void 0!==h&&(t+=d(h,r)+l),void 0!==h&&void 0!==c&&(t+=" - "),void 0!==c&&(t+=d(c,r)+l),s.push(v({chart:i,name:t,options:{},drawLegendSymbol:j.prototype.drawLegendSymbol,visible:!0,isDataClass:!0,setState:t=>{for(let e of n(a))e.setState(t)},setVisible:function(){this.visible=f=e.visible=!f;let t=[];for(let e of n(a))e.setVisible(f),e.hiddenInDataClass=!f,-1===t.indexOf(e.series)&&t.push(e.series);i.legend.colorizeItem(this,f),t.forEach(t=>{!function(t,e,i,s){if(i=i||{},x?.createEvent&&(t.dispatchEvent||t.fireEvent&&t!==p())){let s=x.createEvent("Events");s.initEvent(e,!0,!0),i=v(s,i),t.dispatchEvent?t.dispatchEvent(i):t.fireEvent(e,i)}else if(t.hcEvents){i.target||v(i,{preventDefault:function(){i.defaultPrevented=!0},target:t,type:e});let s=[],o=t,r=!1;for(;o.hcEvents;)Object.hasOwnProperty.call(o,"hcEvents")&&o.hcEvents[e]&&(s.length&&(r=!0),s.unshift.apply(s,o.hcEvents[e])),o=Object.getPrototypeOf(o);r&&s.sort((t,e)=>t.order-e.order),s.forEach(e=>{!1===e.fn.call(t,i,t)&&i.preventDefault()})}}(t,"afterDataClassLegendClick")})}},o))}),s}getSize(){let{chart:t,horiz:e}=this,{height:i,width:s}=this.options,{legend:o}=t.options;return{width:L(null!=s?P(s,t.chartWidth):void 0,o?.symbolWidth,e?H.defaultLegendLength:12),height:L(null!=i?P(i,t.chartHeight):void 0,o?.symbolHeight,e?12:H.defaultLegendLength)}}}H.defaultLegendLength=200,H.keepProps=["legendItem"],v(H.prototype,S),Array.prototype.push.apply(u().keepProps,H.keepProps);let V=p();V.ColorAxis=V.ColorAxis||H,V.ColorAxis.compose(V.Chart,V.Fx,V.Legend,V.Series);let _=p();return c.default})());