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