thardes2
thardes2

Reputation: 1186

wpf oxyplot -- change popup when datapoint is clicked

I am using oxyplot with wpf and I want to change the popup if a datapoint gets clicked. OxyplotDataPointClick

Is it possible to change? I saw a few examples that show how to get the clicked point but nothing about changeing the style.

Thank You

Upvotes: 4

Views: 3178

Answers (1)

Peter
Peter

Reputation: 1068

The popup is called Tracker in OxyPlot's source code. You can define its ControlTemplate in XAML via OxyPlot.Wpf.PlotView.DefaultTrackerTemplate as:

<oxy:PlotView Model="{Binding SomePlotModel}">
  <oxy:PlotView.DefaultTrackerTemplate>
    <ControlTemplate>
       <!-- Put your content here-->
    </ControlTemplate>
   </oxy:PlotView.DefaultTrackerTemplate>
</oxy:PlotView>

If each series data need different tracker, then use OxyPlot.Wpf.PlotView.TrackerDefinitions. For example, if your have a LineSeries with TrackerKey="LineSeriesXyzTrackerKey", then defines its tracker as:

<oxy:PlotView Model="{Binding SomePlotModel}">
  <oxy:PlotView.TrackerDefinitions>
    <oxy:TrackerDefinition TrackerKey="LineSeriesXyzTrackerKey">
      <oxy:TrackerDefinition.TrackerTemplate>
        <ControlTemplate>
        <!-- Put your content here-->
        </ControlTemplate>
      </oxy:TrackerDefinition.TrackerTemplate>
    <oxy:TrackerDefinition TrackerKey="SomeOtherTrackerKey">
      <oxy:TrackerDefinition.TrackerTemplate>
        <ControlTemplate>
        <!-- Put your content here-->
        </ControlTemplate>
      </oxy:TrackerDefinition.TrackerTemplate>
  </oxy:TrackerDefinition>
</oxy:PlotView.TrackerDefinitions>

The DataContext for the ControlTemplate is a TrackerHitResult, you can view what properties are available here: https://github.com/oxyplot/oxyplot/blob/master/Source/OxyPlot/PlotController/Manipulators/TrackerHitResult.cs

Some examples: How can I show the plot points in Oxyplot for a line Graph? http://discussion.oxyplot.org/topics/592-wpf-tracker-multiple-value/

Upvotes: 6

Related Questions