I'm trying to add a description to a legend. I figured out how to show the legend and how to add the description if it is a plain text. I'm stuck on how to pass the description to the legend. Could anyone help me?
I created a minimal example: https://codepen.io/nwp_nadja_bernhard/pen/yLEVdZz
The code in question starts at row 173;
in the function fetchAsync (row 177) I manage to address the desired text -> desc;
in the function create_legend (row 204) I manage to add a static text in the desired place "content" -> description - currently commented;
--> How can I pass the text into the legend content?
Solved! Go to Solution.
Hi @nadja I think you need to await the response from your fetchAsync() function.
You can check out how I got it to work in this codepen ( https://codepen.io/sagewall/pen/zYaNmMq?editors=0011 ) . I wrapped the entire script in (async () => {})() so it would run asynchronously and then just await the fetchAsync response on line 254, and I think it's working with those modifications if I understood the question correctly.
Hi @nadja I think you need to await the response from your fetchAsync() function.
You can check out how I got it to work in this codepen ( https://codepen.io/sagewall/pen/zYaNmMq?editors=0011 ) . I wrapped the entire script in (async () => {})() so it would run asynchronously and then just await the fetchAsync response on line 254, and I think it's working with those modifications if I understood the question correctly.