UNPKG

highcharts

Version:
11 lines 7.11 kB
!/** * Highcharts JS v12.6.0 (2026-04-13) * @module highcharts/modules/histogram-bellcurve * @requires highcharts * * (c) 2010-2026 Highsoft AS * Author: Sebastian Domas * * A commercial license may be required depending on use. * See www.highcharts.com/license */function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(e._Highcharts,e._Highcharts.Series,e._Highcharts.SeriesRegistry):"function"==typeof define&&define.amd?define("highcharts/modules/histogram-bellcurve",["highcharts/highcharts"],function(e){return t(e,e.Series,e.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/modules/histogram-bellcurve"]=t(e._Highcharts,e._Highcharts.Series,e._Highcharts.SeriesRegistry):e.Highcharts=t(e.Highcharts,e.Highcharts.Series,e.Highcharts.SeriesRegistry)}("u"<typeof window?this:window,(e,t,r)=>(()=>{"use strict";var s,i={512:e=>{e.exports=r},820:e=>{e.exports=t},944:t=>{t.exports=e}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return i[e](r,r.exports,o),r.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var a={};o.d(a,{default:()=>H});var l=o(944),h=o.n(l),u=o(820),c=o.n(u);let{doc:p,win:d}=h();function f(e,t,r,s={}){let i="function"==typeof e&&e.prototype||e;Object.hasOwnProperty.call(i,"hcEvents")||(i.hcEvents={});let n=i.hcEvents;h().Point&&e instanceof h().Point&&e.series&&e.series.chart&&(e.series.chart.runTrackerClick=!0);let o=e.addEventListener;o&&o.call(e,t,r,!!h().supportsPassiveEvents&&{passive:void 0===s.passive?-1!==t.indexOf("touch"):s.passive,capture:!1}),n[t]||(n[t]=[]);let a={fn:r,order:"number"==typeof s.order?s.order:1/0};return n[t].push(a),n[t].sort((e,t)=>e.order-t.order),function(){!function(e,t,r){function s(t,r){let s=e.removeEventListener;s&&s.call(e,t,r,!1)}function i(r){let i,n;e.nodeName&&(t?(i={})[t]=!0:i=r,D(i,function(e,t){if(r[t])for(n=r[t].length;n--;)s(t,r[t][n].fn)}))}let n="function"==typeof e&&e.prototype||e;if(Object.hasOwnProperty.call(n,"hcEvents")){let e=n.hcEvents;if(t){let n=e[t]||[];r?(e[t]=n.filter(function(e){return r!==e.fn}),s(t,r)):(i(e),e[t]=[])}else i(e),delete n.hcEvents}}(e,t,r)}}function v(e,t){return e>1e14?e:parseFloat(e.toPrecision(t||14))}function y(e){return g(e)&&"number"==typeof e.nodeType}function b(e){return"number"==typeof e&&!isNaN(e)&&e<1/0&&e>-1/0}function g(e,t){let r;return!!e&&"object"==typeof e&&(!t||"[object Array]"!==(r=Object.prototype.toString.call(e))&&"[object Array Iterator]"!==r)}function m(e,...t){let r,s=[e,...t],i={},n=function(e,t){return"object"!=typeof e&&(e={}),D(t,function(r,s){if("__proto__"!==s&&"constructor"!==s){let i;!g(r,!0)||(i=r?.constructor,g(r,!0)&&!y(r)&&i?.name&&"Object"!==i.name)||y(r)?e[s]=t[s]:e[s]=n(e[s]||{},r)}}),e};!0===e&&(i=s[1],s=Array.prototype.slice.call(s,2));let o=s.length;for(r=0;r<o;r++)i=n(i,s[r]);return i}function D(e,t,r){for(let s in e)Object.hasOwnProperty.call(e,s)&&t.call(r||e[s],e[s],s,e)}Array.prototype.find;let{noop:S}=h();!function(e){function t(){c().prototype.init.apply(this,arguments),this.initialised=!1,this.baseSeries=null,this.eventRemovers=[],this.addEvents()}function r(){let e=this.chart,t=this.options.baseSeries,r=null!=t&&(e.series[t]||e.get(t));this.baseSeries=r||null}function s(){this.eventRemovers.push(f(this.chart,"afterLinkSeries",()=>{this.setBaseSeries(),this.baseSeries&&!this.initialised&&(this.setDerivedData(),this.addBaseSeriesEvents(),this.initialised=!0)}))}function i(){this.eventRemovers.push(f(this.baseSeries,"updatedData",()=>{this.setDerivedData()}),f(this.baseSeries,"destroy",()=>{this.baseSeries=null,this.initialised=!1}))}function n(){this.eventRemovers.forEach(e=>{e()}),c().prototype.destroy.apply(this,arguments)}e.hasDerivedData=!0,e.setDerivedData=S,e.compose=function(e){let o=e.prototype;return o.addBaseSeriesEvents=i,o.addEvents=s,o.destroy=n,o.init=t,o.setBaseSeries=r,e},e.init=t,e.setBaseSeries=r,e.addEvents=s,e.addBaseSeriesEvents=i,e.destroy=n}(s||(s={}));let x=s;var O=o(512),E=o.n(O);let{column:M}=E().seriesTypes,j={"square-root":function(e){return Math.ceil(Math.sqrt(e.length))},sturges:function(e){return Math.ceil(Math.log(e.length)*Math.LOG2E)},rice:function(e){return Math.ceil(2*Math.pow(e.length,1/3))}};class P extends M{binsNumber(e){let t=this.options.binsNumber,r=j[t]||"function"==typeof t&&t;return Math.ceil(r&&r(e)||(b(t)?t:j["square-root"](e)))}setData(e,t=!0,r,s){let i;void 0!==e&&e.length>0&&(e=e.map(function(e){return b(e)?e:e?.y??0}),i=this.derivedData(e.filter(b),this.binsNumber(e),this.options.binWidth)),super.setData.call(this,i,t,r,s)}derivedData(e,t,r){var s;let i,n=v(function(e){let t=e.length,r=e[0];for(;t--;)e[t]>r&&(r=e[t]);return r}(e)),o=v(function(e){let t=e.length,r=e[0];for(;t--;)e[t]<r&&(r=e[t]);return r}(e)),a=[],l={},h=[];for(r=this.binWidth=v(b(r)?r||1:(n-o)/t),this.options.pointRange=Math.max(r,0),i=o;i<n&&(this.userOptions.binWidth||v(n-i)>=r||0>=v(v(o+a.length*r)-i));i=v(i+r))a.push(i),l[i]=0;0!==l[o]&&(a.push(o),l[o]=0);let u=(s=a.map(e=>parseFloat(e)),function(e){let t=1;for(;s[t]<=e;)t++;return s[--t]});for(let t of e)l[v(u(t))]++;for(let e of Object.keys(l))h.push({x:Number(e),y:l[e],x2:v(Number(e)+r)});return h.sort((e,t)=>e.x-t.x),h[h.length-1].x2=n,h}setDerivedData(){let e=this.baseSeries?.getColumn("y");e?.length?this.setData(e,!1,void 0,!1):this.setData([])}}P.defaultOptions=m(M.defaultOptions,{binsNumber:"square-root",binWidth:void 0,pointPadding:0,groupPadding:0,grouping:!1,pointPlacement:"between",tooltip:{headerFormat:"",pointFormat:'<span style="font-size: 0.8em">{point.x} - {point.x2}</span><br/><span style="color:{point.color}">●</span> {series.name} <b>{point.y}</b><br/>'}}),x.compose(P),E().registerSeriesType("histogram",P);let{areaspline:_}=E().seriesTypes;class w extends _{static mean(e){let t=e.length,r=e.reduce(function(e,t){return e+t},0);return t>0&&r/t}static standardDeviation(e,t){let r=e.length;t=b(t)?t:w.mean(e);let s=e.reduce((e,r)=>{let s=r-t;return e+s*s},0);return r>1&&Math.sqrt(s/(r-1))}static normalDensity(e,t,r){let s=e-t;return Math.exp(-(s*s)/(2*r*r))/(r*Math.sqrt(2*Math.PI))}setData(e,t=!0,r,s){let i;void 0!==e&&e.length>0&&(e=e.map(function(e){return b(e)?e:e?.y}).filter(b),this.setMean(e),this.setStandardDeviation(e),i=this.derivedData(this.mean||0,this.standardDeviation||0)),super.setData.call(this,i,t,r,s)}derivedData(e,t){let r=this.options,s=r.intervals,i=r.pointsInInterval,n=s*i*2+1,o=t/i,a=[],l=e-s*t;for(let r=0;r<n;r++)a.push([l,w.normalDensity(l,e,t)]),l+=o;return a}setDerivedData(){this.baseSeries?.getColumn("y").length&&this.setData(this.baseSeries?.getColumn("y"),!1,void 0,!1)}setMean(e){this.mean=v(w.mean(e||[]))}setStandardDeviation(e){this.standardDeviation=v(w.standardDeviation(e||[],this.mean))}}w.defaultOptions=m(_.defaultOptions,{intervals:3,pointsInInterval:3,marker:{enabled:!1}}),x.compose(w),E().registerSeriesType("bellcurve",w);let H=h();return a.default})());