UNPKG

highcharts

Version:
14 lines 15.2 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 */function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(t._Highcharts,t._Highcharts.AST,t._Highcharts.Chart):"function"==typeof define&&define.amd?define("highcharts/modules/export-data",["highcharts/highcharts"],function(t){return e(t,t.AST,t.Chart)}):"object"==typeof exports?exports["highcharts/modules/export-data"]=e(t._Highcharts,t._Highcharts.AST,t._Highcharts.Chart):t.Highcharts=e(t.Highcharts,t.Highcharts.AST,t.Highcharts.Chart)}("u"<typeof window?this:window,(t,e,n)=>(()=>{"use strict";var o,a={660:t=>{t.exports=e},944:e=>{e.exports=t},960:t=>{t.exports=n}},r={};function i(t){var e=r[t];if(void 0!==e)return e.exports;var n=r[t]={exports:{}};return a[t](n,n.exports,i),n.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var l={};i.d(l,{default:()=>F});var s=i(944),c=i.n(s);let{isSafari:h,win:d,win:{document:p}}=c(),u=d.URL||d.webkitURL||d;function f(t){let e=t.replace(/filename=.*;/,"").match(/data:([^;]*)(;base64)?,([A-Z+\d\/]+)/i);if(e&&e.length>3&&d.atob&&d.ArrayBuffer&&d.Uint8Array&&d.Blob&&u.createObjectURL){let t=d.atob(e[3]),n=new d.ArrayBuffer(t.length),o=new d.Uint8Array(n);for(let e=0;e<o.length;++e)o[e]=t.charCodeAt(e);return u.createObjectURL(new d.Blob([o],{type:e[1]}))}}function g(t,e){let n=d.navigator,o=p.createElement("a");if("string"!=typeof t&&!(t instanceof String)&&n.msSaveOrOpenBlob)return void n.msSaveOrOpenBlob(t,e);if(t=""+t,n.userAgent.length>1e3)throw Error("Input too long");let a=/Edge\/\d+/.test(n.userAgent);if((h&&"string"==typeof t&&0===t.indexOf("data:application/pdf")||a||t.length>2e6)&&!(t=f(t)||""))throw Error("Failed to convert to blob");if(void 0!==o.download)o.href=t,o.download=e,p.body.appendChild(o),o.click(),p.body.removeChild(o);else try{if(!d.open(t,"chart"))throw Error("Failed to open window")}catch{d.location.href=t}}function m(t,e){let n=d.navigator,o=d.URL||d.webkitURL||d;try{if(n.msSaveOrOpenBlob&&d.MSBlobBuilder){let e=new d.MSBlobBuilder;return e.append(t),e.getBlob("image/svg+xml")}return o.createObjectURL(new d.Blob(["\uFEFF"+t],{type:e}))}catch(t){}}var x=i(660),b=i.n(x),y=i(960),v=i.n(y);let w={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:T,win:D}=c();function E(t,e,n,o={}){let a="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(a,"hcEvents")||(a.hcEvents={});let r=a.hcEvents;c().Point&&t instanceof c().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let i=t.addEventListener;i&&i.call(t,e,n,!!c().supportsPassiveEvents&&{passive:void 0===o.passive?-1!==e.indexOf("touch"):o.passive,capture:!1}),r[e]||(r[e]=[]);let l={fn:n,order:"number"==typeof o.order?o.order:1/0};return r[e].push(l),r[e].sort((t,e)=>t.order-e.order),function(){!function(t,e,n){function o(e,n){let o=t.removeEventListener;o&&o.call(t,e,n,!1)}function a(n){let a,r;if(t.nodeName){e?(a={})[e]=!0:a=n;var i=a,l=function(t,e){if(n[e])for(r=n[e].length;r--;)o(e,n[e][r].fn)};for(let t in i)Object.hasOwnProperty.call(i,t)&&l.call(i[t],i[t],t,i)}}let r="function"==typeof t&&t.prototype||t;if(Object.hasOwnProperty.call(r,"hcEvents")){let t=r.hcEvents;if(e){let r=t[e]||[];n?(t[e]=r.filter(function(t){return n!==t.fn}),o(e,n)):(a(t),t[e]=[])}else a(t),delete r.hcEvents}}(t,e,n)}}function S(t,e){let n;for(n in t||(t={}),e)t[n]=e[n];return t}function L(t,e,n,o){if(n=n||{},T?.createEvent&&(t.dispatchEvent||t.fireEvent&&t!==c())){let o=T.createEvent("Events");o.initEvent(e,!0,!0),n=S(o,n),t.dispatchEvent?t.dispatchEvent(n):t.fireEvent(e,n)}else if(t.hcEvents){n.target||S(n,{preventDefault:function(){n.defaultPrevented=!0},target:t,type:e});let o=[],a=t,r=!1;for(;a.hcEvents;)Object.hasOwnProperty.call(a,"hcEvents")&&a.hcEvents[e]&&(o.length&&(r=!0),o.unshift.apply(o,a.hcEvents[e])),a=Object.getPrototypeOf(a);r&&o.sort((t,e)=>t.order-e.order),o.forEach(e=>{!1===e.fn.call(t,n,t)&&n.preventDefault()})}o&&!n.defaultPrevented&&o.call(t,n)}let A=Array.prototype.find?function(t,e){return t.find(e)}:function(t,e){let n,o=t.length;for(n=0;n<o;n++)if(e(t[n],n))return t[n]};function C(){let t=arguments,e=t.length;for(let n=0;n<e;n++){let e=t[n];if(null!=e)return e}}let{getOptions:O,setOptions:H}=c(),{composed:k,doc:V,win:N}=c();!function(t){function e(){this.wrapLoading(()=>{let t=this.getCSV(!0);g(m(t,"text/csv")||"data:text/csv,\uFEFF"+encodeURIComponent(t),this.getFilename()+".csv")})}function n(){this.wrapLoading(()=>{let t='<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>";g(m(t,"application/vnd.ms-excel")||"data:application/vnd.ms-excel;base64,"+N.btoa(unescape(encodeURIComponent(t))),this.getFilename()+".xls")})}function o(t){let e="",n=this.getDataRows(),o=this.options?.csv,a=C(o?.decimalPoint,o?.itemDelimiter!==","&&t?1.1.toLocaleString()[1]:"."),r=C(o?.itemDelimiter,","===a?";":","),i=o?.lineDelimiter;return n.forEach((t,o)=>{let l="",s=t.length;for(;s--;)"string"==typeof(l=t[s])&&(l=`"${l}"`),"number"==typeof l&&"."!==a&&(l=l.toString().replace(".",a)),t[s]=l;t.length=n.length?n[0].length:0,e+=t.join(r),o<n.length-1&&(e+=i)}),e}function a(t){let e,n,o=this.chart,a=o.hasParallelCoordinates,r=o.time,i=this.options?.csv||{},l=o.xAxis,s={},c=[],h=[],d=[],p=o.options.lang.exportData,u=p?.categoryHeader,f=p?.categoryDatetimeHeader,g=function(e,n,o){if(i.columnHeaderFormatter){let t=i.columnHeaderFormatter(e,n,o);if(!1!==t)return t}return!e&&u?u:!e.bindAxes&&f&&u?e.options.title&&e.options.title.text||(e.dateTime?f:u):t?{columnTitle:((o||0)>1?n:e.name)||"",topLevelColumnTitle:e.name}:e.name+((o||0)>1?" ("+n+")":"")},m=function(t,e,n){let o={},a={};return e.forEach(function(e){let r=(t.keyToAxis&&t.keyToAxis[e]||e)+"Axis",i="number"==typeof n&&!isNaN(n)&&n<1/0&&n>-1/0?t.chart[r][n]:t[r];o[e]=i&&i.categories||[],a[e]=i&&i.dateTime}),{categoryMap:o,dateTimeValueAxisMap:a}},x=function(t,e){let n=t.pointArrayMap||["y"];return t.data.some(t=>void 0!==t.y&&t.name)&&e&&!e.categories&&"name"!==t.exportKey?["x",...n]:n},b=[],y,v,w,T=0,D,E;for(D in o.series.forEach(function(e){let n=e.options.keys,o=e.xAxis,c=n||x(e,o),p=c.length,u=!e.requireSorting&&{},f=l.indexOf(o),y=m(e,c),v,D;if(!1!==e.options.includeInDataExport&&!e.options.isInternal&&!1!==e.visible){for(A(b,function(t){return t[0]===f})||b.push([f,T]),D=0;D<p;)w=g(e,c[D],c.length),d.push(w.columnTitle||w),t&&h.push(w.topLevelColumnTitle||w),D++;v={chart:e.chart,autoIncrement:e.autoIncrement,options:e.options,pointArrayMap:e.pointArrayMap,index:e.index,xAxis:e.xAxis},e.options.data?.forEach(function(t,n){let l,h,d,g={series:v};a&&(y=m(e,c,n)),e.pointClass.prototype.applyOptions.apply(g,[t]);let x=e.data[n]&&e.data[n].name;if(l=(g.x??"")+","+x,D=0,(!o||"name"===e.exportKey||!a&&o&&o.hasNames&&x)&&(l=x),u&&(u[l]&&(l+="|"+n),u[l]=!0),s[l]){let t=`${l},${s[l].pointers[e.index]}`,n=l;s[l].pointers[e.index]&&(s[t]||(s[t]=[],s[t].xValues=[],s[t].pointers=[]),l=t),s[n].pointers[e.index]+=1}else{s[l]=[],s[l].xValues=[];let t=[];for(let n=0;n<e.chart.series.length;n++)t[n]=0;s[l].pointers=t,s[l].pointers[e.index]=1}for(s[l].x=g.x,s[l].name=x,s[l].xValues[f]=g.x;D<p;)h=c[D],d=e.pointClass.prototype.getNestedProperty.apply(g,[h]),s[l][T+D]=C(y.categoryMap[h][d],y.dateTimeValueAxisMap[h]?r.dateFormat(i.dateFormat,d):null,d),D++}),T+=D}}),s)Object.hasOwnProperty.call(s,D)&&c.push(s[D]);for(v=t?[h,d]:[d],T=b.length;T--;)e=b[T][0],n=b[T][1],y=l[e],c.sort(function(t,n){return t.xValues[e]-n.xValues[e]}),E=g(y),v[0].splice(n,0,E),t&&v[1]&&v[1].splice(n,0,E),c.forEach(function(t){let e=t.name;y&&null==e&&(y.dateTime?(t.x instanceof Date&&(t.x=t.x.getTime()),e=r.dateFormat(i.dateFormat,t.x)):e=y.categories?C(y.names[t.x],y.categories[t.x],t.x):t.x),t.splice(n,0,e)});return L(o,"exportData",{dataRows:v=v.concat(c)}),v}function r(t){let e=t=>{if(!t.tagName||"#text"===t.tagName)return t.textContent||"";let n=t.attributes,o=`<${t.tagName}`;return n&&Object.keys(n).forEach(t=>{let e=n[t];o+=` ${t}="${e}"`}),o+=">",o+=t.textContent||"",(t.children||[]).forEach(t=>{o+=e(t)}),o+=`</${t.tagName}>`};return e(this.getTableAST(t))}function i(t){let e=0,n=[],o=this,a=o.chart,r=a.options,i=t?1.1.toLocaleString()[1]:".",l=C(o.options.useMultiLevelHeaders,!0),s=o.getDataRows(l),c=l?s.shift():null,h=s.shift(),d=function(t,e){let n=t.length;if(e.length!==n)return!1;for(;n--;)if(t[n]!==e[n])return!1;return!0},p=function(t,e,n,o){let r=C(o,""),l="highcharts-text"+(e?" "+e:"");return"number"==typeof r?(r=a.numberFormatter(r,-1,i,"th"===t?"":void 0),l="highcharts-number"):o||(l="highcharts-empty"),{tagName:t,attributes:n=S({class:l},n),textContent:r}},{tableCaption:u}=o.options||{};!1!==u&&n.push({tagName:"caption",attributes:{class:"highcharts-table-caption"},textContent:"string"==typeof u?u:r.title?.text||r.lang.chartTitle});for(let t=0,n=s.length;t<n;++t)s[t].length>e&&(e=s[t].length);n.push(function(t,e,n){let a=[],r=0,i=n||e&&e.length,s,c=0,h;if(l&&t&&e&&!d(t,e)){let n=[];for(;r<i;++r)if((s=t[r])===t[r+1])++c;else if(c)n.push(p("th","highcharts-table-topheading",{scope:"col",colspan:c+1},s)),c=0;else{s===e[r]?o.options.useRowspanHeaders?(h=2,delete e[r]):(h=1,e[r]=""):h=1;let t=p("th","highcharts-table-topheading",{scope:"col"},s);h>1&&t.attributes&&(t.attributes.valign="top",t.attributes.rowspan=h),n.push(t)}a.push({tagName:"tr",children:n})}if(e){let t=[];for(r=0,i=e.length;r<i;++r)void 0!==e[r]&&t.push(p("th",null,{scope:"col"},e[r]));a.push({tagName:"tr",children:t})}return{tagName:"thead",children:a}}(c,h||[],Math.max(e,h?.length||0)));let f=[];s.forEach(function(t){let n=[];for(let o=0;o<e;o++)n.push(p(o?"td":"th",null,o?{}:{scope:"row"},t[o]));f.push({tagName:"tr",children:n})}),n.push({tagName:"tbody",children:f});let g={tree:{tagName:"table",id:`highcharts-data-table-${a.index}`,children:n}};return L(a,"afterGetTableAST",g),g.tree}function l(){this.toggleDataTable(!1)}function s(t){let e=this.chart,n=(t=C(t,!this.isDataTableVisible))&&!this.dataTableDiv;if(n&&(this.dataTableDiv=V.createElement("div"),this.dataTableDiv.className="highcharts-data-table",e.renderTo.parentNode.insertBefore(this.dataTableDiv,e.renderTo.nextSibling)),this.dataTableDiv){let o=this.dataTableDiv.style,a=o.display;o.display=t?"block":"none",t?(this.dataTableDiv.innerHTML=b().emptyHTML,new(b())([this.getTableAST()]).addToDOM(this.dataTableDiv),L(e,"afterViewData",{element:this.dataTableDiv,wasHidden:n||a!==o.display})):L(e,"afterHideData")}this.isDataTableVisible=t;let o=this.divElements,a=this.options,r=a.buttons?.contextButton.menuItems,i=e.options.lang;if(a&&a.menuItemDefinitions&&i&&i.viewData&&i.hideData&&r&&o){let t=o[r.indexOf("viewData")];t&&b().setElementHTML(t,this.isDataTableVisible?i.hideData:i.viewData)}}function c(){this.toggleDataTable(!0)}function h(t){let e=this.chart,n=!!this.options.showExportInProgress,o=N.requestAnimationFrame||setTimeout;o(()=>{n&&e.showLoading(e.options.lang.exportInProgress),o(()=>{try{t.call(this)}finally{n&&e.hideLoading()}})})}function d(){let t=this.exporting,e=t?.dataTableDiv,n=(t,e)=>t.children[e].textContent;if(e&&t.options.allowTableSorting){let o=e.querySelector("thead tr");o&&o.childNodes.forEach(o=>{let a=e.querySelector("tbody");o.addEventListener("click",function(){let r=[...e.querySelectorAll("tr:not(thead tr)")],i=[...o.parentNode.children];if(t){let e,l;r.sort((e=i.indexOf(o),l=t.ascendingOrderInTable=!t.ascendingOrderInTable,(t,o)=>{let a,r;return a=n(l?t:o,e),r=n(l?o:t,e),""===a||""===r||isNaN(a)||isNaN(r)?a.toString().localeCompare(r):a-r})).forEach(t=>{a?.appendChild(t)}),i.forEach(t=>{["highcharts-sort-ascending","highcharts-sort-descending"].forEach(e=>{t.classList.contains(e)&&t.classList.remove(e)})}),o.classList.add(t.ascendingOrderInTable?"highcharts-sort-ascending":"highcharts-sort-descending")}})})}}function p(){this.options?.exporting?.showTable&&!this.options.chart.forExport&&this.exporting?.viewData()}function u(){this.exporting?.dataTableDiv?.remove()}t.compose=function(t,f,g){var m;if(m="ExportData",!(0>k.indexOf(m)&&k.push(m)))return;S(v().prototype,{downloadCSV:function(){return this.exporting?.downloadCSV()},downloadXLS:function(){return this.exporting?.downloadXLS()},getCSV:function(t){return this.exporting?.getCSV(t)},getDataRows:function(t){return this.exporting?.getDataRows(t)},getTable:function(t){return this.exporting?.getTable(t)},getTableAST:function(t){return this.exporting?.getTableAST(t)},hideData:function(){return this.exporting?.hideData()},toggleDataTable:function(t){return this.exporting?.toggleDataTable(t)},viewData:function(){return this.exporting?.viewData()}});let x=f.prototype;if(!x.downloadCSV){E(t,"afterViewData",d),E(t,"render",p),E(t,"destroy",u),x.downloadCSV=e,x.downloadXLS=n,x.getCSV=o,x.getDataRows=a,x.getTable=r,x.getTableAST=i,x.hideData=l,x.toggleDataTable=s,x.wrapLoading=h,x.viewData=c,H(w);let f=O().exporting?.buttons?.contextButton?.menuItems;f&&f.push("separator","downloadCSV","downloadXLS","viewData");let{arearange:m,gantt:b,map:y,mapbubble:v,treemap:T,xrange:D}=g.types;m&&(m.prototype.keyToAxis={low:"y",high:"y"}),b&&(b.prototype.exportKey="name",b.prototype.keyToAxis={start:"x",end:"x"}),y&&(y.prototype.exportKey="name"),v&&(v.prototype.exportKey="name"),T&&(T.prototype.exportKey="name"),D&&(D.prototype.keyToAxis={x2:"x"})}}}(o||(o={}));let R=o,P=c();P.dataURLtoBlob=P.dataURLtoBlob||f,P.downloadURL=P.downloadURL||g,R.compose(P.Chart,P.Exporting,P.Series);let F=c();return l.default})());