简体   繁体   中英

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

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM