-
Notifications
You must be signed in to change notification settings - Fork 139
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
allow non-adaptive custom scale #327
Comments
Agreed, in retrospect tying these two options together was ill-advised. We could try to address this by providing a new option Open to other suggestions. @tcurdt is this something you would be interested in contributing? |
I am sure I could add the option. Just not sure about the changes need deeper in the stack. |
I would start by just adding the option and a test case that verifies how it behaves. If we are lucky, it will just work. If it won't, I can help dissect the code on the PR that is adding the option. |
It seems there already is an https://github.com/mum4k/termdash/blob/master/widgets/linechart/internal/axes/scale.go#L46 I know it would be a breaking change, but frankly speaking just
would make so much more sense. And it would just require to add |
Hm. Odd. Even this refuses to work. Still expands beyond the min/max.
|
Seems like this also need to change https://github.com/mum4k/termdash/blob/master/widgets/linechart/linechart.go#L174 but then the draw panics
|
Sorry it would be great if I could be more helpful, but I am afraid I forgot all the details of the code in question. Setting a custom scale may need more code changes, because this either breaks some assumptions or simply triggers a bug when the scale is set manually. I think you likely picked this up from the error message above - when the custom scale was set, the code attempted to place a point outside of the scale (out of bounds). We will have to track down the piece of code that determines the placement and debug it. What I would recommend is taking the very case from the error message above and converting it into a unit test. |
This seems to be already covered by the existing tests:
Here the test of course still expresses the wrong expectations. |
That's with
|
I guess this something I could work around by limiting the input data - not great but a workaround. |
@tcurdt I would like to help advise here, but I am having a hard time figuring out the current state of things. Would you mind summarizing the current behavior Vs. the desired one? |
Alright - the summary is as follows:
Does that make things clearer? |
I was more after the high level. I think what you commented describes how to adjust the existing test. I am trying to understand what our goal is. Linechart already supports custom scale, but I think that doesn't work for your use case, because it still scales if a value outside of the range is encountered. Is our goal to work on a mode where that automatic scaling is disabled. I am not sure how mouse zoom falls into the story. We can indeed add an option to disable zooming, but if we implement this, we need to also make sure that while enabled, mouse zooming works with the custom scale. Do I understand this correctly? |
Ah! OK, well, I think it would be nice to be able to disable zooming - but that's really for another ticket I guess. My use case: I assume you know what an oscilloscope is? I want to implement something similar. Does that make more sense now? Frankly speaking it sounds so simple: That said, just writing my own widget would still leave it broken IMO. WDYT is the best path forward? |
Thank you, I think I now have a good idea of what is needed. I do happen to know what an oscilloscope is, used to play with one years ago, so that explanation was a good one. I think we should do a few things:
Would this support the use case you have in mind? |
I still think The zooming already provides a way show a slice/window of the data, too. ...but in the end it's of course all your decision - and it sounds like the approach you outlined will also work for me! |
Sorry for not being clear, I do agree with you that YAxisCustomScale is mixing concerns. Please do keep the suggestions coming, this is how we make better software together. My concern is about breaking a behavior that someone out there might depend on regardless how weird the behavior is in retrospect. Or rather I think we should brake it in a more user friendly way. It would be ok to fix bugs, but this would radically change how an established option behaves and we have no way of figuring out if there are users who depend on it. Therefore my suggestion is to fix it forward in a compatible manner. We can design a set of new options that unlike YAxisCustomScale behave sanely. We can even mark YAxisCustomScale as deprecated in documentation and emit a warning when it is used indicating that users should move and we might eventually delete it completely, telling users how to migrate to the replacement options. All of this would be acceptable, but it feels that changing the behavior of an established option would create a hard to debug scenario for someone already using it. What do you think? |
That certainly would be the path of good engineering. That said, I've seen other breaking changes in the release notes and the version is pre-1.0. The fix would essentially be a trivial "add this option". So I figured... But if you want to treat your users well, deprecating certainly is the better way to go! Totally agree. Taking a step back I am really wondering if the scaling isn't really just setting the initial zoom and anchor. WDYT? |
Sorry I think I need to clarify one more detail. Breaking changes are indeed ok all the way until we get into post 1.0. What I am trying to prevent is a silent behavior breakage. I.e. it is ok (if we have to) to break code in a way that makes the compiler complain, as that makes users look at the changelog. However a silent change of behavior on an already established option is what I think we should avoid as there is no warning. Users will have to notice the change in the behavior of their application. You raise a good point, I also think that most of the code that we need is there already and agree that we just need to find the right set of options. Maybe some minor tweaks will be needed. I wish I could advise more, but linechart is one of the more complicated widgets and I no longer remember the details. |
That's fair.
Maybe it's better I start with a simpler version then and see if they somehow converge. |
I've set
linechart.YAxisCustomScale(-20, 20)
and I want the position of 0 to always stay at the same place.Looking at the code, unfortunately
the LineChart would still rescale the Y axis if a value is encountered that is outside of the range specified here
To me it seems adaptive should be an entirely separate option.
The text was updated successfully, but these errors were encountered: