public InjectedPlotterHorizontalSyncConverter(InjectedPlotter plotter) { if (plotter == null) { throw new ArgumentNullException("plotter"); } this.injectedPlotter = plotter; }
void BindingData() { if (!dtstart.Value.HasValue || !dtend.Value.HasValue) { return; } DateTime start = dtstart.Value.Value; DateTime end = dtend.Value.Value; if ((end - start).Days > 7) { end = start.AddDays(7); dtend.Value = end; } else if (start >= end) { end = start.AddDays(1); dtend.Value = end; } HashSet <short> hash = new HashSet <short>(); foreach (var item in sortlist) { item.Value.Collection.Clear(); hash.Add(item.Key); } foreach (KeyValuePair <short, string> item in chklist.SelectedItems) { ObservableDataSource <HistoryData> source; if (!sortlist.TryGetValue(item.Key, out source)) { source = new ObservableDataSource <HistoryData>(); source.SetXMapping(X => hTimeSpanAxis.ConvertToDouble(X.TimeStamp)); source.SetSourceMapping(App.Server[item.Key]); if (comodel.SelectedIndex == 0 || (comodel.SelectedIndex == 1 && sortlist.Count == 0)) //|| (comodel.SelectedIndex == 2 && (sortlist.Count == 0 || chklist.SelectedItems.Count == 1))) { plotterlist[item.Key] = chartPlotter1.AddLineGraph(source, 2, item.Value); } else { var innerPlotter = new InjectedPlotter() { SetViewportBinding = false }; var axis = new HorizontalDateTimeAxis(); innerPlotter.Children.Add(axis); innerPlotter.MainHorizontalAxis = axis; innerPlotter.Children.Add(new VerticalAxis() { Placement = AxisPlacement.Right }); innerPlotter.Children.Add(new VerticalAxisTitle() { Content = item.Value, Placement = AxisPlacement.Right }); chartPlotter1.Children.Add(innerPlotter); innerPlotter.AddLineGraph(source, 2, item.Value); plotterlist.Add(item.Key, innerPlotter); } sortlist.Add(item.Key, source); } hash.Remove(item.Key); var data = App.Server.ReadRaw(start, end, item.Key); if (data != null) { bool first = true; var temp = new HistoryData(item.Key, QUALITIES.QUALITY_GOOD, Storage.Empty, start); source.SuspendUpdate(); foreach (var p in data) { if (first) { temp.Value = p.Value; source.Collection.Add(temp); first = false; } source.Collection.Add(p); } if (source.Collection.Count == 0) { source.Collection.Add(temp); } temp = source.Collection[source.Collection.Count - 1]; temp.TimeStamp = end; source.Collection.Add(temp); source.ResumeUpdate(); } chartPlotter1.FitToView(); } foreach (short id in hash) { sortlist.Remove(id); IPlotterElement plotter; if (plotterlist.TryGetValue(id, out plotter)) { var chart = plotter as Plotter; if (chart != null) { for (int i = chart.Children.Count - 1; i >= 0; i--) { chart.Children[i].RemoveFromPlotter(); } } plotter.RemoveFromPlotter(); plotterlist.Remove(id); } } }
private void DrawPlots() { HorizontalAxis xAxis = (HorizontalAxis)plotter.MainHorizontalAxis; xAxis.TicksProvider = new LogarithmNumericTicksProvider(10); xAxis.LabelProvider = new UnroundingLabelProvider(); xAxis.ShowMajorLabels = true; xAxis.ShowMinorTicks = true; xAxis.SnapsToDevicePixels = true; xAxis.LabelProvider.SetCustomFormatter(info => info.Tick.ToString("#.######e0")); HorizontalAxisTitle HAT = new HorizontalAxisTitle() { Content = _xAxisInfo.AxisTitle }; plotter.MainHorizontalAxis = xAxis; plotter.Children.Add(HAT); ((NumericAxis)plotter.MainHorizontalAxis).AxisControl.TicksPath.Stroke = Brushes.Blue; VerticalAxis yAxis = (VerticalAxis)plotter.MainVerticalAxis; yAxis.TicksProvider = new NumericTicksProvider(); yAxis.LabelProvider = new UnroundingLabelProvider(); yAxis.ShowMajorLabels = true; yAxis.ShowMinorTicks = true; yAxis.SnapsToDevicePixels = true; VerticalAxisTitle VAT = new VerticalAxisTitle() { Content = _yAxisInfoList[0].AxisTitle }; plotter.MainVerticalAxis = yAxis; plotter.Children.Add(VAT); plotter.AxisGrid.DrawVerticalMinorTicks = true; plotter.AxisGrid.DrawHorizontalMinorTicks = true; plotter.MainVerticalAxis.Background = new LinearGradientBrush(Colors.White, Colors.LightGray, 90); var xPoints = _xAxisInfo.AxisDataPoints.AsXDataSource(); // Create the main plot foreach (AxisInfo yAxInfo in _yAxisInfoList) { var yPoints = yAxInfo.AxisDataPoints.AsYDataSource(); CompositeDataSource plot = xPoints.Join(yPoints); plotter.AddLineGraph(plot, yAxInfo.PlotColor, yAxInfo.PlotLineThickness, yAxInfo.AxisLegend); } // add secondary y-axis plots if any exist if (_yAxisInfoSecList != null) { InjectedPlotter innerPlotter = new InjectedPlotter(); innerPlotter.SetViewportBinding = false; plotter.Children.Add(innerPlotter); HorizontalAxis ax = new HorizontalAxis(); ax.Placement = AxisPlacement.Top; ax.TicksProvider = new LogarithmNumericTicksProvider(10); ax.LabelProvider = new UnroundingLabelProvider(); ax.LabelProvider.SetCustomFormatter(info => info.Tick.ToString("#.######e0")); ax.ShowMajorLabels = true; ax.ShowMinorTicks = true; ax.SnapsToDevicePixels = true; ax.AxisControl.TicksPath.Stroke = Brushes.Red; plotter.Children.Add(ax); VerticalAxis yAxisSec = new VerticalAxis() { TicksProvider = new NumericTicksProvider(), LabelProvider = new UnroundingLabelProvider(), ShowMinorTicks = true, ShowMajorLabels = true, SnapsToDevicePixels = true, Placement = AxisPlacement.Right }; VerticalAxisTitle VATsecondary = new VerticalAxisTitle() { Content = _yAxisInfoSecList[0].AxisTitle, Placement = AxisPlacement.Right }; innerPlotter.MainVerticalAxis = yAxisSec; innerPlotter.Children.Add(VATsecondary); innerPlotter.MainVerticalAxis.Background = new LinearGradientBrush(Colors.White, Colors.Red, 90); foreach (AxisInfo yAxInfoSec in _yAxisInfoSecList) { var ySecPoints = yAxInfoSec.AxisDataPoints.AsYDataSource(); CompositeDataSource plotSec = xPoints.Join(ySecPoints); /*innerP*/ plotter.AddLineGraph(plotSec, yAxInfoSec.PlotColor, yAxInfoSec.PlotLineThickness, yAxInfoSec.AxisLegend); } } }