Inconsistent Tracker Text Generation · Issue #1612 · oxyplot/oxyplot · GitHub
Skip to content

Inconsistent Tracker Text Generation #1612

Open

Description

@VisualMelon

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.

As usual, I'm happy to do the leg work.

Activity

  1. Jonarw commented on Jun 27, 2020

    @Jonarw
    Member

    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).

  2. VisualMelon commented on Jun 28, 2020

    @VisualMelon
    ContributorAuthor

    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.
  3. VisualMelon commented on Dec 22, 2020

    @VisualMelon
    ContributorAuthor

    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.

  4. VisualMelon commented on Dec 22, 2020

    @VisualMelon
    ContributorAuthor

    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).

  5. maye1115 commented on Dec 22, 2020

    @maye1115

    适用的用例是对数dB轴,例如在Bode图上:https : //gitter.im/oxyplot/oxyplot?at=5fe1ca6caa6bb528c3655c11(传统上,我会使用线性轴,但这很麻烦)。

    image
    This is an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions