public void SetGraph() { pltMain.Series.Clear(); NonDisplayedSeries.Clear(); innerStack.Children.Clear(); DateTime dMin = OPoints.Min(x => x.Date); dtAxis = new DateTimeAxis { Position = OxyPlot.Axes.AxisPosition.Bottom, Minimum = dMin.Date.ToOADate(), Maximum = DateTime.Today.ToOADate(), StringFormat = "M/d" }; dtAxis.FirstDateTime = dMin.Date; dtAxis.LastDateTime = DateTime.Today; PrefixedLineSeries = new List <PrefixedLineSeries>(); OUsers.ForEach(x => PrefixedLineSeries.Add(OPoints.ToDailyPoints(x.Alias))); OUsers.ForEach(x => PrefixedLineSeries.Add(OPoints.ToHourlyDatePoints(x.Alias))); OUsers.ForEach(x => PrefixedLineSeries.Add(OPoints.ToTotalAvg(x.Alias))); OUsers.ForEach(x => PrefixedLineSeries.Add(OPoints.ToWeeklyAvg(x.Alias))); foreach (var PrefLine in PrefixedLineSeries.OrderBy(x => x.Title)) { pltMain.Series.Add(PrefLine.LineSeries); CheckBox checkBox = new CheckBox() { Name = PrefLine.Key, Content = PrefLine.Title, IsChecked = true }; checkBox.Click += new RoutedEventHandler(this.Combo_Clicked); innerStack.Children.Add(checkBox); } RefreshGraph(); }
private void Combo_Clicked(object sender, RoutedEventArgs e) { var cb = (CheckBox)sender; if (cb.IsChecked.GetValueOrDefault()) { var s = NonDisplayedSeries.FirstOrDefault(x => x.Name == "s" + cb.Name); NonDisplayedSeries.Remove(s); pltMain.Series.Add(s); } else { var s = pltMain.Series.FirstOrDefault(s => s.Name == "s" + cb.Name); pltMain.Series.Remove(s); NonDisplayedSeries.Add(s); } RefreshGraph(); }