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

axis title tweaks #404

Merged
merged 3 commits into from
May 29, 2024
Merged

axis title tweaks #404

merged 3 commits into from
May 29, 2024

Conversation

vijithassar
Copy link
Owner

Cleans up the logic around axis title positioning. The notable visible difference is a change in the positioning logic for x axis titles, which will now appear more cleanly centered relative to the mark content such that in a bar chart with three bars the text will be aligned with the middle bar.

The axis offset function is still hard coded to only handle charts where y is the quantitative encoding, which manifests as a misplaced y axis for bar charts where the x axis is quantitative and there are negative values in the chart.

This is because the axis offset function is actually hard-coded to only handle that orientation! So the first step is to change the name and interface of that function into something that could theoretically handle the same position computation for the x axis. This doesn't actually fix the problem, hence the error handling, but now the solution can be scoped to the offset function.
Somewhere along the way this position logic became more convoluted than it needs to be. The result was an x axis text label that is sometimes positioned slightly off-center relative to the mark content. This is visible when the number of axis ticks or nominal bands on the axis is both small and odd – it's easy to see that there's a disagreement about what constitutes the "center" when there are only three bars, for example.

The underlying cause for this is an accidental philosophical disagreement about what dimensions should mean. The original Vega Lite renderer uses them to define the dimensions of the marks area, and adds extra things like axes or titles on top of that. In contrast, bisonica has always interpreted dimensions instructions as describing the outer bounds of the node, the total size of the chart.

One could argue that this is an incompatibility between the two renderers, but it may also be fair to say that bisonica chose the interpretation that is more useful in the real world.
@vijithassar vijithassar merged commit d9a9a34 into main May 29, 2024
18 checks passed
@vijithassar vijithassar deleted the axis branch May 29, 2024 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant