我正在开发一个需要图表的 WPF 应用程序。我正在使用OxyPlot。我的图表使用以下 XAML 正确呈现。
<oxy:Plot Height="800" HorizontalContentAlignment="Stretch">
<oxy:Plot.Series>
<oxy:LineSeries ItemsSource="{Binding Series1Points}" MarkerType="Diamond" Title="Series 1" />
<oxy:LineSeries ItemsSource="{Binding Series2Points}" MarkerType="Diamond" Title="Series 2" />
</oxy:Plot.Series>
</oxy:Plot>
Run Code Online (Sandbox Code Playgroud)
我有一个尚未成功解决的挑战。当渲染系列时,每个数据点显示为菱形。当用户将鼠标放在钻石上时,我想显示一个带有数据点的 X 和 Y 值的工具提示。你怎么能这么做呢?看起来应该是可以的。然而,我没有取得任何成功。
单击左键即可显示工具提示。要在悬停时显示它,您需要修改 oxyplot 控制器:
C#:
public PlotController customController { get; private set; }
...
//Sets the controller to enable show tracker on mouse hover
customController = new PlotController();
customController.UnbindMouseDown(OxyMouseButton.Left);
customController.BindMouseEnter(PlotCommands.HoverSnapTrack);
Run Code Online (Sandbox Code Playgroud)
xml:
<oxy:Plot Controller="{Binding customController}" Height="800" ... >
Run Code Online (Sandbox Code Playgroud)