-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Composite Chart Not Rescaling Bar Width #611
Comments
Thanks for filing this. I agree it's a bug and I'll take a look for 2.0, as I'm looking at a lot of related stuff. In the meanwhile, you might have better luck asking for workarounds on the mailing list, as I know a lot of people are doing similar stuff. |
Indeed it looks like each of |
+1 Ran into this today |
It's almost two years late but it can be fixed if you assign the xAxisLength of the composite chart to the xAxisLength of the child bar charts: childBarChart.xAxisLength = compositeChart.xAxisLength; |
Also ran into this today. Anyone have a workaround? |
@jesper998, I take it @paloteb's workaround does not work for you? What about manually setting Resizing was not part of the original design of dc.js, so there is a lot of troubleshooting to do. |
Thanks, got it working by setting height and width of children for events "preRender" and "preRedraw" on the composite chart! |
Awesome! |
Here's what I came up with for a more holistic patch for this. @gordonwoodhull thoughts? Would you be interested in a PR for this? dc.override(dc, 'compositeChart', function (parent, chartGroup) {
var _chart = dc._compositeChart(parent, chartGroup);
dc.override(_chart, 'rescale', function () {
_chart._rescale();
var _children = _chart.children();
_children.forEach(function (child) {
child.rescale();
});
return _chart;
});
// properties originally passed through in compose()
['height', 'width', 'margins'].forEach(function (prop) {
var _prop = '_' + prop;
dc.override(_chart, prop, function (value) {
if (!arguments.length) {
return _chart[_prop]();
}
_chart[_prop](value);
var _children = _chart.children();
_children.forEach(function (child) {
child[prop](value);
});
return _chart;
});
});
return _chart;
}); |
This makes a lot of sense and it should be much simpler as part of the library. If you have time, please do file a PR! |
Fixed by #1365 in 3.1.5 |
I have been using the following to rescale bar widths when resizing a full-width chart, where width is assigned by the anchor set at 100% in CSS:
Which works perfectly if
chart
is a bar chart. However, if the bar chart is part of a composition, wherechart
is the composite chart, bar widths no longer rescale.It seems that
_chart.xAxisLength()
incalculateBarWidth
is not reflecting the new width.The text was updated successfully, but these errors were encountered: