public static PlotModel DateTimeaxisPlotModel() { var start = new DateTime(2010, 01, 01); var end = new DateTime(2015, 01, 01); double increment = 3600 * 24 * 14; // Create a random data collection var r = new Random(); var data = new Collection<DateValue>(); var date = start; while (date <= end) { data.Add(new DateValue { Date = date, Value = r.NextDouble() }); date = date.AddSeconds(increment); } var plotModel1 = new PlotModel("DateTime axis"); var dateTimeAxis1 = new DateTimeAxis { CalendarWeekRule = CalendarWeekRule.FirstFourDayWeek, FirstDayOfWeek = DayOfWeek.Monday, Position = AxisPosition.Bottom }; plotModel1.Axes.Add(dateTimeAxis1); var linearAxis1 = new LinearAxis(); plotModel1.Axes.Add(linearAxis1); var lineSeries1 = new LineSeries { Color = OxyColor.FromArgb(255, 78, 154, 6), MarkerFill = OxyColor.FromArgb(255, 78, 154, 6), MarkerStroke = OxyColors.ForestGreen, MarkerType = MarkerType.Plus, StrokeThickness = 1, DataFieldX = "Date", DataFieldY = "Value", ItemsSource = data }; plotModel1.Series.Add(lineSeries1); return plotModel1; }
public static PlotModel SunriseandsunsetinOslo() { int year = DateTime.Now.Year; #if SILVERLIGHT || PCL var sunData = CreateSunData(year, 59.91, 10.75); #else var sunData = CreateSunData(year, 59.91, 10.75, TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time")); #endif var plotModel1 = new PlotModel(); plotModel1.Title = "Sunrise and sunset in Oslo"; #if SILVERLIGHT plotModel1.Subtitle = "UTC time"; #endif var dateTimeAxis1 = new DateTimeAxis { CalendarWeekRule = CalendarWeekRule.FirstFourDayWeek, FirstDayOfWeek = DayOfWeek.Monday, IntervalType = DateTimeIntervalType.Months, MajorGridlineStyle = LineStyle.Solid, Position = AxisPosition.Bottom, StringFormat = "MMM" }; plotModel1.Axes.Add(dateTimeAxis1); var timeSpanAxis1 = new TimeSpanAxis { MajorGridlineStyle = LineStyle.Solid, Maximum = 86400, Minimum = 0, StringFormat = "h:mm" }; plotModel1.Axes.Add(timeSpanAxis1); var areaSeries1 = new AreaSeries { ItemsSource = sunData, DataFieldX = "Day", DataFieldY = "Sunrise", DataFieldX2 = "Day", DataFieldY2 = "Sunset", Fill = OxyColor.FromArgb(128, 255, 255, 0), Color = OxyColors.Black }; plotModel1.Series.Add(areaSeries1); return plotModel1; }