Closed ashleydavies closed 5 years ago
@lumean I haven't tested the repo with this change -- I just copy/pasted the bits I changed and ran them in irb
with concrete values to check the syntax isn't wrong. I haven't got an environment handy to test this with so if you have something convenient it'd be great if you could verify this doesn't break everything!
Sure, thanks for reporting the issue.
Just realized there are some more issues with plot. i.e. following parameters are not correctly honored:
:max_x_value
:max_y_value
:min_x_value
:min_y_value
will discard this PR, since a more extensive fix is needed.
Ah I hadn’t noticed — happy to send up a PR fixing those too this weekend if it saves you some effort?
Just saw you’ve already done a patch for some of it — thanks! Let me know if I can help in any way.
I think (haven’t tested, so apologies if I’m missing anything) the new step lines might have a new (much more minor) bug where if the last point on the axis does perfectly divide the step then it’ll add an extra point, e.g. step 2 from 6 to 10 will do 6,8,10,12, since you unconditionally add step onto the end value?
yes, that was by intention. It was just a quick test to see if the unit test I added was effective in reproducing the short axis issue. See my changes in test_plot.rb in the last commit.If you have the time and would like to, sure I would appreciate your contributions a lot.regarding testing, so far I didn't find a really good way to test if a generated graph lookd as expected. In most cases I just run the unit tests and examples and then look at the generated files in a browser. If you have some ideas how to automate this process in the unit tests, would also appreciate to hear your inputs. e.g. selenium, jpeg diff, diff of generated svg files, etc.
Ah I see - thanks for the clarification!
For testing, one approach I can think of is testing properties in the SVG, e.g. exists a line with slope 1 between the edges of the x axis and y axis. I guess diffing works too, but it might be a bit fragile to subtle visual changes which don’t introduce any incorrectness. Happy to crank out a few tests this weekend if you think that sounds sensible.
This fixes a bug in Plot which allowed the axis to be insufficiently large to contain the last data point in the event that the last data point does not divide evenly
min_value + n*step
.Demo of problem:
.step
never goes above the upper boundExample graph: