示例#1
0
        public override View GetSampleContent(Context context)
        {
            chart                = new SfChart(context);
            chart.Title.Text     = "Electricity-Production";
            chart.Title.TextSize = 15;
            chart.SetBackgroundColor(Color.White);
            chart.ColorModel.ColorPalette = ChartColorPalette.Natural;

            chart.Legend.Visibility             = Visibility.Visible;
            chart.Legend.IconHeight             = 14;
            chart.Legend.IconWidth              = 14;
            chart.Legend.DockPosition           = ChartDock.Bottom;
            chart.Legend.ToggleSeriesVisibility = true;

            NumericalAxis categoryaxis = new NumericalAxis();

            categoryaxis.MajorTickStyle.TickSize = 8;
            categoryaxis.ShowMajorGridLines      = false;
            categoryaxis.Interval = 2;
            categoryaxis.EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Shift;
            chart.PrimaryAxis = categoryaxis;

            NumericalAxis numericalaxis = new NumericalAxis();

            numericalaxis.Title.Text                 = "Production (Billion as kWh)";
            numericalaxis.Minimum                    = 0;
            numericalaxis.Maximum                    = 600;
            numericalaxis.Interval                   = 100;
            numericalaxis.LabelStyle.LabelFormat     = "#'B'";
            numericalaxis.LineStyle.StrokeWidth      = 0;
            numericalaxis.MajorTickStyle.StrokeWidth = 0;
            chart.SecondaryAxis = numericalaxis;

            StepAreaSeries stepAreaSeries1 = new StepAreaSeries();

            stepAreaSeries1.ItemsSource     = MainPage.GetStepAreaData1();
            stepAreaSeries1.XBindingPath    = "XValue";
            stepAreaSeries1.YBindingPath    = "YValue";
            stepAreaSeries1.Label           = "Renewable";
            stepAreaSeries1.EnableAnimation = true;
            stepAreaSeries1.LegendIcon      = ChartLegendIcon.Rectangle;

            StepAreaSeries stepAreaSeries2 = new StepAreaSeries();

            stepAreaSeries2.ItemsSource     = MainPage.GetStepAreaData2();
            stepAreaSeries2.XBindingPath    = "XValue";
            stepAreaSeries2.YBindingPath    = "YValue";
            stepAreaSeries2.Label           = "Non-Renewable";
            stepAreaSeries2.EnableAnimation = true;
            stepAreaSeries2.LegendIcon      = ChartLegendIcon.Rectangle;

            chart.Series.Add(stepAreaSeries1);
            chart.Series.Add(stepAreaSeries2);

            return(chart);
        }
        //public Timer TimerAnimation
        //{
        //    get { return _timerAnimation; }
        //    set { _timerAnimation = value; }
        //}

        private void InitChart()
        {
            try
            {
                Chart.Series.Clear();

                if (this.ItemsAioViewModel.ItemType == ItemType.Digital)
                {
                    Chart.Series.Add(new StepAreaSeries());
                    //Chart.Series.Add(new AreaSeries());
                    //AreaSeries series = (AreaSeries)this.Chart.Series[0];
                    StepAreaSeries series = (StepAreaSeries)this.Chart.Series[0];
                    series.CategoryBinding = new PropertyNameDataPointBinding()
                    {
                        PropertyName = "Date"
                    };
                    series.ValueBinding = new PropertyNameDataPointBinding()
                    {
                        PropertyName = "Value"
                    };
                    series.Stroke          = Brushes.LightBlue;
                    series.Fill            = Brushes.LightBlue;
                    series.StrokeThickness = 2;

                    series.ItemsSource = ObservableCollection;
                }
                else if (this.ItemsAioViewModel.ItemType == ItemType.Analog)
                {
                    Chart.Series.Add(new LineSeries());
                    LineSeries series = (LineSeries)this.Chart.Series[0];
                    series.CategoryBinding = new PropertyNameDataPointBinding()
                    {
                        PropertyName = "Date"
                    };
                    series.ValueBinding = new PropertyNameDataPointBinding()
                    {
                        PropertyName = "Value"
                    };
                    series.Stroke          = Brushes.Blue;
                    series.StrokeThickness = 2;

                    series.ItemsSource = ObservableCollection;
                }
            }
            catch (Exception ex)
            {
                Logger.LogIndustrialMonitoring(ex);
            }
        }
