Axes configuration
Closed this issue · 7 comments
pc.scale(input_axis, [lower, upper])
successfully adjusts the yscale domain and ticks of an axis, but the axis itself is the only thing affected -- the polylines are not adjusted. How would I go about updating the plot to match the new axis domain?
I'm guessing it has something to do with pc.applyAxisConfig()
but I'm unsure what the correct parameters should be. Thanks for the help!
I've tested this api and usage should be:
pc.scale(input_axis, [lower, upper]);
pc.data(pc.data().filter(d => d[input_axis] >= lower && d[input_axis] <= upper));
pc.render();
I can filter data accordingly when pc.scale
is called, but I tend to not do this because it is end user who should control data via pc.data
. If I filter data with pc.scale
, end user will lose the track of what the current data is.
What do you think?
I agree that pc.scale
should not manipulate the data; that should be left to pc.data
. Actually, my goal should not even require the data to be filtered. I want to expand the axis and have the data re-mapped so that the range appears more consolidated. I think the code should look something like this:
var input = "weight (lb)";
var upper = 10000;
var lower = 0;
pc.scale(input,[lower, upper]);
pc.updateAxes(); // or pc.applyAxisConfig(input)
pc.render();
The svg ticks have been updated, but the data is still mapped to the same place. Is there already a way to fix this?
Side note: I think it would also be useful if pc.scale
allowed the user to specify the type of scale to use for the axis (log, linear, ordinal, custom). Perhaps pc.scale(input, [lower, upper], scale)
? Maybe this is too much?
Looks great! Thank you for your consistent and quality work!
Thanks for your appreciation of my work. You've contributed detailed code samples and keen observations to issues, and that help me a lot resolve problems.