generated from acdh-oeaw/template-app-nuxt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into dev
- Loading branch information
Showing
5 changed files
with
113 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// @ts-nocheck | ||
/* eslint-disable */ | ||
// sadly this function is just js, so need to disable typechecker for it | ||
import zipcelx from "zipcelx"; | ||
|
||
export const HighchartsExcelDownload = (H) => { | ||
if (H.getOptions().exporting) { | ||
H.Chart.prototype.downloadXLSX = function () { | ||
const div = document.createElement("div"); | ||
let name, | ||
xlsxRows = []; | ||
div.style.display = "none"; | ||
document.body.appendChild(div); | ||
const rows = this.getDataRows(true); | ||
xlsxRows = rows.slice(1).map(function (row) { | ||
return row.map(function (column) { | ||
return { | ||
type: typeof column === "number" ? "number" : "string", | ||
value: column, | ||
}; | ||
}); | ||
}); | ||
|
||
// Get the filename, copied from the Chart.fileDownload function | ||
if (this.options.exporting.filename) { | ||
name = this.options.exporting.filename; | ||
} else if (this.title.textStr) { | ||
name = this.title.textStr.replace(/ /g, "-").toLowerCase(); | ||
} else { | ||
name = "chart"; | ||
} | ||
|
||
zipcelx({ | ||
filename: name, | ||
sheet: { | ||
data: xlsxRows, | ||
}, | ||
}); | ||
}; | ||
|
||
// Default lang string, overridable in i18n options | ||
H.getOptions().lang.downloadXLSX = "Download XLSX"; | ||
|
||
// Add the menu item handler | ||
H.getOptions().exporting.menuItemDefinitions.downloadXLSX = { | ||
textKey: "downloadXLSX", | ||
onclick: function () { | ||
this.downloadXLSX(); | ||
}, | ||
}; | ||
|
||
// Replace the menu item | ||
const menuItems = H.getOptions().exporting.buttons.contextButton.menuItems; | ||
menuItems[menuItems.indexOf("downloadXLS")] = "downloadXLSX"; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import Highcharts from "highcharts"; | ||
import ExportingDataModule from "highcharts/modules/export-data"; | ||
import ExportingModule from "highcharts/modules/exporting"; | ||
import MapsModule from "highcharts/modules/map"; | ||
import HighchartsVue from "highcharts-vue"; | ||
|
||
// In order to use Highcharts Maps we need to | ||
// wrap Highcharts with the correct module: | ||
import { HighchartsExcelDownload } from "./helpers/highchartsExcelFunction"; | ||
|
||
export default defineNuxtPlugin((nuxtApp) => { | ||
MapsModule(Highcharts); | ||
ExportingModule(Highcharts); | ||
ExportingDataModule(Highcharts); | ||
|
||
// overwrites the excel download to work propperly. this part is copied and adapted from a highcharts fiddle using that library. could be adapted to use a more maintained one, but would only recomend, if issues surface | ||
HighchartsExcelDownload(Highcharts); | ||
// @ts-ignore | ||
nuxtApp.vueApp.use(HighchartsVue, { tagName: "HighCharts" }); | ||
}); |