示例#3
0
        private void OnChartTypeSelectionChanged1(object sender, SelectionChangedEventArgs e)
        {
            if (Basic_Chart != null)
            {
                if (Basic_Chart.Behaviors.Count == 0)
                {
                    Basic_Chart.Behaviors.Add(new ChartZoomPanBehavior());
                }
                (Basic_Chart.SecondaryAxis as NumericalAxis).ClearValue(NumericalAxis.MaximumProperty);
            }
            ComboBox comboBox = sender as ComboBox;

            if (comboBox.SelectedIndex == 0 && viewModel != null)
            {
                Histogram_Chart.Visibility       = Visibility.Collapsed;
                Basic_Chart.Visibility           = Visibility.Visible;
                Column_Chart.Visibility          = Visibility.Collapsed;
                Scatter_Chart.Visibility         = Visibility.Collapsed;
                Waterfall_Chart.Visibility       = Visibility.Collapsed;
                boxWhiskerChart.Visibility       = Visibility.Collapsed;
                SplineRangeArea_Chart.Visibility = Visibility.Collapsed;

                Basic_Chart.PrimaryAxis   = this.primaryAxis;
                Basic_Chart.SecondaryAxis = this.secondaryAxis;
                Basic_Chart.Legend        = this.legend;
                LineSeries series1 = new LineSeries();
                LineSeries series2 = new LineSeries();
                LineSeries series3 = new LineSeries();

                ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo();
                adornmentInfo1.ShowLabel  = false;
                adornmentInfo1.ShowMarker = true;
                adornmentInfo1.Symbol     = ChartSymbol.Ellipse;
                series1.AdornmentsInfo    = adornmentInfo1;

                ChartAdornmentInfo adornmentInfo2 = new ChartAdornmentInfo();
                adornmentInfo2.ShowLabel  = false;
                adornmentInfo2.ShowMarker = true;
                adornmentInfo2.Symbol     = ChartSymbol.Ellipse;
                series2.AdornmentsInfo    = adornmentInfo2;

                ChartAdornmentInfo adornmentInfo3 = new ChartAdornmentInfo();
                adornmentInfo3.ShowLabel  = false;
                adornmentInfo3.ShowMarker = true;
                adornmentInfo3.Symbol     = ChartSymbol.Ellipse;
                series3.AdornmentsInfo    = adornmentInfo3;

                series1.XBindingPath    = "Year";
                series1.YBindingPath    = "IND";
                series1.ItemsSource     = viewModel.power;
                series1.ShowTooltip     = true;
                series1.EnableAnimation = true;
                series1.Label           = "India";

                series2.XBindingPath    = "Year";
                series2.YBindingPath    = "GER";
                series2.ItemsSource     = viewModel.power;
                series2.ShowTooltip     = true;
                series2.EnableAnimation = true;
                series2.Label           = "Germany";

                series3.XBindingPath    = "Year";
                series3.YBindingPath    = "FRA";
                series3.ItemsSource     = viewModel.power;
                series3.EnableAnimation = true;
                series3.ShowTooltip     = true;
                series3.Label           = "France";

                Basic_Chart.Series.Clear();
                Basic_Chart.PrimaryAxis.ZoomFactor   = 1;
                Basic_Chart.SecondaryAxis.ZoomFactor = 1;
                Basic_Chart.Series.Add(series1);
                Basic_Chart.Series.Add(series2);
                Basic_Chart.Series.Add(series3);
            }
            else if (comboBox.SelectedIndex == 1 && viewModel != null)
            {
                Histogram_Chart.Visibility       = Visibility.Collapsed;
                Basic_Chart.Visibility           = Visibility.Visible;
                Column_Chart.Visibility          = Visibility.Collapsed;
                Scatter_Chart.Visibility         = Visibility.Collapsed;
                Waterfall_Chart.Visibility       = Visibility.Collapsed;
                boxWhiskerChart.Visibility       = Visibility.Collapsed;
                SplineRangeArea_Chart.Visibility = Visibility.Collapsed;

                Basic_Chart.PrimaryAxis   = this.primaryAxis;
                Basic_Chart.SecondaryAxis = this.secondaryAxis;
                Basic_Chart.Legend        = this.legend;
                SplineSeries series1 = new SplineSeries();
                SplineSeries series2 = new SplineSeries();
                SplineSeries series3 = new SplineSeries();

                ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo();
                adornmentInfo1.ShowLabel  = false;
                adornmentInfo1.ShowMarker = true;
                adornmentInfo1.Symbol     = ChartSymbol.Ellipse;
                series1.AdornmentsInfo    = adornmentInfo1;

                ChartAdornmentInfo adornmentInfo2 = new ChartAdornmentInfo();
                adornmentInfo2.ShowLabel  = false;
                adornmentInfo2.ShowMarker = true;
                adornmentInfo2.Symbol     = ChartSymbol.Ellipse;
                series2.AdornmentsInfo    = adornmentInfo2;

                ChartAdornmentInfo adornmentInfo3 = new ChartAdornmentInfo();
                adornmentInfo3.ShowLabel  = false;
                adornmentInfo3.ShowMarker = true;
                adornmentInfo3.Symbol     = ChartSymbol.Ellipse;
                series3.AdornmentsInfo    = adornmentInfo3;

                series1.XBindingPath    = "Year";
                series1.YBindingPath    = "IND";
                series1.ItemsSource     = viewModel.power;
                series1.EnableAnimation = true;
                series1.ShowTooltip     = true;
                series1.Label           = "India";

                series2.XBindingPath    = "Year";
                series2.YBindingPath    = "GER";
                series2.ItemsSource     = viewModel.power;
                series2.EnableAnimation = true;
                series2.ShowTooltip     = true;
                series2.Label           = "Germany";

                series3.XBindingPath    = "Year";
                series3.YBindingPath    = "FRA";
                series3.ItemsSource     = viewModel.power;
                series3.EnableAnimation = true;
                series3.ShowTooltip     = true;
                series3.Label           = "France";

                Basic_Chart.Series.Clear();
                Basic_Chart.PrimaryAxis.ZoomFactor   = 1;
                Basic_Chart.SecondaryAxis.ZoomFactor = 1;
                DoubleCollection doubleCollection = new DoubleCollection();
                doubleCollection.Add(5);
                doubleCollection.Add(3);
                series1.StrokeDashArray = doubleCollection;
                series2.StrokeDashArray = doubleCollection;
                series3.StrokeDashArray = doubleCollection;

                Basic_Chart.Series.Add(series1);
                Basic_Chart.Series.Add(series2);
                Basic_Chart.Series.Add(series3);
            }
            else if (comboBox.SelectedIndex == 2)
            {
                Histogram_Chart.Visibility       = Visibility.Collapsed;
                Basic_Chart.Visibility           = Visibility.Collapsed;
                Column_Chart.Visibility          = Visibility.Collapsed;
                Waterfall_Chart.Visibility       = Visibility.Collapsed;
                Scatter_Chart.Visibility         = Visibility.Collapsed;
                boxWhiskerChart.Visibility       = Visibility.Collapsed;
                SplineRangeArea_Chart.Visibility = Visibility.Visible;

                (SplineRangeArea_Chart.Series[0] as AdornmentSeries).AdornmentsInfo = new ChartAdornmentInfo()
                {
                    AdornmentsPosition  = AdornmentsPosition.TopAndBottom,
                    VerticalAlignment   = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    ShowLabel           = true,
                    LabelTemplate       = this.MainGrid.Resources["splineRangeAreaAdornment"] as DataTemplate
                };
            }
            else if (comboBox.SelectedIndex == 3 && viewModel != null)
            {
                Histogram_Chart.Visibility       = Visibility.Collapsed;
                Basic_Chart.Visibility           = Visibility.Collapsed;
                Column_Chart.Visibility          = Visibility.Collapsed;
                Waterfall_Chart.Visibility       = Visibility.Collapsed;
                Scatter_Chart.Visibility         = Visibility.Visible;
                boxWhiskerChart.Visibility       = Visibility.Collapsed;
                SplineRangeArea_Chart.Visibility = Visibility.Collapsed;
            }
            else if (comboBox.SelectedIndex == 4)
            {
                Basic_Chart.Visibility           = Visibility.Collapsed;
                Scatter_Chart.Visibility         = Visibility.Collapsed;
                Column_Chart.Visibility          = Visibility.Collapsed;
                Histogram_Chart.Visibility       = Visibility.Collapsed;
                Waterfall_Chart.Visibility       = Visibility.Collapsed;
                boxWhiskerChart.Visibility       = Visibility.Visible;
                SplineRangeArea_Chart.Visibility = Visibility.Collapsed;
            }
            else if (comboBox.SelectedIndex == 5 && viewModel != null)
            {
                Histogram_Chart.Visibility       = Visibility.Collapsed;
                Basic_Chart.Visibility           = Visibility.Collapsed;
                Column_Chart.Visibility          = Visibility.Visible;
                Scatter_Chart.Visibility         = Visibility.Collapsed;
                Waterfall_Chart.Visibility       = Visibility.Collapsed;
                boxWhiskerChart.Visibility       = Visibility.Collapsed;
                SplineRangeArea_Chart.Visibility = Visibility.Collapsed;
            }
            else if (comboBox.SelectedIndex == 6 && viewModel != null)
            {
                Histogram_Chart.Visibility       = Visibility.Collapsed;
                Basic_Chart.Visibility           = Visibility.Visible;
                Column_Chart.Visibility          = Visibility.Collapsed;
                Scatter_Chart.Visibility         = Visibility.Collapsed;
                Waterfall_Chart.Visibility       = Visibility.Collapsed;
                boxWhiskerChart.Visibility       = Visibility.Collapsed;
                SplineRangeArea_Chart.Visibility = Visibility.Collapsed;

                Basic_Chart.PrimaryAxis   = this.primaryAxis;
                Basic_Chart.SecondaryAxis = this.secondaryAxis;
                Basic_Chart.Legend        = this.legend;
                StepLineSeries series1 = new StepLineSeries();
                StepLineSeries series2 = new StepLineSeries();
                StepLineSeries series3 = new StepLineSeries();

                ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo();
                adornmentInfo1.ShowLabel  = false;
                adornmentInfo1.ShowMarker = true;
                adornmentInfo1.Symbol     = ChartSymbol.Ellipse;
                series1.AdornmentsInfo    = adornmentInfo1;

                ChartAdornmentInfo adornmentInfo2 = new ChartAdornmentInfo();
                adornmentInfo2.ShowLabel  = false;
                adornmentInfo2.ShowMarker = true;
                adornmentInfo2.Symbol     = ChartSymbol.Ellipse;
                series2.AdornmentsInfo    = adornmentInfo2;

                ChartAdornmentInfo adornmentInfo3 = new ChartAdornmentInfo();
                adornmentInfo3.ShowLabel  = false;
                adornmentInfo3.ShowMarker = true;
                adornmentInfo3.Symbol     = ChartSymbol.Ellipse;
                series3.AdornmentsInfo    = adornmentInfo3;

                series1.XBindingPath = "Year";
                series1.YBindingPath = "IND";
                series1.ShowTooltip  = true;
                series1.ItemsSource  = viewModel.power;
                series1.Label        = "India";

                series2.XBindingPath = "Year";
                series2.YBindingPath = "GER";
                series2.ItemsSource  = viewModel.power;
                series2.ShowTooltip  = true;
                series2.Label        = "Germany";

                series3.XBindingPath = "Year";
                series3.YBindingPath = "FRA";
                series3.ItemsSource  = viewModel.power;
                series3.ShowTooltip  = true;
                series3.Label        = "France";

                Basic_Chart.Series.Clear();
                Basic_Chart.PrimaryAxis.ZoomFactor   = 1;
                Basic_Chart.SecondaryAxis.ZoomFactor = 1;
                Basic_Chart.Series.Add(series1);
                Basic_Chart.Series.Add(series2);
                Basic_Chart.Series.Add(series3);
            }
            else if (comboBox.SelectedIndex == 7 && viewModel != null)
            {
                Histogram_Chart.Visibility       = Visibility.Collapsed;
                Basic_Chart.Visibility           = Visibility.Visible;
                Column_Chart.Visibility          = Visibility.Collapsed;
                Scatter_Chart.Visibility         = Visibility.Collapsed;
                Waterfall_Chart.Visibility       = Visibility.Collapsed;
                boxWhiskerChart.Visibility       = Visibility.Collapsed;
                SplineRangeArea_Chart.Visibility = Visibility.Collapsed;

                Basic_Chart.PrimaryAxis   = this.primaryAxis;
                Basic_Chart.SecondaryAxis = this.secondaryAxis;
                Basic_Chart.Legend        = this.legend;
                StepAreaSeries     series1        = new StepAreaSeries();
                StepAreaSeries     series2        = new StepAreaSeries();
                DataTemplate       template1      = MainGrid.Resources["labelTemplateStepArea"] as DataTemplate;
                DataTemplate       template2      = MainGrid.Resources["labelTemplateStepArea1"] as DataTemplate;
                ChartAdornmentInfo adornmentInfo1 = new ChartAdornmentInfo
                {
                    ShowLabel     = true,
                    LabelTemplate = template1,
                };
                ChartAdornmentInfo adornmentInfo2 = new ChartAdornmentInfo
                {
                    ShowLabel     = true,
                    LabelTemplate = template2,
                };

                series1.AdornmentsInfo  = adornmentInfo1;
                series1.XBindingPath    = "Year";
                series1.YBindingPath    = "AUS";
                series1.Label           = "Australia";
                series1.ItemsSource     = viewModel.power;
                series1.StrokeThickness = 2;
                series1.Stroke          = new SolidColorBrush(Color.FromArgb(0xFF, 0x99, 0xDE, 0x4A));
                series1.Interior        = new SolidColorBrush(Color.FromArgb(0x78, 0x99, 0xDE, 0x4A));
                series1.ShowTooltip     = true;
                series2.AdornmentsInfo  = adornmentInfo2;
                series2.XBindingPath    = "Year";
                series2.YBindingPath    = "UK";
                series2.Label           = "UK";
                series2.ItemsSource     = viewModel.power;
                series2.StrokeThickness = 2;
                series2.Stroke          = new SolidColorBrush(Color.FromArgb(0xFF, 0xA4, 0xC5, 0xF4));
                series2.Interior        = new SolidColorBrush(Color.FromArgb(0x78, 0xA4, 0xC5, 0xF4));
                series2.ShowTooltip     = true;
                Basic_Chart.Series.Clear();
                Basic_Chart.PrimaryAxis.ZoomFactor   = 1;
                Basic_Chart.SecondaryAxis.ZoomFactor = 1;
                Basic_Chart.Series.Add(series1);
                Basic_Chart.Series.Add(series2);
            }
            else if (comboBox.SelectedIndex == 8)
            {
                Basic_Chart.Visibility           = Visibility.Collapsed;
                Scatter_Chart.Visibility         = Visibility.Collapsed;
                Column_Chart.Visibility          = Visibility.Collapsed;
                Histogram_Chart.Visibility       = Visibility.Visible;
                boxWhiskerChart.Visibility       = Visibility.Collapsed;
                Waterfall_Chart.Visibility       = Visibility.Collapsed;
                SplineRangeArea_Chart.Visibility = Visibility.Collapsed;
            }
            else
            {
                Basic_Chart.Visibility           = Visibility.Collapsed;
                Scatter_Chart.Visibility         = Visibility.Collapsed;
                Column_Chart.Visibility          = Visibility.Collapsed;
                Histogram_Chart.Visibility       = Visibility.Collapsed;
                boxWhiskerChart.Visibility       = Visibility.Collapsed;
                Waterfall_Chart.Visibility       = Visibility.Visible;
                SplineRangeArea_Chart.Visibility = Visibility.Collapsed;
            }
        }
