/// <summary> /// Initializes a chart with X axis from type <see cref="AlertPresentation.ChartAxisType.DateAxis"/>. /// </summary> /// <param name="chartAlertProperty">The chart alert property that should be displayed.</param> private void InitializeDateTimeXAxisChart(ChartAlertProperty chartAlertProperty) { var sortedDateTimePoints = chartAlertProperty.DataPoints.OrderBy(point => point.X).ToList(); var chartDatePoints = sortedDateTimePoints.Select(dataPoint => { DateTime x = ConvertCoordinateValueToDateTime(dataPoint.X, "X"); double y = ConvertCoordinateValueToDouble(dataPoint.Y, "Y"); return(new ChartDataPoint <DateTime>(x, y)); }); var chartValues = new ChartValues <ChartDataPoint <DateTime> >(chartDatePoints); // In order to support Bar Chart, Since we are using DateTime.Ticks as X, the width of the bar is 1 tick and 1 tick is 1 millisecond. // In order to make our bars visible we need to change the unit of the chart. Hence, we are taking the difference between 2 first points (assuming difference between every 2 points is equal) double xAxisFactor = chartValues.Count > 1 ? chartValues.Skip(1).First().X.Ticks - chartValues.First().X.Ticks : chartValues.First().X.Ticks; CartesianMapper <ChartDataPoint <DateTime> > pointMapperConfig = Mappers.Xy <ChartDataPoint <DateTime> >() .X(dateTimeDataPoint => dateTimeDataPoint.X.Ticks / xAxisFactor) .Y(dateTimeDataPoint => dateTimeDataPoint.Y); this.SeriesCollection = new SeriesCollection(pointMapperConfig); this.AddSeries(chartAlertProperty.ChartType, chartValues); this.XAxisFormatter = value => new DateTime((long)(value * xAxisFactor)).ToString(CultureInfo.InvariantCulture); this.SetYAxisFormat(chartAlertProperty); }
private void ResetZoomOnClick(object sender, RoutedEventArgs e) { if (_values.Count() > 0) { From = _values.First().StartPoint; To = _values.Last().EndPoint; } }
public void RemoveSearch() { if (selectedPhonePos.Count != 0) { String cleanSelectedMAC = selectedMAC.Replace(":", ""); DatiDispositivo p = selectedPhonePos.First <DatiDispositivo>(); selectedPhonePos.Remove(p); if (Pacchetto.CntrlGlobal(selectedMAC)) { //hiddenPhone hiddenPhonePos.Add(p); } else { //visiblePhone phonePos.Add(p); } } }
private bool PassFilter(Predicate <object> filter, ChartValues <DataPoint> values) { bool pass = filter == null; if (!pass) { var first = values.First(); if (CurrentPetOrPlayerOption == Labels.PETPLAYEROPTION) { pass = filter(first.PlayerName) || (HasPets.ContainsKey(first.Name) && filter(HasPets[first.Name])); } else { pass = filter(first.Name); } } return(pass); }
/// <summary> /// /// </summary> /// <param name="dataList">Name, Addr, Value</param> public void Update(List <SectionData> dataList) { foreach (var data in dataList) { LineSeries series = (LineSeries)Series_Collection.Where((x) => (uint)((LineSeries)x).Tag == data.Addr).SingleOrDefault(); if (series == null) { series = new LineSeries { Name = data.Name.Replace(".", "_"), Tag = data.Addr, Values = new ChartValues <ObservablePoint>(), Stroke = GetNextColor(), Fill = Brushes.Transparent, StrokeThickness = .5, PointGeometry = null, }; Series_Collection.Add(series); } ChartValues <ObservablePoint> Values = (ChartValues <ObservablePoint>)series.Values; if (Values.Count > MAX_COUNT - 1) { Values.Remove(Values.First()); } else if (Values.Count < MAX_COUNT) { Values.Add(new ObservablePoint( (DateTime.Now - LaunchTime).TotalSeconds, data.Value )); } } if (dataList.Count < Series_Collection.Count) { var UnfoundSeries = Series_Collection.Where((series) => !dataList.Any((data) => data.Addr == (uint)((LineSeries)series).Tag)); foreach (var item in UnfoundSeries) { Series_Collection.Remove(item); } } }
private void button1_Click(object sender, EventArgs e) { cartesianChart1.AxisX[0].MinValue = _values.First().StartPoint; cartesianChart1.AxisX[0].MaxValue = _values.Last().EndPoint; }