到目前为止,我从这里尝试了Oxyplot和官方示例http://oxyplot.codeplex.com/wikipage?title=BarSeries 但是我遇到了几个问题:
首先,他无法识别命名空间氧,因此他无法找到任何必需的功能,例如CategoryAxis
和BarSeries
,尽管我已经添加了所有必需的功能库。
packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="OxyPlot.Core" version="2013.2.138.1" targetFramework="net451" />
<package id="OxyPlot.Wpf" version="2013.2.138.1" targetFramework="net451" />
</packages>
Main.Window.xaml.cs
using OxyPlot;
namespace OxyPlotDemo
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var tmp = new PlotModel();
tmp.Axes.Add(new CategoryAxis { ItemsSource = items, LabelField = "Label" }); // dont know wher
tmp.Axes.Add(new LinearAxis(AxisPosition.Left) { MinimumPadding = 0, AbsoluteMinimum = 0 });
tmp.Series.Add(new BarSeries { Title = "2009", ItemsSource = items,
ValueField = "Value1" });
}
}
}
MainWindow.xml 刚刚添加了按钮
<Window x:Class="OxyPlotDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button Content="Button" HorizontalAlignment="Left" Margin="432,10,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
</Grid>
</Window>
VS2013说,他不知道任何CategoryAxis
,items
,LinearAxis
,AxisPosition
,BarSeries
,我怎么能得到它们或什么我做错了吗?是否可以避免DataBinding
。或者也许有人如何以其他方式创建条形图?
答案 0 :(得分:2)
VS2013说,他不知道任何CategoryAxis,项目,LinearAxis,AxisPosition,BarSeries
添加这些名称空间: 使用OxyPlot.Axes; 使用OxyPlot.Series;