Нема описа
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

exporting-data.js 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. /*
  2. Highcharts JS v8.0.4 (2020-03-10)
  3. Exporting module
  4. (c) 2010-2019 Torstein Honsi
  5. License: www.highcharts.com/license
  6. */
  7. (function (c) {
  8. "object" === typeof module && module.exports ? (c["default"] = c, module.exports = c) : "function" === typeof define && define.amd ? define("highcharts/modules/export-data", ["highcharts", "highcharts/modules/exporting"], function (k) {
  9. c(k);
  10. c.Highcharts = k;
  11. return c
  12. }) : c("undefined" !== typeof Highcharts ? Highcharts : void 0)
  13. })(function (c) {
  14. function k(b, a, c, u) {
  15. b.hasOwnProperty(a) || (b[a] = u.apply(null, c))
  16. }
  17. c = c ? c._modules : {};
  18. k(c, "mixins/ajax.js", [c["parts/Globals.js"], c["parts/Utilities.js"]], function (b, a) {
  19. var c = a.merge,
  20. u = a.objectEach;
  21. b.ajax = function (b) {
  22. var a = c(!0, {
  23. url: !1,
  24. type: "get",
  25. dataType: "json",
  26. success: !1,
  27. error: !1,
  28. data: !1,
  29. headers: {}
  30. }, b);
  31. b = {
  32. json: "application/json",
  33. xml: "application/xml",
  34. text: "text/plain",
  35. octet: "application/octet-stream"
  36. };
  37. var d = new XMLHttpRequest;
  38. if (!a.url) return !1;
  39. d.open(a.type.toUpperCase(), a.url, !0);
  40. a.headers["Content-Type"] || d.setRequestHeader("Content-Type", b[a.dataType] || b.text);
  41. u(a.headers, function (a, b) {
  42. d.setRequestHeader(b, a)
  43. });
  44. d.onreadystatechange = function () {
  45. if (4 === d.readyState) {
  46. if (200 ===
  47. d.status) {
  48. var b = d.responseText;
  49. if ("json" === a.dataType) try {
  50. b = JSON.parse(b)
  51. } catch (e) {
  52. a.error && a.error(d, e);
  53. return
  54. }
  55. return a.success && a.success(b)
  56. }
  57. a.error && a.error(d, d.responseText)
  58. }
  59. };
  60. try {
  61. a.data = JSON.stringify(a.data)
  62. } catch (A) {}
  63. d.send(a.data || !0)
  64. };
  65. b.getJSON = function (a, c) {
  66. b.ajax({
  67. url: a,
  68. success: c,
  69. dataType: "json",
  70. headers: {
  71. "Content-Type": "text/plain"
  72. }
  73. })
  74. }
  75. });
  76. k(c, "mixins/download-url.js", [c["parts/Globals.js"]], function (b) {
  77. var a = b.win,
  78. c = a.navigator,
  79. u = a.document,
  80. k = a.URL || a.webkitURL || a,
  81. v = /Edge\/\d+/.test(c.userAgent);
  82. b.dataURLtoBlob = function (b) {
  83. if ((b = b.match(/data:([^;]*)(;base64)?,([0-9A-Za-z+/]+)/)) && 3 < b.length && a.atob && a.ArrayBuffer && a.Uint8Array && a.Blob && k.createObjectURL) {
  84. var d = a.atob(b[3]),
  85. c = new a.ArrayBuffer(d.length);
  86. c = new a.Uint8Array(c);
  87. for (var f = 0; f < c.length; ++f) c[f] = d.charCodeAt(f);
  88. b = new a.Blob([c], {
  89. type: b[1]
  90. });
  91. return k.createObjectURL(b)
  92. }
  93. };
  94. b.downloadURL = function (d, k) {
  95. var e = u.createElement("a");
  96. if ("string" === typeof d || d instanceof String || !c.msSaveOrOpenBlob) {
  97. if (v || 2E6 < d.length)
  98. if (d = b.dataURLtoBlob(d),
  99. !d) throw Error("Failed to convert to blob");
  100. if ("undefined" !== typeof e.download) e.href = d, e.download = k, u.body.appendChild(e), e.click(), u.body.removeChild(e);
  101. else try {
  102. var f = a.open(d, "chart");
  103. if ("undefined" === typeof f || null === f) throw Error("Failed to open window");
  104. } catch (z) {
  105. a.location.href = d
  106. }
  107. } else c.msSaveOrOpenBlob(d, k)
  108. }
  109. });
  110. k(c, "modules/export-data.src.js", [c["parts/Globals.js"], c["parts/Utilities.js"]], function (b, a) {
  111. function c(a, b) {
  112. var c = d.navigator,
  113. m = -1 < c.userAgent.indexOf("WebKit") && 0 > c.userAgent.indexOf("Chrome"),
  114. e = d.URL || d.webkitURL || d;
  115. try {
  116. if (c.msSaveOrOpenBlob && d.MSBlobBuilder) {
  117. var p = new d.MSBlobBuilder;
  118. p.append(a);
  119. return p.getBlob("image/svg+xml")
  120. }
  121. if (!m) return e.createObjectURL(new d.Blob(["\ufeff" + a], {
  122. type: b
  123. }))
  124. } catch (G) {}
  125. }
  126. var k = a.defined,
  127. F = a.extend,
  128. v = a.pick,
  129. d = b.win,
  130. A = d.document,
  131. e = b.seriesTypes,
  132. f = b.downloadURL,
  133. z = b.fireEvent;
  134. b.setOptions({
  135. exporting: {
  136. csv: {
  137. columnHeaderFormatter: null,
  138. dateFormat: "%Y-%m-%d %H:%M:%S",
  139. decimalPoint: null,
  140. itemDelimiter: null,
  141. lineDelimiter: "\n"
  142. },
  143. showTable: !1,
  144. useMultiLevelHeaders: !0,
  145. useRowspanHeaders: !0
  146. },
  147. lang: {
  148. downloadCSV: "Download CSV",
  149. downloadXLS: "Download XLS",
  150. viewData: "View data table"
  151. }
  152. });
  153. b.addEvent(b.Chart, "render", function () {
  154. this.options && this.options.exporting && this.options.exporting.showTable && !this.options.chart.forExport && this.viewData()
  155. });
  156. b.Chart.prototype.setUpKeyToAxis = function () {
  157. e.arearange && (e.arearange.prototype.keyToAxis = {
  158. low: "y",
  159. high: "y"
  160. });
  161. e.gantt && (e.gantt.prototype.keyToAxis = {
  162. start: "x",
  163. end: "x"
  164. })
  165. };
  166. b.Chart.prototype.getDataRows = function (a) {
  167. var c = this.hasParallelCoordinates,
  168. d = this.time,
  169. e = this.options.exporting && this.options.exporting.csv || {},
  170. m = this.xAxis,
  171. p = {},
  172. f = [],
  173. B = [],
  174. w = [],
  175. r, C = function (h, c, d) {
  176. if (e.columnHeaderFormatter) {
  177. var g = e.columnHeaderFormatter(h, c, d);
  178. if (!1 !== g) return g
  179. }
  180. return h ? h instanceof b.Axis ? h.options.title && h.options.title.text || (h.isDatetimeAxis ? "DateTime" : "Category") : a ? {
  181. columnTitle: 1 < d ? c : h.name,
  182. topLevelColumnTitle: h.name
  183. } : h.name + (1 < d ? " (" + c + ")" : "") : "Category"
  184. },
  185. D = function (a, c, d) {
  186. var h = {},
  187. g = {};
  188. c.forEach(function (c) {
  189. var e = (a.keyToAxis && a.keyToAxis[c] || c) +
  190. "Axis";
  191. e = b.isNumber(d) ? a.chart[e][d] : a[e];
  192. h[c] = e && e.categories || [];
  193. g[c] = e && e.isDatetimeAxis
  194. });
  195. return {
  196. categoryMap: h,
  197. dateTimeValueAxisMap: g
  198. }
  199. },
  200. g = [];
  201. var y = 0;
  202. this.setUpKeyToAxis();
  203. this.series.forEach(function (h) {
  204. var t = h.options.keys || h.pointArrayMap || ["y"],
  205. q = t.length,
  206. l = !h.requireSorting && {},
  207. k = m.indexOf(h.xAxis),
  208. f = D(h, t),
  209. n;
  210. if (!1 !== h.options.includeInDataExport && !h.options.isInternal && !1 !== h.visible) {
  211. b.find(g, function (a) {
  212. return a[0] === k
  213. }) || g.push([k, y]);
  214. for (n = 0; n < q;) r = C(h, t[n], t.length), w.push(r.columnTitle ||
  215. r), a && B.push(r.topLevelColumnTitle || r), n++;
  216. var x = {
  217. chart: h.chart,
  218. autoIncrement: h.autoIncrement,
  219. options: h.options,
  220. pointArrayMap: h.pointArrayMap
  221. };
  222. h.options.data.forEach(function (a, b) {
  223. c && (f = D(h, t, b));
  224. var g = {
  225. series: x
  226. };
  227. h.pointClass.prototype.applyOptions.apply(g, [a]);
  228. a = g.x;
  229. var m = h.data[b] && h.data[b].name;
  230. n = 0;
  231. h.xAxis && "name" !== h.exportKey || (a = m);
  232. l && (l[a] && (a += "|" + b), l[a] = !0);
  233. p[a] || (p[a] = [], p[a].xValues = []);
  234. p[a].x = g.x;
  235. p[a].name = m;
  236. for (p[a].xValues[k] = g.x; n < q;) b = t[n], m = g[b], p[a][y + n] = v(f.categoryMap[b][m],
  237. f.dateTimeValueAxisMap[b] ? d.dateFormat(e.dateFormat, m) : null, m), n++
  238. });
  239. y += n
  240. }
  241. });
  242. for (q in p) Object.hasOwnProperty.call(p, q) && f.push(p[q]);
  243. var q = a ? [B, w] : [w];
  244. for (y = g.length; y--;) {
  245. var t = g[y][0];
  246. var l = g[y][1];
  247. var x = m[t];
  248. f.sort(function (a, b) {
  249. return a.xValues[t] - b.xValues[t]
  250. });
  251. var E = C(x);
  252. q[0].splice(l, 0, E);
  253. a && q[1] && q[1].splice(l, 0, E);
  254. f.forEach(function (a) {
  255. var b = a.name;
  256. x && !k(b) && (x.isDatetimeAxis ? (a.x instanceof Date && (a.x = a.x.getTime()), b = d.dateFormat(e.dateFormat, a.x)) : b = x.categories ? v(x.names[a.x], x.categories[a.x],
  257. a.x) : a.x);
  258. a.splice(l, 0, b)
  259. })
  260. }
  261. q = q.concat(f);
  262. z(this, "exportData", {
  263. dataRows: q
  264. });
  265. return q
  266. };
  267. b.Chart.prototype.getCSV = function (a) {
  268. var b = "",
  269. c = this.getDataRows(),
  270. d = this.options.exporting.csv,
  271. e = v(d.decimalPoint, "," !== d.itemDelimiter && a ? (1.1).toLocaleString()[1] : "."),
  272. m = v(d.itemDelimiter, "," === e ? ";" : ","),
  273. k = d.lineDelimiter;
  274. c.forEach(function (a, d) {
  275. for (var f, n = a.length; n--;) f = a[n], "string" === typeof f && (f = '"' + f + '"'), "number" === typeof f && "." !== e && (f = f.toString().replace(".", e)), a[n] = f;
  276. b += a.join(m);
  277. d < c.length - 1 && (b +=
  278. k)
  279. });
  280. return b
  281. };
  282. b.Chart.prototype.getTable = function (a) {
  283. var b = '<table id="highcharts-data-table-' + this.index + '">',
  284. c = this.options,
  285. d = a ? (1.1).toLocaleString()[1] : ".",
  286. e = v(c.exporting.useMultiLevelHeaders, !0);
  287. a = this.getDataRows(e);
  288. var f = 0,
  289. k = e ? a.shift() : null,
  290. m = a.shift(),
  291. w = function (a, b, c, e) {
  292. var g = v(e, "");
  293. b = "text" + (b ? " " + b : "");
  294. "number" === typeof g ? (g = g.toString(), "," === d && (g = g.replace(".", d)), b = "number") : e || (b = "empty");
  295. return "<" + a + (c ? " " + c : "") + ' class="' + b + '">' + g + "</" + a + ">"
  296. };
  297. !1 !== c.exporting.tableCaption && (b +=
  298. '<caption class="highcharts-table-caption">' + v(c.exporting.tableCaption, c.title.text ? c.title.text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;").replace(/\//g, "&#x2F;") : "Chart") + "</caption>");
  299. for (var r = 0, u = a.length; r < u; ++r) a[r].length > f && (f = a[r].length);
  300. b += function (a, b, d) {
  301. var f = "<thead>",
  302. g = 0;
  303. d = d || b && b.length;
  304. var l, k = 0;
  305. if (l = e && a && b) {
  306. a: if (l = a.length, b.length === l) {
  307. for (; l--;)
  308. if (a[l] !== b[l]) {
  309. l = !1;
  310. break a
  311. } l = !0
  312. } else l = !1;l = !l
  313. }
  314. if (l) {
  315. for (f += "<tr>"; g <
  316. d; ++g) {
  317. l = a[g];
  318. var m = a[g + 1];
  319. l === m ? ++k : k ? (f += w("th", "highcharts-table-topheading", 'scope="col" colspan="' + (k + 1) + '"', l), k = 0) : (l === b[g] ? c.exporting.useRowspanHeaders ? (m = 2, delete b[g]) : (m = 1, b[g] = "") : m = 1, f += w("th", "highcharts-table-topheading", 'scope="col"' + (1 < m ? ' valign="top" rowspan="' + m + '"' : ""), l))
  320. }
  321. f += "</tr>"
  322. }
  323. if (b) {
  324. f += "<tr>";
  325. g = 0;
  326. for (d = b.length; g < d; ++g) "undefined" !== typeof b[g] && (f += w("th", null, 'scope="col"', b[g]));
  327. f += "</tr>"
  328. }
  329. return f + "</thead>"
  330. }(k, m, Math.max(f, m.length));
  331. b += "<tbody>";
  332. a.forEach(function (a) {
  333. b +=
  334. "<tr>";
  335. for (var c = 0; c < f; c++) b += w(c ? "td" : "th", null, c ? "" : 'scope="row"', a[c]);
  336. b += "</tr>"
  337. });
  338. b += "</tbody></table>";
  339. a = {
  340. html: b
  341. };
  342. z(this, "afterGetTable", a);
  343. return a.html
  344. };
  345. b.Chart.prototype.downloadCSV = function () {
  346. var a = this.getCSV(!0);
  347. f(c(a, "text/csv") || "data:text/csv,\ufeff" + encodeURIComponent(a), this.getFilename() + ".csv")
  348. };
  349. b.Chart.prototype.downloadXLS = function () {
  350. var a = '<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>' +
  351. this.getTable(!0) + "</body></html>";
  352. f(c(a, "application/vnd.ms-excel") || "data:application/vnd.ms-excel;base64," + d.btoa(unescape(encodeURIComponent(a))), this.getFilename() + ".xls")
  353. };
  354. b.Chart.prototype.viewData = function () {
  355. this.dataTableDiv || (this.dataTableDiv = A.createElement("div"), this.dataTableDiv.className = "highcharts-data-table", this.renderTo.parentNode.insertBefore(this.dataTableDiv, this.renderTo.nextSibling));
  356. this.dataTableDiv.innerHTML = this.getTable();
  357. z(this, "afterViewData", this.dataTableDiv)
  358. };
  359. if (a =
  360. b.getOptions().exporting) F(a.menuItemDefinitions, {
  361. downloadCSV: {
  362. textKey: "downloadCSV",
  363. onclick: function () {
  364. this.downloadCSV()
  365. }
  366. },
  367. downloadXLS: {
  368. textKey: "downloadXLS",
  369. onclick: function () {
  370. this.downloadXLS()
  371. }
  372. },
  373. viewData: {
  374. textKey: "viewData",
  375. onclick: function () {
  376. this.viewData()
  377. }
  378. }
  379. }), a.buttons && a.buttons.contextButton.menuItems.push("separator", "downloadCSV", "downloadXLS", "viewData");
  380. e.map && (e.map.prototype.exportKey = "name");
  381. e.mapbubble && (e.mapbubble.prototype.exportKey = "name");
  382. e.treemap && (e.treemap.prototype.exportKey =
  383. "name")
  384. });
  385. k(c, "masters/modules/export-data.src.js", [], function () {})
  386. });
  387. //# sourceMappingURL=export-data.js.map