All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.modules.data.js Maven / Gradle / Ivy

The newest version!
!/**
 * Highcharts JS v11.4.8 (2024-08-29)
 *
 * Data module
 *
 * (c) 2012-2024 Torstein Honsi
 *
 * License: www.highcharts.com/license
 */function(e){"object"==typeof module&&module.exports?(e.default=e,module.exports=e):"function"==typeof define&&define.amd?define("highcharts/modules/data",["highcharts"],function(t){return e(t),e.Highcharts=t,e}):e("undefined"!=typeof Highcharts?Highcharts:void 0)}(function(e){"use strict";var t=e?e._modules:{};function s(t,s,i,a){t.hasOwnProperty(s)||(t[s]=a.apply(null,i),"function"==typeof CustomEvent&&e.win.dispatchEvent(new CustomEvent("HighchartsModuleLoaded",{detail:{path:s,module:t[s]}})))}s(t,"Core/HttpUtilities.js",[t["Core/Globals.js"],t["Core/Utilities.js"]],function(e,t){let{win:s}=e,{discardElement:i,objectEach:a}=t,n={ajax:function(e){let t={json:"application/json",xml:"application/xml",text:"text/plain",octet:"application/octet-stream"},s=new XMLHttpRequest;function i(t,s){e.error&&e.error(t,s)}if(!e.url)return!1;s.open((e.type||"get").toUpperCase(),e.url,!0),e.headers&&e.headers["Content-Type"]||s.setRequestHeader("Content-Type",t[e.dataType||"json"]||t.text),a(e.headers,function(e,t){s.setRequestHeader(t,e)}),e.responseType&&(s.responseType=e.responseType),s.onreadystatechange=function(){let t;if(4===s.readyState){if(200===s.status){if("blob"!==e.responseType&&(t=s.responseText,"json"===e.dataType))try{t=JSON.parse(t)}catch(e){if(e instanceof Error)return i(s,e)}return e.success&&e.success(t,s)}i(s,s.responseText)}},e.data&&"string"!=typeof e.data&&(e.data=JSON.stringify(e.data)),s.send(e.data)},getJSON:function(e,t){n.ajax({url:e,success:t,dataType:"json",headers:{"Content-Type":"text/plain"}})},post:function(e,t,n){let r=new s.FormData;a(t,function(e,t){r.append(t,e)}),r.append("b64","true");let{filename:o,type:l}=t;return s.fetch(e,{method:"POST",body:r,...n}).then(e=>{e.ok&&e.text().then(e=>{let t=document.createElement("a");t.href=`data:${l};base64,${e}`,t.download=o,t.click(),i(t)})})}};return n}),s(t,"Extensions/Data.js",[t["Core/Axis/Axis.js"],t["Core/Chart/Chart.js"],t["Core/Defaults.js"],t["Core/Globals.js"],t["Core/HttpUtilities.js"],t["Core/Series/Point.js"],t["Core/Series/SeriesRegistry.js"],t["Core/Utilities.js"]],function(e,t,s,i,a,n,r,o){let{getOptions:l}=s,{doc:u}=i,{ajax:h}=a,{seriesTypes:d}=r,{addEvent:p,defined:m,extend:c,fireEvent:f,isNumber:g,merge:x,objectEach:C,pick:y,splat:v}=o;function T(e){return!!(e&&(e.rowsURL||e.csvURL||e.columnsURL))}class N{static data(e,t={},s){return new N(e,t,s)}static rowsToColumns(e){let t,s,i,a,n;if(e)for(t=0,n=[],s=e.length;tt.getFullYear()-2e3?s+=1900:s+=2e3,Date.UTC(s,+e[2]-1,+e[1])},alternative:"mm/dd/YY"},"mm/dd/YY":{regex:/^(\d{1,2})[\-\/\.](\d{1,2})[\-\/\.](\d{2})$/,parser:function(e){return e?Date.UTC(+e[3]+2e3,+e[1]-1,+e[2]):NaN}}},this.chart=s,this.chartOptions=t,this.options=e,this.rawColumns=[],this.init(e,t,s)}init(e,t,s){let i=e.decimalPoint,a;t&&(this.chartOptions=t),s&&(this.chart=s),"."!==i&&","!==i&&(i=void 0),this.options=e,this.columns=e.columns||this.rowsToColumns(e.rows)||[],this.firstRowAsNames=y(e.firstRowAsNames,this.firstRowAsNames,!0),this.decimalRegex=i&&RegExp("^(-?[0-9]+)"+i+"([0-9]+)$"),void 0!==this.liveDataTimeout&&clearTimeout(this.liveDataTimeout),this.rawColumns=[],this.columns.length&&(this.dataFound(),a=!T(e)),a||(a=this.fetchLiveData()),a||(a=!!this.parseCSV().length),a||(a=!!this.parseTable().length),a||(a=this.parseGoogleSpreadsheet()),!a&&e.afterComplete&&e.afterComplete(this)}getColumnDistribution(){let e=this.chartOptions,t=this.options,s=[],i=function(e="line"){return(d[e].prototype.pointArrayMap||[0]).length},a=function(e="line"){return d[e].prototype.pointArrayMap},n=e?.chart?.type,r=[],o=[],l=t?.seriesMapping||e?.series?.map(function(){return{x:0}})||[],u=0;(e?.series||[]).forEach(e=>{r.push(i(e.type||n))}),l.forEach(e=>{s.push(e.x||0)}),0===s.length&&s.push(0),l.forEach(t=>{let s=new R,l=r[u]||i(n),h=(e?.series??[])[u]??{},d=a(h.type||n),p=d??["y"];(m(t.x)||h.isCartesian||!d)&&s.addColumnReader(t.x,"x"),C(t,function(e,t){"x"!==t&&s.addColumnReader(e,t)});for(let e=0;e=p.length)&&(h=p.length-1),i.itemDelimiter)d=i.itemDelimiter;else{let e,s,a;e=0,s=0,a=!1,p.some(function(t,i){let a=!1,n,r,l,u="";if(i>13)return!0;for(let i=0;io[","]?a=";":(o[","],o[";"],a=","),i.decimalPoint||(e>s?i.decimalPoint=".":i.decimalPoint=",",t.decimalRegex=RegExp("^(-?[0-9]+)"+i.decimalPoint+"([0-9]+)$")),d=a}let e=0;for(m=u;m<=h;m++)"#"===p[m][0]?e++:function(e,t,o,l){let u=0,h="",p="",m="",c="",f=0,g=0;function x(t){h=e[t],p=e[t-1],m=e[t+1]}function C(e){r.lengthf||f>n){++f,c="";return}i.columnTypes||(!isNaN(parseFloat(c))&&isFinite(c)?(c=parseFloat(c),C("number")):isNaN(Date.parse(c))?C("string"):(c=c.replace(/\//g,"-"),C("date"))),s.lengthe.length)&&(s=e.length);h31?o[p]<100?l[p]="YY":l[p]="YYYY":o[p]>12&&o[p]<=31?(l[p]="dd",d=!0):l[p].length||(l[p]="mm")));if(d){for(p=0;p12&&"YY"!==l[p]&&"YYYY"!==l[p]&&(l[p]="YY"):r[p]>12&&"mm"===l[p]&&(l[p]="dd");return(3===l.length&&"dd"===l[1]&&"dd"===l[2]&&(l[2]="YY"),u=l.join("/"),(i.dateFormats||t.dateFormats)[u])?u:(f(t,"deduceDateFailed"),a)}return a}(s[0])),this.dataFound()}return s}parseTable(){let e=this.options,t=this.columns||[],s=e.startRow||0,i=e.endRow||Number.MAX_VALUE,a=e.startColumn||0,n=e.endColumn||Number.MAX_VALUE;if(e.table){let r=e.table;"string"==typeof r&&(r=u.getElementById(r)),[].forEach.call(r.getElementsByTagName("tr"),(e,r)=>{r>=s&&r<=i&&[].forEach.call(e.children,(e,i)=>{let o=t[i-a],l=1;if(("TD"===e.tagName||"TH"===e.tagName)&&i>=a&&i<=n)for(t[i-a]||(t[i-a]=[]),t[i-a][r-s]=e.innerHTML;r-s>=l&&void 0===o[r-s-l];)o[r-s-l]=null,l++})}),this.dataFound()}return t}fetchLiveData(){let e=this,t=this.chart,s=this.options,i=s.enablePolling,a=x(s),n=0,r=1e3*(s.dataRefreshRate||2);return!!T(s)&&(r<1e3&&(r=1e3),delete s.csvURL,delete s.rowsURL,delete s.columnsURL,function o(l){function u(a,u,d){if(!a||!/^(http|\/|\.\/|\.\.\/)/.test(a))return a&&s.error&&s.error("Invalid URL"),!1;function p(){i&&t.liveDataURL===a&&(e.liveDataTimeout=setTimeout(o,r))}return l&&(clearTimeout(e.liveDataTimeout),t.liveDataURL=a),h({url:a,dataType:d||"json",success:function(e){t?.series&&u(e),p()},error:function(e,t){return++n<3&&p(),s.error?.(t,e)}}),!0}u(a.csvURL,function(e){t.update({data:{csv:e}})},"text")||u(a.rowsURL,function(e){t.update({data:{rows:e}})})||u(a.columnsURL,function(e){t.update({data:{columns:e}})})}(!0),T(s))}parseGoogleSpreadsheet(){let e=this,t=this.options,s=t.googleSpreadsheetKey,i=this.chart,a=Math.max(1e3*(t.dataRefreshRate||2),4e3),n=()=>{if(t.googleSpreadsheetRange)return t.googleSpreadsheetRange;let e="ABCDEFGHIJKLMNOPQRSTUVWXYZ",s=(e.charAt(t.startColumn||0)||"A")+((t.startRow||0)+1),i=e.charAt(y(t.endColumn,-1))||"ZZ";return m(t.endRow)&&(i+=t.endRow+1),`${s}:${i}`};return s&&(delete t.googleSpreadsheetKey,function i(r){h({url:["https://sheets.googleapis.com/v4/spreadsheets",s,"values",n(),"?alt=json&majorDimension=COLUMNS&valueRenderOption=UNFORMATTED_VALUE&dateTimeRenderOption=FORMATTED_STRING&key="+t.googleAPIKey].join("/"),dataType:"json",success:function(s){r(s),t.enablePolling&&(e.liveDataTimeout=setTimeout(function(){i(r)},a))},error:function(e,s){return t.error?.(s,e)}})}(function(t){let s=t.values;if(!s||0===s.length)return!1;let a=s.reduce((e,t)=>Math.max(e,t.length),0);s.forEach(e=>{for(let t=0;t31536e6&&"float"!==l?e.isDatetime=!0:e.isNumeric=!0,void 0!==e[d+1]&&(T=c>e[d+1])):(f?.length&&(C=this.parseDate(p)),n&&g(C)&&"float"!==l?(r[d]=p,e[d]=C,e.isDatetime=!0,void 0!==e[d+1]&&((y=C>e[d+1])!==T&&void 0!==T&&(this.alternativeFormat?(this.dateFormat=this.alternativeFormat,d=e.length,this.alternativeFormat=this.dateFormats[this.dateFormat].alternative):e.unsorted=!0),T=y)):(e[d]=""===f?null:f,0!==d&&(e.isDatetime||e.isNumeric)&&(e.mixed=!0)));if(n&&e.mixed&&(i[t]=s[t]),n&&T&&this.options.sort){for(t=0;t0;){for((d=new R).addColumnReader(0,"x"),-1!==(f=p.indexOf(0))&&p.splice(f,1),r=0;r0&&s[0].readers.length>0&&void 0!==(c=e?.[s[0].readers[0].columnIndex??-1])&&(c.isDatetime?i="datetime":c.isNumeric||(i="category")),"category"===i)for(u=0;u{void 0===t.columnIndex&&(t.columnIndex=e.shift())}),this.readers.forEach(e=>{void 0===e.columnIndex&&(t=!1)}),t}read(e,t){let s=this.pointIsArray,i=s?[]:{};if(this.readers.forEach(a=>{let r=e[a.columnIndex][t];s?i.push(r):a.configName.indexOf(".")>0?n.prototype.setNestedProperty(i,r,a.configName):i[a.configName]=r}),void 0===this.name&&this.readers.length>=2){let t=[];this.readers.forEach(function(e){("x"===e.configName||"name"===e.configName||"y"===e.configName)&&void 0!==e.columnIndex&&t.push(e.columnIndex)}),t.length>=2&&(t.shift(),t.sort(function(e,t){return e-t})),this.name=e[y(t.shift(),0)].name}return i}addColumnReader(e,t){this.readers.push({columnIndex:e,configName:t}),"x"===t||"y"===t||void 0===t||(this.pointIsArray=!1)}getReferencedColumnIndexes(){let e,t;let s=[];for(e=0;e




© 2015 - 2024 Weber Informatics LLC | Privacy Policy