Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ctot-nondef committed Dec 11, 2023
2 parents e5e8cce + d18e7ff commit e80be19
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"html-to-text": "^9.0.5",
"pinia": "^2.1.7",
"vue-highlight-words": "^3.0.1",
"vue-json-viewer": "3"
"vue-json-viewer": "3",
"zipcelx": "^1.6.2"
},
"devDependencies": {
"@acdh-oeaw/eslint-config": "^1.0.0",
Expand Down
46 changes: 46 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/components/DataDisplay/KWICDetailDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ watch(active, async () => {
});
const parsedText = computed(() => {
if (!details.value) return "not loaded yet, lol";
if (!details.value?.content) return "not loaded yet.";
const html = details.value.content.map((a) => a.str).join(" ");
const text = convert(html.replaceAll("</p>", "</p>\n\n"), { preserveNewlines: true });
return text;
Expand Down
56 changes: 56 additions & 0 deletions src/plugins/helpers/highchartsExcelFunction.ts
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";
}
};
10 changes: 8 additions & 2 deletions src/plugins/highcharts.client.ts
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" });
});

0 comments on commit e80be19

Please sign in to comment.