我在C#winforms应用程序中使用OxyPlot.我的axese是LinearAxis类型.
我试图绘制一些实时数据,我已经设法通过在我的系列中添加点并在数据可用时刷新绘图.但是,我无法弄清楚如何使用时间序列使曲线向右移动.
每个时间序列数据点的X值增加(int)1,我试图使用.Pan()来实现自动滚动:
xAxis.Pan(-1);
Run Code Online (Sandbox Code Playgroud)
显然这没有用,因为我假设该方法采用像素输入或其他东西,因此平移比数据增量慢得多.
我也尝试用-MajorTIckSize和-MajorStepSize替换-1而没有运气,因为这些通常都太小了.
我的问题是,我如何确定我需要用于平移真实数据的delta?我假设这将取决于缩放级别,显然它会很好,如果它会继续工作,因为我放大和缩小.我想解决方案涉及某种功能,依赖于滴答间隔的像素宽度或某事但我无法弄清楚.
PS:我也在OxyPlot讨论页面上问了这个问题
谢谢,
阿尔钦
下午好,现在我有这张图表,但我想在条形图中添加红色和蓝色线条。我与oxyplot相当新。谢谢你的帮助。
我目前正在使用保存为布尔值的继电器中的事件显示。因此,最好有一条水平线参考。
蓝线只是代表系统中事件的另一条线。
这是我的xaml
<Window x:Class="Label_Issue.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Label_Issue"
xmlns:oxy="http://oxyplot.org/wpf"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<oxy:PlotView x:Name="barChartModel"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)
这是我的.cs
namespace Label_Issue
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
SetUtilizationData();
}
public PlotModel PlotModel { get; set; }
private void SetUtilizationData()
{
PlotModel = new PlotModel
{
LegendOrientation = LegendOrientation.Vertical,
LegendPlacement = LegendPlacement.Outside,
LegendPosition = LegendPosition.RightTop
};
// define x-axis
OxyPlot.Axes.DateTimeAxis dateAxis = new OxyPlot.Axes.DateTimeAxis
{
Position = OxyPlot.Axes.AxisPosition.Bottom,
//StringFormat = "dd/MM/yy HH:mm" // …Run Code Online (Sandbox Code Playgroud) 我在 Oxyplot 热图小部件的边缘看到了空间。我想让 X0,X1,Y0,Y1 绘制在热图油漆画布的最边缘,即没有边距和填充。OxyPlot 的 HeatMapSeries 是如何做到的?
我希望 (0, 0) 正好位于左下角。
我想订购legend我的 Oxyplot 图表alphabetical order。里面可能吗Oxyplot?
这是我当前的情节:带有图例的情节
我想订购legend我的chart. 我不会先排序绘制数据的方式,因为这意味着太多的条件,而且我希望尽可能保持绘制的通用性。我知道这是一个选择,但我宁愿不采用这种方法。
请告诉我是否可以order alphabetically仅使用 中的图例项目Oxyplot?
我正在努力解决 WPF 项目中有关 OxyPlot 的几个问题。
首先,我可以使用 Plot 类或 PlotView 类。这两个类有什么区别?
理想情况下,我想对模型(或至少部分模型)和数据使用数据绑定。
如果我使用 PlotView,我可以对模型使用 Binding,如下所示:
<oxy:PlotView Model="{Binding Model}"/>
Run Code Online (Sandbox Code Playgroud)
如果我使用 Plot,我可以对数据使用数据绑定,例如
<oxy:Plot>
<oxy:Plot.Series>
<oxy:LineSeries ItemsSource="{Binding Points}" />
</oxy:Plot.Series>
</oxy:Plot>
Run Code Online (Sandbox Code Playgroud)
我可以让这两个都工作,但是有没有办法对模型和数据使用绑定?
如果我使用 Plot 类和 Binding 来处理数据,我至少会使用 Binding 来处理 LineColor,如下所示
<oxy:Plot>
<oxy:Plot.Series>
<oxy:LineSeries ItemsSource="{Binding Points}"
DataFieldX="X"
DataFieldY="Y"
StrokeThickness="2"
MarkerSize="0"
LineStyle="Solid"
Color="{Binding LineColor}"
MarkerType="None"/>
</oxy:Plot.Series>
</oxy:Plot>
Run Code Online (Sandbox Code Playgroud)
我根本无法让它发挥作用。曲线始终为绿色。我的 LineColor 属性是使用 OxyColor 类型定义的。这是错误的类型吗?
我知道我在同一篇文章中提出了几个问题,但我认为它们是非常密切相关的。
我想添加一个位于绘图区域特定位置的 TextAnnotation,其方式独立于轴平移或缩放 - 类似于水印。
我注意到 TextAnnotation 位置只能由 DataPoint 确定,而 ImageAnnotation 具有用于定位的 X 和 Y 属性。
我已经搜索了很多关于这个问题的答案,但我只找到了与 Windows Forms 而不是 WPF 相关的旧答案。文档中没有提到任何内容。
我有两个使用oxyplot绘制的线系列。但是,我无法将每个系列分配给一个单独的轴(由于比例不同,我需要两个)。
在发现的示例中,有人指出应该将key="somename"分配给轴定义,并将YAxisKey="somename"分配给线系列。但是,我收到一条错误消息,指出这些属性不存在。任何帮助是极大的赞赏。请参阅下面附加的 xaml 代码
<Wpf:Plot
DockPanel.Dock="Bottom"
x:Name="OxyPlot1"
Title="{Binding Title}" Height="400" Margin="0,0,0,0">
<Wpf:Plot.Axes>
<Wpf:LinearAxis
x:Name="Psiaxis" Position="Left" Title="Pressure (PSI)"
TickStyle="Inside" StartPosition="0"/>
<Wpf:LinearAxis
x:Name="Gpmaxis" Position="Right" Title="Flow In (GPM)"
TickStyle="Inside" StartPosition="0"/>
<Wpf:DateTimeAxis
Position="Bottom" TickStyle="Inside" IntervalType="Seconds"
MinorGridlineStyle="Dash" MajorGridlineStyle="Solid"
StringFormat="dd:MM:yyyy HH:mm:ss"/>
</Wpf:Plot.Axes>
<Wpf:LineSeries
x:Name="SelectedPointsPressure"
Height="100"
Width="100"
Title="Pressure (psi)"
ItemsSource="{Binding ToPlotPoints1}"/>
<Wpf:LineSeries
x:Name="RegressionPoints"
Height="100"
Width="100"
LineStyle="Solid"
Color="Blue"
Title="Linear least squares fit"
ItemsSource="{Binding ToPlotPoints2}"/>
<Wpf:LineSeries
x:Name="SelectedPointsFlowin"
Height="100"
Width="100"
LineStyle="Solid"
Color="Green"
Title="Flow In (gpm)"
ItemsSource="{Binding …Run Code Online (Sandbox Code Playgroud) 我一直在尝试在我的线系列之上使用 oxyplot 实现散点图。基本上,我想对散点图上的一些点进行颜色编码。
我已经使用散点图和线系列创建了下面的图表:
上述点颜色是按照此处的教程创建的。基本上,我添加了一个 RangeColorAxis。该图的 X 轴范围从 0 到 1,并创建颜色,如下所示:
var customAxis = new RangeColorAxis { Key = "customColors" };
customAxis.AddRange(0, 0.1, OxyColors.Red);
customAxis.AddRange(0.1, 0.2, OxyColors.Yellow);
customAxis.AddRange(0.2, 0.3, OxyColors.Green);
customAxis.AddRange(0.3, 1, OxyColors.Orange);
customAxis.AddRange(1, 1.1, OxyColors.Blue);
OxyPlotModel.Axes.Add(customAxis);
Run Code Online (Sandbox Code Playgroud)
但现在,我还想在上图中添加一些颜色渐变。例如,从点 0.0 到 0.1,我希望颜色从浅红色进展到深红色。从 0.1 到 0.2,我想从浅黄色过渡到亮黄色。从0.2到0.3,我想从浅绿色过渡到深绿色。等等。
在 Oxyplot 中可以做到这一点吗?谢谢