<RuntimeDirectory>\System.Windows.Forms.dll
OxyPlot.WindowsForms
OxyPlot
OxyPlot.Axes
OxyPlot.Series
OxyPlot.WindowsForms
System.Windows.Forms
void Main()
{
var model = new PlotModel { Title = "Test" };
var cs = new ColumnSeries()
{
FillColor = OxyColors.DarkMagenta,
};
var data = new List
{
new ProjectData() { Year = 2014, Month = 11, Count = 10 },
new ProjectData() { Year = 2014, Month = 12, Count = 30 },
new ProjectData() { Year = 2015, Month = 1, Count = 50 },
};
var labels = data.Select(d => d.Date.ToShortDateString()).ToArray();
var axis = new CategoryAxis() { Position = AxisPosition.Bottom };
axis.Labels.AddRange(labels);
model.Axes.Add(axis);
foreach(var item in data)
{
cs.Items.Add(new ColumnItem(item.Count));
}
model.Series.Add(cs);
ShowChart(model);
}
public class ProjectData
{
public int Year { get; set; }
public int Month { get; set; }
public DateTime Date { get { return new DateTime(Year, Month, 1); } }
public int Count { get; set; }
}
public static void ShowChart(PlotModel model)
{
var chart = new PlotView();
chart.Model = model;
chart.Dump();
}