Skip to content

Instantly share code, notes, and snippets.

@peace2048
Created June 22, 2017 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peace2048/1d7577187507d252bcc6e08658ebbffb to your computer and use it in GitHub Desktop.
Save peace2048/1d7577187507d252bcc6e08658ebbffb to your computer and use it in GitHub Desktop.
<Query Kind="Statements">
<Reference>&lt;RuntimeDirectory&gt;\System.Windows.Forms.dll</Reference>
<NuGetReference>OxyPlot.WindowsForms</NuGetReference>
<Namespace>OxyPlot</Namespace>
<Namespace>OxyPlot.Axes</Namespace>
<Namespace>OxyPlot.Series</Namespace>
</Query>
var pm = new PlotModel
{
IsLegendVisible = true,
LegendPlacement = LegendPlacement.Outside,
LegendPosition = LegendPosition.LeftTop
};
var xaxis = new DateTimeAxis
{
Position = AxisPosition.Bottom,
StringFormat = "h:mm"
};
pm.Axes.Add(xaxis);
var yaxis = new LinearAxis
{
IsAxisVisible = false,
IsPanEnabled = false,
IsZoomEnabled = false
};
pm.Axes.Add(yaxis);
var gannt1 = new RectangleBarSeries();
gannt1.Title = "AAA";
gannt1.Items.Add(new RectangleBarItem(
DateTimeAxis.ToDouble(DateTime.Today.Add(new TimeSpan(8, 30, 0))), 0,
DateTimeAxis.ToDouble(DateTime.Today.Add(new TimeSpan(8, 32, 0))), 1)
);
gannt1.Items.Add(new RectangleBarItem(
DateTimeAxis.ToDouble(DateTime.Today.Add(new TimeSpan(8, 35, 0))), 0,
DateTimeAxis.ToDouble(DateTime.Today.Add(new TimeSpan(8, 37, 0))), 1)
);
gannt1.Items.Add(new RectangleBarItem(
DateTimeAxis.ToDouble(DateTime.Today.Add(new TimeSpan(8, 43, 0))), 0,
DateTimeAxis.ToDouble(DateTime.Today.Add(new TimeSpan(8, 44, 0))), 1)
);
pm.Series.Add(gannt1);
var gannt2 = new RectangleBarSeries();
gannt2.Title = "BBB";
gannt2.Items.Add(new RectangleBarItem(
DateTimeAxis.ToDouble(DateTime.Today.Add(new TimeSpan(8, 31, 0))), 1,
DateTimeAxis.ToDouble(DateTime.Today.Add(new TimeSpan(8, 33, 0))), 2)
);
gannt2.Items.Add(new RectangleBarItem(
DateTimeAxis.ToDouble(DateTime.Today.Add(new TimeSpan(8, 35, 0))), 1,
DateTimeAxis.ToDouble(DateTime.Today.Add(new TimeSpan(8, 40, 0))), 2)
);
gannt2.Items.Add(new RectangleBarItem(
DateTimeAxis.ToDouble(DateTime.Today.Add(new TimeSpan(8, 41, 0))), 1,
DateTimeAxis.ToDouble(DateTime.Today.Add(new TimeSpan(8, 50, 0))), 2)
);
pm.Series.Add(gannt2);
new OxyPlot.WindowsForms.PlotView { Model = pm }.Dump();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment