ember-c3 icon indicating copy to clipboard operation
ember-c3 copied to clipboard

C3 Chart Re-Render Issue.

Open amit199309 opened this issue 3 years ago • 1 comments

C3 chart re-rendering while we switch browser tab reason being original bar color lost. Do we have any mechanism to prevent chart re-rendering either implicitly or explicitly?

amit199309 avatar Dec 28 '21 10:12 amit199309

I'm not sure why switching browser tabs would cause color loss/re-render. Under the hood it's using didUpdateAttrs so I'm assuming the component is seeing a data change.

There's no direct way via the component or c3 but there is a backdoor way to prevent rendering using the dtitle attribute. It's hacky but could possible fix the issue.

The mechanism to change chart titles without refreshing the graph could be used to prevent a refresh. See guard logic in didUpdateAttrs below. If you had dtitle set and dtitle .refresh set to false. the graph won't reload. Even if you are setting the title attribute you can set dtitle to the same value

// don't refresh other properties if they cause side effects
if (isEmpty(this.dtitle) || (isPresent(this.dtitle) && this.dtitle.refresh))
   debounce(this, this._reload, 360);

It's been on my list for awhile to modernize the component for newer Ember versions. Using the same guard logic above, I could add an attribute that would prevent renders. Hopefully I can start working on the updating after the first of the year.

maxwondercorn avatar Dec 30 '21 19:12 maxwondercorn