简体   繁体   English

使用 Oxyplot Visual Studio C# 的折线图

[英]Line graph using Oxyplot Visual studio C#

I'm struggling to get a simple line graph as an output.我正在努力获得一个简单的折线图作为输出。 All tools of Oxyplot is not in my toolbar. Oxyplot 的所有工具都不在我的工具栏中。

InitializeComponent();
PlotModel model = new PlotModel();

OxyPlot.WindowsForms.PlotView plot1 = new OxyPlot.WindowsForms.PlotView();     

var lineSeries = new LineSeries();
lineSeries.Points.Add(new DataPoint(0, 0))
lineSeries.Points.Add(new DataPoint(10, 4));
lineSeries.Points.Add(new DataPoint(30, 2));
lineSeries.Points.Add(new DataPoint(40, 12));
model.Series.Add(lineSeries);

How can I have Oxyplot commands in the toolbar in Visual Studio?如何在 Visual Studio 的工具栏中使用 Oxyplot 命令?

Had the same problem and finally found a solution (for WPF):遇到了同样的问题,终于找到了解决方案(对于 WPF):

(might similarly work for WinForms) (可能同样适用于 WinForms)


  1. Locate the OxyPlot DLLs in your project tree somewhere in "../packages" and copy both OxyPLot.dll and OxyPlot.Wpf.dll into the same folder (eg "../packages/OxyPlot_Wpf").在项目树中的“../packages”中找到 OxyPlot DLL,并将OxyPLot.dll 和 OxyPlot.Wpf.dll复制到同一文件夹中(例如“../packages/OxyPlot_Wpf”)。

  2. Then, in the solution explorer, remove the references which NuGet made before, and add references to the copied DLLs instead.然后,在解决方案资源管理器中,删除 NuGet 之前创建的引用,并改为添加对复制的 DLL 的引用。

  3. Finally, create a new tab in the Toolbox and drag OxyPlot.Wpf.dll from the file explorer and drop it on the created tab.最后,在工具箱中创建一个新选项卡并将 OxyPlot.Wpf.dll 从文件资源管理器中拖放到创建的选项卡上。


You should see some three dozen OxyPlot controls now.您现在应该会看到大约三打 OxyPlot 控件。

The answer here pointed me in the right direction. 这里的答案为我指明了正确的方向。

Cheerio, Al切里奥,阿尔

If you use WPF:如果您使用 WPF:

If you want to add a Plot control in the design view, press Choose Items... in the Toolbox and browse for the OxyPlot.Wpf.dll file.如果要在设计视图中添加 Plot 控件,请按工具箱中的选择项...并浏览 OxyPlot.Wpf.dll 文件。 If you used NuGet, it should be located in the packages folder in your solution folder.如果你使用过 NuGet,它应该位于你的解决方案文件夹中的包文件夹中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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