dmoxin
Posts: 5
Joined: Fri Apr 16, 2021 4:38 pm

Multiple maps per page causes download option to fail

Should I be able to run two different Highchart maps on the same page and have the ‘Download CSV’ and ‘Download XLS’ options work? Both maps will display and respond as expected to all other mouse events. All functionality of each map, including the download options, works when only one of the maps appears on a page. When combined on a page, I receive a js error when selecting a download option:

Uncaught TypeError: Cannot read property 'name' of undefined
at columnHeaderFormatter (?sc_itemid={1C6CB255-E483-4187-91B5-9B7206DCECD5}&sc_mode=preview&sc_lang=en&sc_site=mysiteurl:2369)
at f.H.Chart.getDataRows (?sc_itemid={1C6CB255-E483-4187-91B5-9B7206DCECD5}&sc_mode=preview&sc_lang=en&sc_site=mysiteurl:2521)
at f.b.getCSV (export-data.js:20)
at f.b.downloadCSV (export-data.js:25)
at f.onclick (?sc_itemid={1C6CB255-E483-4187-91B5-9B7206DCECD5}&sc_mode=preview&sc_lang=en&sc_site=mysiteurl:63)
at HTMLLIElement.onclick (exporting.js:32)

I've been searching and experimenting for a bit and have not found an example or solution. Thanks.
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: Multiple maps per page causes download option to fail

Hello dmoxin!

Welcome to our forum and thanks for contacting us with your question!

I was trying to reproduce your problem, but in my case, everything is working correctly. Here is my demo: https://jsfiddle.net/BlackLabel/s3rpvk0w/

Could you reproduce the issue in an online editor that I could work on? You can use the demo above as a template.

Best regards!
Dominik Chudy
Highcharts Developer
dmoxin
Posts: 5
Joined: Fri Apr 16, 2021 4:38 pm

Re: Multiple maps per page causes download option to fail

Just to close the loop on this thread, I discovered after posting that we were over-writing certain methods in the highcharts modules so that we could customize the output. For example, in a custom options js file, we had:

H.Chart.prototype.getDataRows = function (multiLevelHeaders) {
var time = this.time,
csvOptions = (this.options.exporting && this.options.exporting.csv) || {},
xAxis,
. . . // extra code omitted for brevity
i,
x,
xTitle,
// Options
columnHeaderFormatter = function (item, key, keyLength) {
. . .
}

...so not as simple as two maps on page. With only one map, this worked fine. With two, problems emerged.
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: Multiple maps per page causes download option to fail

Hi again!

Thanks for clarifying this issue. We appreciate it a lot. :)

Best regards!
Dominik Chudy
Highcharts Developer

Return to “Highcharts Maps”