d3 / d3-scale

Encodings that map abstract data to visual representation.

Home Page:https://d3js.org/d3-scale

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spline scale

havardl opened this issue · comments

I would like to create a scale which would use the following settings. Would this be possible with any of the d3 scales?

Greetings, you mention "the following settings" but then there are no "settings" that follow. What would be the settings exactly? Does this type of scale exist in any other library?

Sorry about that. After doing some more reading on D3 scales, I guess the setting I'm referring to would be the exponent. My use case is that I have a dataset with a few outliers which are fairly big compared to the other values, and to be able to scale the small values so that they do no disappear visually, I've used a logarithmic spline to try and "blend out" the smallest and largest values.

The screenshot is from a software called Gephi, where you can apply this scale (where both the lower and top values gets a cap), and I'm trying to find the correct representation of the scale in D3.

I'd suggest using a Lamé transformation, which is a generalization of the circle equation x^k + y^k = 1:

y = Math.pow(1 - Math.pow(x, k), 1/k)

See https://observablehq.com/@enjalot/square-a-circle

To do it in D3 you might use an interpolator, see https://observablehq.com/@fil/squircle-interpolator