You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tracker texts currently use a mix of GetValue and FormatValue. The latter would seem more correct to me, but seems to be restricted to category axes. It would, for example, seem directly applicable to DateTimeAxis (as in #1611), and indeed numerical axes with custom formatters. I propose replacing all calls to GetValue with FormatValue for all Tracker texts.
Additionally, BarSeries is unique in providing a protected virtual GetTrackerText method, which provides an extension point. It could be useful to provide such methods in all series. It may be worth providing extension by delegate in addition to virtual GetTrackerText methods. The main complexity would be in designing per-series GetTrackerText signatures. Off hand, I'm not sure how StyleCop wants delegates, but it would be annoying to have a separate file for separate delegates if we went that way (though e.g. DataPoint series could mostly share one signature). The main API concern I foresee is that extension at one level will muddy things for any inheriting types. Adding delegates or something can be done in the future, but I think it would make sense to add the protected virtual GetTrackerText methods for all series at the same time as changing the behaviour, so that it can be 'reverted' by users if absolutely necessary.
I am not too sure as to what even is the point of the Axis.GetValue(...) function in the presence of Axis.FormatValue(...). As far as I can see Axis.GetValue(...) is only ever used for trackers. If I didn't miss anything, we could even think about removing Axis.GetValue(...) after this (or rather marking it as obsolete for now).
It dawned on me the reason: it's so you can format the value however you'd like in the TrackerString. I'm not sure what to do, but there are two obvious options:
Make everything call GetValue, which wouldn't change any behaviour because CategoryAxis.GetValue just calls FormatValue internally. This is a small change that I don't think anyone would notice. We could consider changing CategoryAxis.GetValue to just return the value, rather than formatting it, for consistency.
Make everything call FormatValue, which removes the ability to have different formatting for tracker and axes, but means the axes can provide a sensible default and makes within-application consistency easier.
Looking again, GetValue probably should not be used for this purpose, but is the only extension point that works with trackers at the moment. I propose that everything that needs a string should be calling FormatValue (i.e. tick rendering and trackers): nothing else makes any sense. We can add virtual string GetTrackerText(...) methods to series so that tracker text can be overridden as necessary: don't worry about delegates for now. I'll try to sort out a PR soon.
Activity
Jonarw commentedon Jun 27, 2020
I am not too sure as to what even is the point of the
Axis.GetValue(...)function in the presence ofAxis.FormatValue(...). As far as I can seeAxis.GetValue(...)is only ever used for trackers. If I didn't miss anything, we could even think about removingAxis.GetValue(...)after this (or rather marking it as obsolete for now).VisualMelon commentedon Jun 28, 2020
It dawned on me the reason: it's so you can format the value however you'd like in the
TrackerString. I'm not sure what to do, but there are two obvious options:GetValue, which wouldn't change any behaviour becauseCategoryAxis.GetValuejust callsFormatValueinternally. This is a small change that I don't think anyone would notice. We could consider changingCategoryAxis.GetValueto just return the value, rather than formatting it, for consistency.FormatValue, which removes the ability to have different formatting for tracker and axes, but means the axes can provide a sensible default and makes within-application consistency easier.VisualMelon commentedon Dec 22, 2020
Looking again,
GetValueprobably should not be used for this purpose, but is the only extension point that works with trackers at the moment. I propose that everything that needs a string should be callingFormatValue(i.e. tick rendering and trackers): nothing else makes any sense. We can addvirtual string GetTrackerText(...)methods to series so that tracker text can be overridden as necessary: don't worry about delegates for now. I'll try to sort out a PR soon.VisualMelon commentedon Dec 22, 2020
Applicable use-case is a logarithmic dB axis e.g. on a Bode plot: https://gitter.im/oxyplot/oxyplot?at=5fe1ca6caa6bb528c3655c11 (traditionally I would use a linear axis, but that's iffy).
maye1115 commentedon Dec 22, 2020
This is an example.