Skip to content
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

bar chart is not updating bar widths #795

Open
christianmalek opened this issue Dec 15, 2014 · 5 comments
Open

bar chart is not updating bar widths #795

christianmalek opened this issue Dec 15, 2014 · 5 comments

Comments

@christianmalek
Copy link

If I resize the browser window, the widths of the bars don't update. No matter if you resize bigger or smaller. It appears in 2.0.0-alpha.2.

Update code:

charts.bar.width(width);
dc.renderAll();

Before window resize:
image
After window resize:
image

@gordonwoodhull gordonwoodhull added this to the v2.1 milestone Dec 15, 2014
@gordonwoodhull
Copy link
Contributor

Responsive layout is not yet supported - I'm calling on folks to contribute fixes for 2.1. I'm not sure that it can be completely automatic, as there is apparently no standard event for resizing elements.

See e.g. #544

As a workaround, call chart.rescale manually when you observe a browser resize event.

@christianmalek
Copy link
Author

Works perfect!

Concerning the standard event for resizing:
Wouldn't it be enough to call chart.rescale for the render and update functions? I would not even implement an debouncer because I think that the resize events should be handled by the developer.

@gordonwoodhull
Copy link
Contributor

It's worth considering, but I think it may be overkill - at least, I presume there were performance reasons why the bar width was not calculated on every redraw, but I could be wrong about that.

@r4j4h
Copy link
Contributor

r4j4h commented Dec 16, 2014

I definitely think that the events should be handled by the developer. In some casese debouncing may or may not be desirable, and in some cases with many charts sharing the same resize handler will likely be more efficient and provide greater control. There is nothing stopping a developer from having each chart do its own resize as well. I think making it easy to implement and after that documenting a variety of ways is the best approach.

Currently I throttle the browser resize callback from the window and call .render() in it. This recalculates everything but makes it all fit. This has been a really simple and effective approach and I haven't found too many real issues with it.

From this conversation I am wondering if I should be calling rescale before my redraw calls? Once we determine that I think we should make sure some sample code doing this is easily available to developers as this will likely be a very often desired feature.

@r4j4h
Copy link
Contributor

r4j4h commented Dec 31, 2014

Can anyone who is using rescale before redraw confirm a difference in behavior if the rescale call is removed? I did not see any benefit from rescale being present, but I have not tried every chart type yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants