-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling .load() on a chart that is not rendered yet (due to lazy rendering) triggers an error #3106
Comments
IMO, this need to be handle by usage perspective. In this case, the call of // will be called, when chart element's visibility turn to be visible
onafterinit: function(){
setTimeout(function () {
chart.load({
columns: [
['fill', Math.min(30 / 100, 1)],
['background', 1 - Math.min(30 / 100, 1)]
]
})
}, 100)
} |
@netil I indeed fixed the time when I loaded the data. However, it would still be great to avoid triggering an error due to accessing an undefined internal property when calling this method when the chart is not initialized yet, especially given that lazy rendering is active by default if the element is initially hidden (and there is no way to opt-out). |
@stof, thanks for the suggestion. What will be the "best" way handling this? Not throwing error? warning via console? or just staying silently not giving any notice? And expanding for every possible error cases, what policy is the "best"? The way to handle this, will differ based on each one's perspective. |
@netil the issue is that there is no way to disable lazy init. Even putting an explicit To me, the solution should look like this:
|
side note: if the codebase was actually typechecked (instead of using |
I found another case that triggered such error when calling the public API while a chart was not yet initialized due to the automatic lazy rendering: const chart = bb.generate(options);
chart.legend.show(['first', 'second']); |
Will update to make a "forced" state to initialize, even when
Was trying to implement this, but not really sure. Giving warning msg is good for users, but in terms of library is adding some additional call execution. Will try consider in the future. |
Make to initialize when chart element isn't visible, but render.lazy=false is set Ref naver#3106
Make to initialize when chart element isn't visible, but render.lazy=false is set Ref naver#3106
Description
Steps to check or reproduce
If
element
is hidden at the time of running this code (in my case, it is inside a modal for which the opening animation has not run yet), the.load
call fails becauseupdateTargets
tries to use$el.main
which has not been initialized yet.The text was updated successfully, but these errors were encountered: