public static PlotModel TimeSpanaxisPlotModel() { var start = new TimeSpan(0, 0, 0, 0); var end = new TimeSpan(0, 24, 0, 0); double increment = 3600; // Create a random data collection var r = new Random(); var data = new Collection<TimeValue>(); var current = start; while (current <= end) { data.Add(new TimeValue { Time = current, Value = r.NextDouble() }); current = current.Add(new TimeSpan(0, 0, (int)increment)); } var plotModel1 = new PlotModel("TimeSpan axis"); var timeSpanAxis1 = new TimeSpanAxis { Position = AxisPosition.Bottom, StringFormat = "h:mm" }; plotModel1.Axes.Add(timeSpanAxis1); var linearAxis1 = new LinearAxis { Position = AxisPosition.Left }; 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 = "Time", 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; }