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
option to force scales of bar charts on left and top to the same sizes #41
Comments
i found computeChartHeightRatios = (
sets,
minCombinations = 2,
) => {
const leftMax = d3.max(sets, d => d.cardinality);
const topMax = d3.max(
UpSetJS.generateCombinations(sets)
.filter(d => d.sets.size >= minCombinations)
.map(d => d.cardinality)
);
const ratio = (topMax / leftMax);
return [ratio, 1 - ratio];
} and many many different versions of this. even if i drop in magic numbers, they don't work as soon as the chart height changes. sadly for my uses case i can't really use the chart without aligning these scales. :\ |
can you create a sketch of what you wanna achieve and how it relates to the chart dimension |
isn't it in the end just enforcing special ratios or setting the width/height such that the constraint:
is fulfilled |
so yes you have solved this problem for one static case. i don't know where you got the values for: const widthRatios = [0.18, 0.12, 0.7];
const heightRatios = [0.6, 0.4]; and i don't know how i would figure any of this out from the documentation. but all of that aside, this is a fundamental data visualization issue. surely you get that? i'll see if i can generalize your solution and plug it into my code, but gosh it seems like having this logic built in would make sense. |
v1.7.0 allows to specify both the maximal scale value as well as the precise pixel values for the set/combination areas. Thus, with e.g. |
this is really great! thank you! 🙏🏻 |
currently the scale on the left bar chart is not the same as the scale on the top. in cases where these bar charts show the same unit, it would be great to be able to coordinate these scales such that a bar of some size on the left has the same numeric value for a bar of the same size on the top.
this has been confusing for my users and specifically caused key insights to be overlooked.
one simple implementation would be to set the height, in pixels, of the top bar chart to be the width, in pixels, of the left bar chart. however this risks rather a lot of wasted white space if these two scales are significantly different. a more sophisticated approach would be to compute the
.domains()
of these two scales, and the.range()
of the scale on the left in the same way you are currently, but set the.range()
on the top scales such that equal values show up as the same size on both charts.please forgive me if an option like this already exists. i've not been able to find an exhaustive list of options anywhere in the doc, and currently hunt through the story book for options. if that list is somewhere, even if it is in code, i'd love to see it.
thank you! :)
The text was updated successfully, but these errors were encountered: