UNPKG

highcharts

Version:
14 lines 14.5 kB
/** * Highcharts JS v12.6.0 (2026-04-13) * @module highcharts/modules/export-data * @requires highcharts * @requires highcharts/modules/exporting * * Export data module * * (c) 2010-2026 Highsoft AS * Author: Torstein Hønsi * * A commercial license may be required depending on use. * See www.highcharts.com/license */import*as e from"../highcharts.js";var t,n={};n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let a=e.default;var o=n.n(a);let{isSafari:i,win:r,win:{document:l}}=o(),s=r.URL||r.webkitURL||r;function c(e){let t=e.replace(/filename=.*;/,"").match(/data:([^;]*)(;base64)?,([A-Z+\d\/]+)/i);if(t&&t.length>3&&r.atob&&r.ArrayBuffer&&r.Uint8Array&&r.Blob&&s.createObjectURL){let e=r.atob(t[3]),n=new r.ArrayBuffer(e.length),a=new r.Uint8Array(n);for(let t=0;t<a.length;++t)a[t]=e.charCodeAt(t);return s.createObjectURL(new r.Blob([a],{type:t[1]}))}}function d(e,t){let n=r.navigator,a=l.createElement("a");if("string"!=typeof e&&!(e instanceof String)&&n.msSaveOrOpenBlob)return void n.msSaveOrOpenBlob(e,t);if(e=""+e,n.userAgent.length>1e3)throw Error("Input too long");let o=/Edge\/\d+/.test(n.userAgent);if((i&&"string"==typeof e&&0===e.indexOf("data:application/pdf")||o||e.length>2e6)&&!(e=c(e)||""))throw Error("Failed to convert to blob");if(void 0!==a.download)a.href=e,a.download=t,l.body.appendChild(a),a.click(),l.body.removeChild(a);else try{if(!r.open(e,"chart"))throw Error("Failed to open window")}catch{r.location.href=e}}function h(e,t){let n=r.navigator,a=r.URL||r.webkitURL||r;try{if(n.msSaveOrOpenBlob&&r.MSBlobBuilder){let t=new r.MSBlobBuilder;return t.append(e),t.getBlob("image/svg+xml")}return a.createObjectURL(new r.Blob(["\uFEFF"+e],{type:t}))}catch(e){}}let p=e.default.AST;var u=n.n(p);let f=e.default.Chart;var g=n.n(f);let m={exporting:{csv:{annotations:{itemDelimiter:"; ",join:!1},columnHeaderFormatter:null,dateFormat:"%Y-%m-%d %H:%M:%S",decimalPoint:null,itemDelimiter:null,lineDelimiter:"\n"},menuItemDefinitions:{downloadCSV:{textKey:"downloadCSV",onclick:function(){this.exporting?.downloadCSV()}},downloadXLS:{textKey:"downloadXLS",onclick:function(){this.exporting?.downloadXLS()}},viewData:{textKey:"viewData",onclick:function(){this.exporting?.wrapLoading(this.exporting.toggleDataTable)}}},showExportInProgress:!0,showTable:!1,useMultiLevelHeaders:!0,useRowspanHeaders:!0},lang:{downloadCSV:"Download CSV",downloadXLS:"Download XLS",exportData:{annotationHeader:"Annotations",categoryHeader:"Category",categoryDatetimeHeader:"DateTime"},viewData:"View data table",hideData:"Hide data table",exportInProgress:"Exporting..."}},{doc:x,win:b}=o();function y(e,t,n,a={}){let i="function"==typeof e&&e.prototype||e;Object.hasOwnProperty.call(i,"hcEvents")||(i.hcEvents={});let r=i.hcEvents;o().Point&&e instanceof o().Point&&e.series&&e.series.chart&&(e.series.chart.runTrackerClick=!0);let l=e.addEventListener;l&&l.call(e,t,n,!!o().supportsPassiveEvents&&{passive:void 0===a.passive?-1!==t.indexOf("touch"):a.passive,capture:!1}),r[t]||(r[t]=[]);let s={fn:n,order:"number"==typeof a.order?a.order:1/0};return r[t].push(s),r[t].sort((e,t)=>e.order-t.order),function(){!function(e,t,n){function a(t,n){let a=e.removeEventListener;a&&a.call(e,t,n,!1)}function o(n){let o,i;if(e.nodeName){t?(o={})[t]=!0:o=n;var r=o,l=function(e,t){if(n[t])for(i=n[t].length;i--;)a(t,n[t][i].fn)};for(let e in r)Object.hasOwnProperty.call(r,e)&&l.call(r[e],r[e],e,r)}}let i="function"==typeof e&&e.prototype||e;if(Object.hasOwnProperty.call(i,"hcEvents")){let e=i.hcEvents;if(t){let i=e[t]||[];n?(e[t]=i.filter(function(e){return n!==e.fn}),a(t,n)):(o(e),e[t]=[])}else o(e),delete i.hcEvents}}(e,t,n)}}function v(e,t){let n;for(n in e||(e={}),t)e[n]=t[n];return e}function w(e,t,n,a){if(n=n||{},x?.createEvent&&(e.dispatchEvent||e.fireEvent&&e!==o())){let a=x.createEvent("Events");a.initEvent(t,!0,!0),n=v(a,n),e.dispatchEvent?e.dispatchEvent(n):e.fireEvent(t,n)}else if(e.hcEvents){n.target||v(n,{preventDefault:function(){n.defaultPrevented=!0},target:e,type:t});let a=[],o=e,i=!1;for(;o.hcEvents;)Object.hasOwnProperty.call(o,"hcEvents")&&o.hcEvents[t]&&(a.length&&(i=!0),a.unshift.apply(a,o.hcEvents[t])),o=Object.getPrototypeOf(o);i&&a.sort((e,t)=>e.order-t.order),a.forEach(t=>{!1===t.fn.call(e,n,e)&&n.preventDefault()})}a&&!n.defaultPrevented&&a.call(e,n)}let T=Array.prototype.find?function(e,t){return e.find(t)}:function(e,t){let n,a=e.length;for(n=0;n<a;n++)if(t(e[n],n))return e[n]};function D(){let e=arguments,t=e.length;for(let n=0;n<t;n++){let t=e[n];if(null!=t)return t}}let{getOptions:E,setOptions:S}=o(),{composed:L,doc:O,win:A}=o();!function(e){function t(){this.wrapLoading(()=>{let e=this.getCSV(!0);d(h(e,"text/csv")||"data:text/csv,\uFEFF"+encodeURIComponent(e),this.getFilename()+".csv")})}function n(){this.wrapLoading(()=>{let e='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head>\x3c!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>Ark1</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--\x3e<style>td{border:none;font-family: Calibri, sans-serif;} .number{mso-number-format:"0.00";} .text{ mso-number-format:"@";}</style><meta name=ProgId content=Excel.Sheet><meta charset=UTF-8></head><body>'+this.getTable(!0)+"</body></html>";d(h(e,"application/vnd.ms-excel")||"data:application/vnd.ms-excel;base64,"+A.btoa(unescape(encodeURIComponent(e))),this.getFilename()+".xls")})}function a(e){let t="",n=this.getDataRows(),a=this.options?.csv,o=D(a?.decimalPoint,a?.itemDelimiter!==","&&e?1.1.toLocaleString()[1]:"."),i=D(a?.itemDelimiter,","===o?";":","),r=a?.lineDelimiter;return n.forEach((e,a)=>{let l="",s=e.length;for(;s--;)"string"==typeof(l=e[s])&&(l=`"${l}"`),"number"==typeof l&&"."!==o&&(l=l.toString().replace(".",o)),e[s]=l;e.length=n.length?n[0].length:0,t+=e.join(i),a<n.length-1&&(t+=r)}),t}function o(e){let t,n,a=this.chart,o=a.hasParallelCoordinates,i=a.time,r=this.options?.csv||{},l=a.xAxis,s={},c=[],d=[],h=[],p=a.options.lang.exportData,u=p?.categoryHeader,f=p?.categoryDatetimeHeader,g=function(t,n,a){if(r.columnHeaderFormatter){let e=r.columnHeaderFormatter(t,n,a);if(!1!==e)return e}return!t&&u?u:!t.bindAxes&&f&&u?t.options.title&&t.options.title.text||(t.dateTime?f:u):e?{columnTitle:((a||0)>1?n:t.name)||"",topLevelColumnTitle:t.name}:t.name+((a||0)>1?" ("+n+")":"")},m=function(e,t,n){let a={},o={};return t.forEach(function(t){let i=(e.keyToAxis&&e.keyToAxis[t]||t)+"Axis",r="number"==typeof n&&!isNaN(n)&&n<1/0&&n>-1/0?e.chart[i][n]:e[i];a[t]=r&&r.categories||[],o[t]=r&&r.dateTime}),{categoryMap:a,dateTimeValueAxisMap:o}},x=function(e,t){let n=e.pointArrayMap||["y"];return e.data.some(e=>void 0!==e.y&&e.name)&&t&&!t.categories&&"name"!==e.exportKey?["x",...n]:n},b=[],y,v,E,S=0,L,O;for(L in a.series.forEach(function(t){let n=t.options.keys,a=t.xAxis,c=n||x(t,a),p=c.length,u=!t.requireSorting&&{},f=l.indexOf(a),y=m(t,c),v,w;if(!1!==t.options.includeInDataExport&&!t.options.isInternal&&!1!==t.visible){for(T(b,function(e){return e[0]===f})||b.push([f,S]),w=0;w<p;)E=g(t,c[w],c.length),h.push(E.columnTitle||E),e&&d.push(E.topLevelColumnTitle||E),w++;v={chart:t.chart,autoIncrement:t.autoIncrement,options:t.options,pointArrayMap:t.pointArrayMap,index:t.index,xAxis:t.xAxis},t.options.data?.forEach(function(e,n){let l,d,h,g={series:v};o&&(y=m(t,c,n)),t.pointClass.prototype.applyOptions.apply(g,[e]);let x=t.data[n]&&t.data[n].name;if(l=(g.x??"")+","+x,w=0,(!a||"name"===t.exportKey||!o&&a&&a.hasNames&&x)&&(l=x),u&&(u[l]&&(l+="|"+n),u[l]=!0),s[l]){let e=`${l},${s[l].pointers[t.index]}`,n=l;s[l].pointers[t.index]&&(s[e]||(s[e]=[],s[e].xValues=[],s[e].pointers=[]),l=e),s[n].pointers[t.index]+=1}else{s[l]=[],s[l].xValues=[];let e=[];for(let n=0;n<t.chart.series.length;n++)e[n]=0;s[l].pointers=e,s[l].pointers[t.index]=1}for(s[l].x=g.x,s[l].name=x,s[l].xValues[f]=g.x;w<p;)d=c[w],h=t.pointClass.prototype.getNestedProperty.apply(g,[d]),s[l][S+w]=D(y.categoryMap[d][h],y.dateTimeValueAxisMap[d]?i.dateFormat(r.dateFormat,h):null,h),w++}),S+=w}}),s)Object.hasOwnProperty.call(s,L)&&c.push(s[L]);for(v=e?[d,h]:[h],S=b.length;S--;)t=b[S][0],n=b[S][1],y=l[t],c.sort(function(e,n){return e.xValues[t]-n.xValues[t]}),O=g(y),v[0].splice(n,0,O),e&&v[1]&&v[1].splice(n,0,O),c.forEach(function(e){let t=e.name;y&&null==t&&(y.dateTime?(e.x instanceof Date&&(e.x=e.x.getTime()),t=i.dateFormat(r.dateFormat,e.x)):t=y.categories?D(y.names[e.x],y.categories[e.x],e.x):e.x),e.splice(n,0,t)});return w(a,"exportData",{dataRows:v=v.concat(c)}),v}function i(e){let t=e=>{if(!e.tagName||"#text"===e.tagName)return e.textContent||"";let n=e.attributes,a=`<${e.tagName}`;return n&&Object.keys(n).forEach(e=>{let t=n[e];a+=` ${e}="${t}"`}),a+=">",a+=e.textContent||"",(e.children||[]).forEach(e=>{a+=t(e)}),a+=`</${e.tagName}>`};return t(this.getTableAST(e))}function r(e){let t=0,n=[],a=this,o=a.chart,i=o.options,r=e?1.1.toLocaleString()[1]:".",l=D(a.options.useMultiLevelHeaders,!0),s=a.getDataRows(l),c=l?s.shift():null,d=s.shift(),h=function(e,t){let n=e.length;if(t.length!==n)return!1;for(;n--;)if(e[n]!==t[n])return!1;return!0},p=function(e,t,n,a){let i=D(a,""),l="highcharts-text"+(t?" "+t:"");return"number"==typeof i?(i=o.numberFormatter(i,-1,r,"th"===e?"":void 0),l="highcharts-number"):a||(l="highcharts-empty"),{tagName:e,attributes:n=v({class:l},n),textContent:i}},{tableCaption:u}=a.options||{};!1!==u&&n.push({tagName:"caption",attributes:{class:"highcharts-table-caption"},textContent:"string"==typeof u?u:i.title?.text||i.lang.chartTitle});for(let e=0,n=s.length;e<n;++e)s[e].length>t&&(t=s[e].length);n.push(function(e,t,n){let o=[],i=0,r=n||t&&t.length,s,c=0,d;if(l&&e&&t&&!h(e,t)){let n=[];for(;i<r;++i)if((s=e[i])===e[i+1])++c;else if(c)n.push(p("th","highcharts-table-topheading",{scope:"col",colspan:c+1},s)),c=0;else{s===t[i]?a.options.useRowspanHeaders?(d=2,delete t[i]):(d=1,t[i]=""):d=1;let e=p("th","highcharts-table-topheading",{scope:"col"},s);d>1&&e.attributes&&(e.attributes.valign="top",e.attributes.rowspan=d),n.push(e)}o.push({tagName:"tr",children:n})}if(t){let e=[];for(i=0,r=t.length;i<r;++i)void 0!==t[i]&&e.push(p("th",null,{scope:"col"},t[i]));o.push({tagName:"tr",children:e})}return{tagName:"thead",children:o}}(c,d||[],Math.max(t,d?.length||0)));let f=[];s.forEach(function(e){let n=[];for(let a=0;a<t;a++)n.push(p(a?"td":"th",null,a?{}:{scope:"row"},e[a]));f.push({tagName:"tr",children:n})}),n.push({tagName:"tbody",children:f});let g={tree:{tagName:"table",id:`highcharts-data-table-${o.index}`,children:n}};return w(o,"afterGetTableAST",g),g.tree}function l(){this.toggleDataTable(!1)}function s(e){let t=this.chart,n=(e=D(e,!this.isDataTableVisible))&&!this.dataTableDiv;if(n&&(this.dataTableDiv=O.createElement("div"),this.dataTableDiv.className="highcharts-data-table",t.renderTo.parentNode.insertBefore(this.dataTableDiv,t.renderTo.nextSibling)),this.dataTableDiv){let a=this.dataTableDiv.style,o=a.display;a.display=e?"block":"none",e?(this.dataTableDiv.innerHTML=u().emptyHTML,new(u())([this.getTableAST()]).addToDOM(this.dataTableDiv),w(t,"afterViewData",{element:this.dataTableDiv,wasHidden:n||o!==a.display})):w(t,"afterHideData")}this.isDataTableVisible=e;let a=this.divElements,o=this.options,i=o.buttons?.contextButton.menuItems,r=t.options.lang;if(o&&o.menuItemDefinitions&&r&&r.viewData&&r.hideData&&i&&a){let e=a[i.indexOf("viewData")];e&&u().setElementHTML(e,this.isDataTableVisible?r.hideData:r.viewData)}}function c(){this.toggleDataTable(!0)}function p(e){let t=this.chart,n=!!this.options.showExportInProgress,a=A.requestAnimationFrame||setTimeout;a(()=>{n&&t.showLoading(t.options.lang.exportInProgress),a(()=>{try{e.call(this)}finally{n&&t.hideLoading()}})})}function f(){let e=this.exporting,t=e?.dataTableDiv,n=(e,t)=>e.children[t].textContent;if(t&&e.options.allowTableSorting){let a=t.querySelector("thead tr");a&&a.childNodes.forEach(a=>{let o=t.querySelector("tbody");a.addEventListener("click",function(){let i=[...t.querySelectorAll("tr:not(thead tr)")],r=[...a.parentNode.children];if(e){let t,l;i.sort((t=r.indexOf(a),l=e.ascendingOrderInTable=!e.ascendingOrderInTable,(e,a)=>{let o,i;return o=n(l?e:a,t),i=n(l?a:e,t),""===o||""===i||isNaN(o)||isNaN(i)?o.toString().localeCompare(i):o-i})).forEach(e=>{o?.appendChild(e)}),r.forEach(e=>{["highcharts-sort-ascending","highcharts-sort-descending"].forEach(t=>{e.classList.contains(t)&&e.classList.remove(t)})}),a.classList.add(e.ascendingOrderInTable?"highcharts-sort-ascending":"highcharts-sort-descending")}})})}}function x(){this.options?.exporting?.showTable&&!this.options.chart.forExport&&this.exporting?.viewData()}function b(){this.exporting?.dataTableDiv?.remove()}e.compose=function(e,d,h){var u;if(u="ExportData",!(0>L.indexOf(u)&&L.push(u)))return;v(g().prototype,{downloadCSV:function(){return this.exporting?.downloadCSV()},downloadXLS:function(){return this.exporting?.downloadXLS()},getCSV:function(e){return this.exporting?.getCSV(e)},getDataRows:function(e){return this.exporting?.getDataRows(e)},getTable:function(e){return this.exporting?.getTable(e)},getTableAST:function(e){return this.exporting?.getTableAST(e)},hideData:function(){return this.exporting?.hideData()},toggleDataTable:function(e){return this.exporting?.toggleDataTable(e)},viewData:function(){return this.exporting?.viewData()}});let w=d.prototype;if(!w.downloadCSV){y(e,"afterViewData",f),y(e,"render",x),y(e,"destroy",b),w.downloadCSV=t,w.downloadXLS=n,w.getCSV=a,w.getDataRows=o,w.getTable=i,w.getTableAST=r,w.hideData=l,w.toggleDataTable=s,w.wrapLoading=p,w.viewData=c,S(m);let d=E().exporting?.buttons?.contextButton?.menuItems;d&&d.push("separator","downloadCSV","downloadXLS","viewData");let{arearange:u,gantt:g,map:v,mapbubble:T,treemap:D,xrange:L}=h.types;u&&(u.prototype.keyToAxis={low:"y",high:"y"}),g&&(g.prototype.exportKey="name",g.prototype.keyToAxis={start:"x",end:"x"}),v&&(v.prototype.exportKey="name"),T&&(T.prototype.exportKey="name"),D&&(D.prototype.exportKey="name"),L&&(L.prototype.keyToAxis={x2:"x"})}}}(t||(t={}));let C=t,k=o();k.dataURLtoBlob=k.dataURLtoBlob||c,k.downloadURL=k.downloadURL||d,C.compose(k.Chart,k.Exporting,k.Series);let V=o();export{V as default};