Hi, this is a neat little library, thanks for developing it!
However I've encountered some surprising behavior by PlotMany() that can lead to wildly incorrect output graphs if not guarded against. Thanks for taking a look at this and any fixes you can make.
What I observe:
Repeated calls to PlotMany() with the same data slices (with new values appended for each new call) result in the passed data slices being unexpectedly modified by the method.
Without very clear documentation, I expect that library API calls will not modify the length or contents of passed data slices.
In the case of this library, there is no reason to expect that the data passed in for plotting will be modified, as that is not typical behavior for plotting packages.
At a minimum the documentation should be updated to warn users of this side-effect. But ideally, the library would make internal copies of data that needs to be modified.
Hi, this is a neat little library, thanks for developing it!
However I've encountered some surprising behavior by
PlotMany()
that can lead to wildly incorrect output graphs if not guarded against. Thanks for taking a look at this and any fixes you can make.What I observe:
Repeated calls to
PlotMany()
with the same data slices (with new values appended for each new call) result in the passed data slices being unexpectedly modified by the method.This appears to happen when a fixed
Width()
is specified, here: https://github.com/guptarohit/asciigraph/blob/master/asciigraph.go#L30-L39This results in incorrect distortions in the output plots (the lines should be straight), such as:
What I expect:
Without very clear documentation, I expect that library API calls will not modify the length or contents of passed data slices. In the case of this library, there is no reason to expect that the data passed in for plotting will be modified, as that is not typical behavior for plotting packages.
At a minimum the documentation should be updated to warn users of this side-effect. But ideally, the library would make internal copies of data that needs to be modified.
The expected output (straight lines) is:
Reproduction: