dundalek / markmap

Visualize markdown documents as mindmaps
MIT License
1.7k stars 175 forks source link

a annoying undefined error #38

Closed Lyqqt closed 4 years ago

Lyqqt commented 4 years ago

Annoy error in view.js: Error: attribute y: Expected length, "NaN".

May add || 0 in line 3 (line 24 in view.js): function linkWidth(nodeData) { const data = nodeData.data; return Math.max(6 - 2 * data.d || 0, 1.5); }

dundalek commented 4 years ago

Do you have an example of a situation when it happens? I would rather like to fix a root cause of the bug if possible.

Lyqqt commented 4 years ago

Oh, that's actually my fault. My data structure is wired therefore I skip the transform and convert to json data directly (without key "d"). So I'm trying to render data with default line weight. It will be fine if I add key "d" to my json data. It's just my personal opinion is to add a default value to make more universal. data = { "v": "nodeName", /* "d": 1 */ }