示例#4
0
        private void InitChart()
        {
            try
            {
                ChartBrushes = new List <Brush>();
                ChartBrushes.Add(Brushes.Blue);
                ChartBrushes.Add(Brushes.Green);
                ChartBrushes.Add(Brushes.LightSalmon);
                ChartBrushes.Add(Brushes.DarkRed);
                ChartBrushes.Add(Brushes.Gold);
                ChartBrushes.Add(Brushes.CadetBlue);
                ChartBrushes.Add(Brushes.Coral);
                ChartBrushes.Add(Brushes.Crimson);
                ChartBrushes.Add(Brushes.Indigo);
                ChartBrushes.Add(Brushes.PaleGreen);
                ChartBrushes.Add(Brushes.OrangeRed);
                ChartBrushes.Add(Brushes.Purple);
                ChartBrushes.Add(Brushes.Fuchsia);
                ChartBrushes.Add(Brushes.AliceBlue);
                ChartBrushes.Add(Brushes.Orange);
                ChartBrushes.Add(Brushes.Purple);
                ChartBrushes.Add(Brushes.Chartreuse);
                ChartBrushes.Add(Brushes.MediumBlue);
                ChartBrushes.Add(Brushes.Chocolate);

                int countItems = ItemsId.Count;

                if (ItemsId != null)
                {
                    for (int i = 0; i < countItems; i++)
                    {
                        switch (ChartType)
                        {
                        case ChartType.AreaSeries:
                            Chart.Series.Add(new AreaSeries());
                            AreaSeries series1 = (AreaSeries)this.Chart.Series[i];
                            series1.CategoryBinding = new PropertyNameDataPointBinding()
                            {
                                PropertyName = "Time"
                            };
                            series1.ValueBinding = new PropertyNameDataPointBinding()
                            {
                                PropertyName = "Value"
                            };
                            series1.Stroke          = ChartBrushes[i];
                            series1.StrokeThickness = 2;
                            break;

                        case ChartType.LineSeries:
                            Chart.Series.Add(new LineSeries());
                            LineSeries series2 = (LineSeries)this.Chart.Series[i];
                            series2.CategoryBinding = new PropertyNameDataPointBinding()
                            {
                                PropertyName = "Time"
                            };
                            series2.ValueBinding = new PropertyNameDataPointBinding()
                            {
                                PropertyName = "Value"
                            };
                            series2.Stroke          = ChartBrushes[i];
                            series2.StrokeThickness = 2;
                            break;

                        case ChartType.PointSeries:
                            Chart.Series.Add(new PointSeries());
                            PointSeries series3 = (PointSeries)this.Chart.Series[i];
                            series3.CategoryBinding = new PropertyNameDataPointBinding()
                            {
                                PropertyName = "Time"
                            };
                            series3.ValueBinding = new PropertyNameDataPointBinding()
                            {
                                PropertyName = "Value"
                            };
                            break;

                        case ChartType.SplineAreaSeries:
                            Chart.Series.Add(new SplineAreaSeries());
                            SplineAreaSeries series4 = (SplineAreaSeries)this.Chart.Series[i];
                            series4.CategoryBinding = new PropertyNameDataPointBinding()
                            {
                                PropertyName = "Time"
                            };
                            series4.ValueBinding = new PropertyNameDataPointBinding()
                            {
                                PropertyName = "Value"
                            };
                            series4.Stroke          = ChartBrushes[i];
                            series4.StrokeThickness = 2;
                            break;

                        case ChartType.SplineSeries:
                            Chart.Series.Add(new SplineSeries());
                            SplineSeries series5 = (SplineSeries)this.Chart.Series[i];
                            series5.CategoryBinding = new PropertyNameDataPointBinding()
                            {
                                PropertyName = "Time"
                            };
                            series5.ValueBinding = new PropertyNameDataPointBinding()
                            {
                                PropertyName = "Value"
                            };
                            series5.Stroke          = ChartBrushes[i];
                            series5.StrokeThickness = 2;
                            break;

                        case ChartType.StepAreaSeries:
                            Chart.Series.Add(new StepAreaSeries());
                            StepAreaSeries series6 = (StepAreaSeries)this.Chart.Series[i];
                            series6.CategoryBinding = new PropertyNameDataPointBinding()
                            {
                                PropertyName = "Time"
                            };
                            series6.ValueBinding = new PropertyNameDataPointBinding()
                            {
                                PropertyName = "Value"
                            };
                            series6.Stroke          = ChartBrushes[i];
                            series6.StrokeThickness = 2;
                            break;

                        case ChartType.StepLineSeries:
                            Chart.Series.Add(new StepLineSeries());
                            StepLineSeries series7 = (StepLineSeries)this.Chart.Series[i];
                            series7.CategoryBinding = new PropertyNameDataPointBinding()
                            {
                                PropertyName = "Time"
                            };
                            series7.ValueBinding = new PropertyNameDataPointBinding()
                            {
                                PropertyName = "Value"
                            };
                            series7.Stroke          = ChartBrushes[i];
                            series7.StrokeThickness = 2;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogIndustrialMonitoring(ex);
            }
        }
示例#5
0
        void WindowChartHistory_ShowDataCompleted(object sender, ShowDataCompletedEventArgs e)
        {
            try
            {
                if (ItemsId.Count == 1)
                {
                    TextBlockTitle.Text = string.Format("{0} {1}-{2}", e.CurrentItem.ItemName, this.StartTime.ToString(), this.EndTime.ToString());
                }
                else
                {
                    TextBlockTitle.Text = string.Format("Compare {0}-{1}", this.StartTime.ToString(), this.EndTime.ToString());
                }

                switch (ChartType)
                {
                case ChartType.AreaSeries:
                    AreaSeries series1 = (AreaSeries)this.Chart.Series[e.ItemId.Key];
                    series1.ItemsSource = e.Data;
                    break;

                case ChartType.LineSeries:
                    LineSeries series2 = (LineSeries)this.Chart.Series[e.ItemId.Key];
                    series2.ItemsSource = e.Data;
                    break;

                case ChartType.PointSeries:
                    PointSeries series3 = (PointSeries)this.Chart.Series[e.ItemId.Key];
                    series3.ItemsSource = e.Data;
                    break;

                case ChartType.SplineAreaSeries:
                    SplineAreaSeries series4 = (SplineAreaSeries)this.Chart.Series[e.ItemId.Key];
                    series4.ItemsSource = e.Data;
                    break;

                case ChartType.SplineSeries:
                    SplineSeries series5 = (SplineSeries)this.Chart.Series[e.ItemId.Key];
                    series5.ItemsSource = e.Data;
                    break;

                case ChartType.StepAreaSeries:
                    StepAreaSeries series6 = (StepAreaSeries)this.Chart.Series[e.ItemId.Key];
                    series6.ItemsSource = e.Data;
                    break;

                case ChartType.StepLineSeries:
                    StepLineSeries series7 = (StepLineSeries)this.Chart.Series[e.ItemId.Key];
                    series7.ItemsSource = e.Data;
                    break;
                }

                Chart.Zoom = new Size(1, 1);

                if (e.GenerateLegend)
                {
                    ChartLegend.Items.Add(new LegendItem()
                    {
                        MarkerFill = ChartBrushes[e.ItemId.Key], Title = e.CurrentItem.ItemName
                    });
                }

                BusyIndicator.IsBusy = false;
            }
            catch (Exception ex)
            {
                Logger.LogIndustrialMonitoring(ex);
            }
        }
示例#6
0
        public void RenderGraphic(string CompoundString, bool showGroups)
        {
            VariantChart.Series.Clear();
            Graphics graphics = new Graphics(CompoundString, this);
            var      denseArr = graphics.DenseFunction();

            ViewModel denseViewModel = new ViewModel(denseArr.Item1);

            GraphicTop.Text = CompoundString;
            NumericalAxis primary = new NumericalAxis()
            {
                Header  = "Нормализованные величины",
                Maximum = 1.01
            };
            NumericalAxis secondary = new NumericalAxis()
            {
                Header  = "Плотность величины",
                Maximum = denseArr.Item2
            };

            VariantChart.PrimaryAxis   = primary;
            VariantChart.SecondaryAxis = secondary;
            SplineAreaSeries denseFunction = new SplineAreaSeries()
            {
                ItemsSource  = denseViewModel.Data,
                XBindingPath = "AddressOfPrimitive",
                YBindingPath = "CountInPrimitive",
                SplineType   = SplineType.Monotonic,
                Interior     = new SolidColorBrush(System.Windows.Media.Color.FromArgb(128, 0, 0, 0))
            };

            if (showGroups)
            {
                List <Graphics.ItemPrimitive>[] groups = graphics.GroupFunction();
                for (int i = 0; i < groups.Length; i++)
                {
                    SolidColorBrush solidColorBrush;
                    if (i % 2 == 0)
                    {
                        solidColorBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(180, 239, 154, 154));
                    }
                    else
                    {
                        solidColorBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(180, 63, 81, 181));
                    }
                    ViewModel      groupViewModel = new ViewModel(groups[i]);
                    StepAreaSeries groupsFunction = new StepAreaSeries()
                    {
                        ItemsSource  = groupViewModel.Data,
                        XBindingPath = "AddressOfPrimitive",
                        YBindingPath = "CountInPrimitive",
                        Interior     = solidColorBrush
                    };
                    VariantChart.Series.Add(groupsFunction);
                }
                ViewModel    medianas         = new ViewModel(graphics.MedianaFunction());
                ColumnSeries medianasFunction = new ColumnSeries()
                {
                    ItemsSource    = medianas.Data,
                    XBindingPath   = "AddressOfPrimitive",
                    YBindingPath   = "CountInPrimitive",
                    Interior       = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 0, 0, 0)),
                    SegmentSpacing = 0.1
                };
                //VariantChart.Series.Add(medianasFunction);
            }
            VariantChart.Series.Add(denseFunction);
        }