Skip to content

inferRadialRange #235

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

Merged
merged 2 commits into from
Mar 11, 2021
Merged

inferRadialRange #235

merged 2 commits into from
Mar 11, 2021

Conversation

Fil
Copy link
Contributor

@Fil Fil commented Mar 11, 2021

inferRadialDomain relies on the heuristic h25 = "median of 25% quantiles of the r channel across marks".
It sets the domain [0, h25] with a default range of [0, 3].

The problem is that "domain" and "range" carry little information about the actual extent of the values (in data or pixel space), and unless you know how the sausage is made you can't really guess how to change either domain or range to meet your visual requirements (though fixing the two solves everything).

With this commit, the default domain becomes the actual extent of values in data space, and the default range are the corresponding values in pixel space, based on the h25 heuristic (in other words, the scale is chosen in a way that r(0) = 0 and r(h25) = 3, and its domain is the data's extent).

Setting the range to [2, 10] (without setting the domain) will make the smallest dot have a radius of 2 and the largest a radius of 10. This is crystal-clear.

Setting the domain alone (without setting the range) does not change the chart at all, but allows the user to change the extent of a potential future radius legend.

In the case of the http://localhost:8008/?test=diamondsCaratPriceDots test, I had to change add an explicit range: [0,3] to the domain: [0, 100], in order to have the set scale (100 values => a dot of radius 3).

In the general case (no indication given by the user), the heuristic is preserved exactly (only precision issues make the test svgs change).

inferRadialDomain relies on the heuristic h25 = "median of 25% quantiles of the r channel across marks".
It sets the domain [0, h25] with a default range of [0, 3].

The problem is that "domain" and "range" carry little information about the actual extent of the values (in data or pixel space), and unless you know how the sausage is made you can't really guess how to change either domain or range to meet your visual requirements (though fixing the two solves everything).

With this commit, the default domain becomes the actual extent of values in data space, and the default range are the corresponding values in pixel space, based on the h25 heuristic.

Setting the range to [2, 10] (without setting the domain) will make the smallest dot have a radius of 2 and the largest a radius of 10. This is crystal-clear.

Setting the domain alone (without setting the range) does not change the chart at all, but allows the user to change the extent of a potential future radius legend.

In the case of the http://localhost:8008/?test=diamondsCaratPriceDots test, I had to change add an explicit range: [0,3] to the domain: [0, 100], in order to have the set scale (100 values => a dot of radius 3).

In the general case (no indication given by the user), he heuristic is preserved exactly (only precision issues make the test svg change).
@Fil Fil requested a review from mbostock March 11, 2021 17:04
@Fil Fil mentioned this pull request Mar 11, 2021
@mbostock
Copy link
Member

I think it would be preferable for the radial domain to always start at zero, i.e., [0, max] instead of [min, max] and similarly for the range. This makes it more likely that when you set a custom range that the area will be proportional to the value, since you can set any [0, maxRadius]. Whereas if you set [minRadius, maxRadius] to match the domain [min, max], if you chose the wrong minRadius, the area will no longer be proportional to the value.

@Fil
Copy link
Contributor Author

Fil commented Mar 11, 2021

I often do this when I want the smallest dots (even with r almost 0) to be visible, in particular if I want its "interior" to be visible (ie I need to set the radius at "r + stroke-width"). Having "area proportional to value" is the basic rule but the visual translation of this rule is not directly r = sqrt(v).

EDIT: to clarify my point, when I need to do this I will set both domain and range explicitly.

@Fil Fil merged commit b8e2a42 into main Mar 11, 2021
@Fil Fil deleted the inferRadialRange branch March 11, 2021 19:00
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.

2 participants