bumbeishvili / org-chart

Highly customizable org chart. Integrations available for Angular, React, Vue
https://stackblitz.com/edit/web-platform-o5t1ha
MIT License
928 stars 330 forks source link

SVG Export: Uncaught ReferenceError: h is not defined #306

Closed Jack-Fawcett closed 1 year ago

Jack-Fawcett commented 1 year ago

[Description] When using export SVG function reports an error when used: d3-org-chart@3.0.1-next.1:69 Uncaught ReferenceError: h is not defined at t.OrgChart.downloadImage (d3-org-chart@3.0.1-next.1:69:24027) at t.OrgChart.exportSvg (d3-org-chart@3.0.1-next.1:69:23585) at HTMLButtonElement.onclick ((index):1:7)

Steps to reproduce the behavior:

  1. Go to example page for export function
  2. Click on EXPORT SVG button

Expected behavior: Download SVG file

Desktop

bumbeishvili commented 1 year ago

It seems the issue has something to do with the minified file

image

In the original version, h (serializeString) is not in the else section, so it's accessible

image
Jack-Fawcett commented 1 year ago

@bumbeishvili is there a way to avoid this error in the minifying process?

bumbeishvili commented 1 year ago

I have no idea, If you can, just use this class

https://github.com/bumbeishvili/org-chart/blob/6080ad592cc1d5d4d257b22ab34a912bd7dddbc2/src/d3-org-chart.js#L23

And don't forget to include d3 and flextree

 <script src="https://d3js.org/d3.v7.min.js"></script>
 <script src="https://cdn.jsdelivr.net/npm/d3-flextree@2.1.2/build/d3-flextree.js"></script>