public void addSeries(List<KeyValuePair<double, double>> list, int index)
 {
     ScatterSeries scatter = new ScatterSeries();
     scatter.Title = "Cluster " + index;
     scatter.DependentValuePath = "Value";
     scatter.IndependentValuePath = "Key";
     scatter.ItemsSource = list;
     GraphObj.Series.Add(scatter);
 }
        public void addSeries(Dictionary<double, double> slownik)
        {
            ScatterSeries series = new ScatterSeries();
            series.Name = "nazwa";
            series.IndependentValuePath = "Key";
            series.DependentValuePath = "Value";
            series.ItemsSource = slownik;

            Style s = new Style(typeof(ScatterDataPoint), chart.Palette[chart.Series.Count % chart.Palette.Count]["DataPointStyle"] as Style);
            s.Setters.Add(new Setter(OpacityProperty, 100.0));
            s.Setters.Add(new Setter(BackgroundProperty, getColorBrush()));

            series.DataPointStyle = s;

            chart.Series.Add(series);
        }
 public void AutomaticMinimumAndMaximum()
 {
     Chart chart = new Chart();
     ScatterSeries series = new ScatterSeries();
     series.IndependentValueBinding = new Binding();
     series.ItemsSource = new int[] { 100 };
     chart.Series.Add(series);
     TestAsync(
         chart,
         () =>
         {
             foreach (LinearAxis axis in chart.ActualAxes)
             {
                 Assert.IsTrue((99 == axis.ActualMinimum) && (axis.ActualMaximum == 101));
             }
         });
 }
        private void SetGraph(string strataValue, List<SimpleDataValue> actualValues, List<SimpleDataValue> trendValues, List<SimpleDataValue> aberrationValues, List<DataGridRow> aberrationDetails)
        {
            StackPanel chartPanel = new StackPanel();
            chartPanel.Margin = (Thickness)this.Resources["genericElementMargin"];
            chartPanel.Visibility = System.Windows.Visibility.Collapsed;
            strataPanelList.Add(chartPanel);

            if (GadgetOptions.StrataVariableNames.Count == 0)
            {
                panelMain.Children.Add(chartPanel);
            }
            else
            {
                TextBlock txtExpanderHeader = new TextBlock();
                txtExpanderHeader.Text = strataValue;
                txtExpanderHeader.Style = this.Resources["genericOutputExpanderText"] as Style;

                Expander expander = new Expander();
                expander.Margin = (Thickness)this.Resources["expanderMargin"]; //new Thickness(6, 2, 6, 6);
                expander.IsExpanded = true;
                expander.Header = txtExpanderHeader;
                expander.Visibility = System.Windows.Visibility.Collapsed;

                expander.Content = chartPanel;
                chartPanel.Tag = txtExpanderHeader.Text;
                panelMain.Children.Add(expander);
                strataExpanderList.Add(expander);
            }

            Chart chart = new Chart();

            LinearAxis dependentAxis = new LinearAxis();
            dependentAxis.Orientation = AxisOrientation.Y;
            dependentAxis.Minimum = 0;
            dependentAxis.ShowGridLines = true;

            CategoryAxis independentAxis = new CategoryAxis();
            independentAxis.Orientation = AxisOrientation.X;
            independentAxis.SortOrder = CategorySortOrder.Ascending;
            independentAxis.AxisLabelStyle = Resources["RotateAxisAberrationStyle"] as Style;

            chart.PlotAreaStyle = new Style();
            chart.PlotAreaStyle.Setters.Add(new Setter(Chart.BackgroundProperty, Brushes.White));

            dependentAxis.GridLineStyle = new Style();
            dependentAxis.GridLineStyle.Setters.Add(new Setter(Line.StrokeProperty, Brushes.LightGray));

            //System.Windows.Controls.DataVisualization.Charting.Chart.BackgroundProperty

            try
            {
                independentAxis.AxisLabelStyle.Setters.Add(new Setter(AxisLabel.StringFormatProperty, "{0:d}"));
            }
            catch (Exception)
            {
                //already added
            }

            LineSeries series1 = new LineSeries();
            series1.IndependentValuePath = "IndependentValue";
            series1.DependentValuePath = "DependentValue";
            series1.ItemsSource = actualValues;
            series1.Title = DashboardSharedStrings.GADGET_ABERRATION_ACTUAL;
            series1.DependentRangeAxis = dependentAxis;
            series1.IndependentAxis = independentAxis;

            LineSeries series2 = new LineSeries();
            series2.IndependentValuePath = "IndependentValue";
            series2.DependentValuePath = "DependentValue";
            series2.ItemsSource = trendValues;
            series2.Title = DashboardSharedStrings.GADGET_ABERRATION_EXPECTED;
            series2.DependentRangeAxis = dependentAxis;
            series2.IndependentAxis = independentAxis;
            series2.PolylineStyle = Resources["GooglePolylineAberrationStyle"] as Style;
            series2.DataPointStyle = Resources["GoogleDataPointAberrationStyle"] as Style;

            ScatterSeries series3 = new ScatterSeries();
            series3.IndependentValuePath = "IndependentValue";
            series3.DependentValuePath = "DependentValue";
            series3.ItemsSource = aberrationValues;
            series3.Title = DashboardSharedStrings.GADGET_ABERRATION;
            series3.DependentRangeAxis = dependentAxis;
            series3.IndependentAxis = independentAxis;
            series3.DataPointStyle = Resources["DataPointAberrationStyle"] as Style;

            chart.Series.Add(series1);
            chart.Series.Add(series3);
            chart.Series.Add(series2);
            chart.Height = 400;

            //if (actualValues.Count > 37)
            //{
            //    chart.Width = (actualValues.Count * (871.0 / 37.0)) + 129;
            //}
            //else
            //{
            //    chart.Width = 1000;
            //}
            chart.BorderThickness = new Thickness(0);
            chart.Margin = new Thickness(6, -20, 6, 6);
            //chart.Width = (actualValues.Count * (871.0 / 37.0)) + 539;
            //Label title = new Label();
            //title.Content = strataValue;
            //title.Margin = new Thickness(10);
            //title.FontWeight = FontWeights.Bold;

            //panelMain.Children.Add(title);
            //panelMain.Children.Add(chart);
            ScrollViewer sv = new ScrollViewer();
            sv.MaxHeight = 400;
            sv.MaxWidth = System.Windows.SystemParameters.PrimaryScreenWidth - 125;
            //if (actualValues.Count > 37)
            //{
                chart.Width = (actualValues.Count * (871.0 / 37.0)) + 229;
            //}
            //else
            //{
            //    sv.Width = 900;
            //}
            sv.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
            //sv.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            sv.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left;
            sv.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            sv.Content = chart;

            chartPanel.Children.Add(sv);

            if (aberrationDetails.Count == 0)
            {
                Label noAbberration = new Label();
                noAbberration.Content = DashboardSharedStrings.GADGET_NO_ABERRATIONS_FOUND;
                noAbberration.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                noAbberration.Margin = new Thickness(0, 0, 0, 0);
                noAbberration.FontWeight = FontWeights.Bold;
                noAbberration.Foreground = Brushes.Red;
                //panelMain.Children.Add(noAbberration);
                chartPanel.Children.Add(noAbberration);
            }
            else
            {
                Label abberrationFound = new Label();
                abberrationFound.Content = DashboardSharedStrings.GADGET_ABERRATIONS_FOUND;
                abberrationFound.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                abberrationFound.Margin = new Thickness(0, 0, 0, 5);
                abberrationFound.FontWeight = FontWeights.Bold;
                abberrationFound.Foreground = Brushes.Red;
                //panelMain.Children.Add(abberrationFound);
                chartPanel.Children.Add(abberrationFound);

                Grid grid = new Grid();
                grid.SnapsToDevicePixels = true;
                grid.HorizontalAlignment = HorizontalAlignment.Center;
                grid.Margin = new Thickness(0, 0, 0, 0);

                ColumnDefinition column1 = new ColumnDefinition();
                ColumnDefinition column2 = new ColumnDefinition();
                ColumnDefinition column3 = new ColumnDefinition();
                ColumnDefinition column4 = new ColumnDefinition();

                column1.Width = GridLength.Auto;
                column2.Width = GridLength.Auto;
                column3.Width = GridLength.Auto;
                column4.Width = GridLength.Auto;

                grid.ColumnDefinitions.Add(column1);
                grid.ColumnDefinitions.Add(column2);
                grid.ColumnDefinitions.Add(column3);
                grid.ColumnDefinitions.Add(column4);

                RowDefinition rowDefHeader = new RowDefinition();
                rowDefHeader.Height = new GridLength(25);
                grid.RowDefinitions.Add(rowDefHeader); //grdFreq.RowDefinitions.Add(rowDefHeader);

                for (int y = 0; y < /*grdFreq*/grid.ColumnDefinitions.Count; y++)
                {
                    Rectangle rctHeader = new Rectangle();
                    rctHeader.Style = this.Resources["gridHeaderCellRectangle"] as Style;
                    Grid.SetRow(rctHeader, 0);
                    Grid.SetColumn(rctHeader, y);
                    grid.Children.Add(rctHeader); //grdFreq.Children.Add(rctHeader);
                }

                TextBlock txtValHeader = new TextBlock();
                txtValHeader.Text = DashboardSharedStrings.GADGET_ABERRATION_DATE;
                txtValHeader.Style = this.Resources["columnHeadingText"] as Style;
                Grid.SetRow(txtValHeader, 0);
                Grid.SetColumn(txtValHeader, 0);
                grid.Children.Add(txtValHeader); //grdFreq.Children.Add(txtValHeader);

                TextBlock txtFreqHeader = new TextBlock();
                txtFreqHeader.Text = DashboardSharedStrings.GADGET_ABERRATION_COUNT;
                txtFreqHeader.Style = this.Resources["columnHeadingText"] as Style;
                Grid.SetRow(txtFreqHeader, 0);
                Grid.SetColumn(txtFreqHeader, 1);
                grid.Children.Add(txtFreqHeader); //grdFreq.Children.Add(txtFreqHeader);

                TextBlock txtPctHeader = new TextBlock();
                txtPctHeader.Text = DashboardSharedStrings.GADGET_ABERRATION_EXPECTED;
                txtPctHeader.Style = this.Resources["columnHeadingText"] as Style;
                Grid.SetRow(txtPctHeader, 0);
                Grid.SetColumn(txtPctHeader, 2);
                grid.Children.Add(txtPctHeader); //grdFreq.Children.Add(txtPctHeader);

                TextBlock txtAccuHeader = new TextBlock();
                txtAccuHeader.Text = DashboardSharedStrings.GADGET_ABERRATION_DIFF;
                txtAccuHeader.Style = this.Resources["columnHeadingText"] as Style;
                Grid.SetRow(txtAccuHeader, 0);
                Grid.SetColumn(txtAccuHeader, 3);
                grid.Children.Add(txtAccuHeader);

                //panelMain.Children.Add(grid);
                chartPanel.Children.Add(grid);

                int rowcount = 1;
                foreach (DataGridRow aberrationDetail in aberrationDetails)
                {
                    RowDefinition rowDef = new RowDefinition();
                    grid.RowDefinitions.Add(rowDef);

                    TextBlock txtDate = new TextBlock();
                    txtDate.Text = aberrationDetail.Date.ToShortDateString();
                    txtDate.Margin = new Thickness(2);
                    txtDate.VerticalAlignment = VerticalAlignment.Center;
                    txtDate.HorizontalAlignment = HorizontalAlignment.Center;
                    Grid.SetRow(txtDate, rowcount);
                    Grid.SetColumn(txtDate, 0);
                    grid.Children.Add(txtDate);

                    TextBlock txtFreq = new TextBlock();
                    txtFreq.Text = aberrationDetail.Frequency.ToString();
                    txtFreq.Margin = new Thickness(2);
                    txtFreq.VerticalAlignment = VerticalAlignment.Center;
                    txtFreq.HorizontalAlignment = HorizontalAlignment.Center;
                    Grid.SetRow(txtFreq, rowcount);
                    Grid.SetColumn(txtFreq, 1);
                    grid.Children.Add(txtFreq);

                    TextBlock txtAvg = new TextBlock();
                    txtAvg.Text = aberrationDetail.RunningAverage.ToString("N2");
                    txtAvg.Margin = new Thickness(2);
                    txtAvg.VerticalAlignment = VerticalAlignment.Center;
                    txtAvg.HorizontalAlignment = HorizontalAlignment.Center;
                    Grid.SetRow(txtAvg, rowcount);
                    Grid.SetColumn(txtAvg, 2);
                    grid.Children.Add(txtAvg);

                    TextBlock txtDelta = new TextBlock();
                    txtDelta.Text = "  " + aberrationDetail.Delta.ToString("N2") + " standard deviations  ";

                    StackPanel pnl = new StackPanel();
                    pnl.Orientation = Orientation.Horizontal;
                    pnl.VerticalAlignment = VerticalAlignment.Center;
                    pnl.HorizontalAlignment = HorizontalAlignment.Center;
                    pnl.Children.Add(txtDelta);

                    Grid.SetRow(pnl, rowcount);
                    Grid.SetColumn(pnl, 3);
                    grid.Children.Add(pnl);

                    rowcount++;
                }

                int rdcount = 0;
                foreach (RowDefinition rd in grid.RowDefinitions)
                {
                    int cdcount = 0;
                    foreach (ColumnDefinition cd in grid.ColumnDefinitions)
                    {
                        //Rectangle rctBorder = new Rectangle();
                        //rctBorder.Stroke = Brushes.Black;
                        //Grid.SetRow(rctBorder, rdcount);
                        //Grid.SetColumn(rctBorder, cdcount);
                        //grid.Children.Add(rctBorder);
                        //cdcount++;
                        Border border = new Border();
                        border.Style = this.Resources["gridCellBorder"] as Style;

                        if (rdcount == 0)
                        {
                            border.BorderThickness = new Thickness(border.BorderThickness.Left, border.BorderThickness.Bottom, border.BorderThickness.Right, border.BorderThickness.Bottom);
                        }
                        if (cdcount == 0)
                        {
                            border.BorderThickness = new Thickness(border.BorderThickness.Right, border.BorderThickness.Top, border.BorderThickness.Right, border.BorderThickness.Bottom);
                        }

                        Grid.SetRow(border, rdcount);
                        Grid.SetColumn(border, cdcount);
                        grid.Children.Add(border);
                        cdcount++;
                    }
                    rdcount++;
                }
            }
        }
Example #5
0
        bool ProcessSeriesData(ref List<object> listOfSeries, string chartType, string seriesDataString, ref string failOverMessage)
        {
            bool parsed = false;
            bool isSingleSeries = false;

            List<ColumnSeries> columnSeriesList = new List<ColumnSeries>();

            string[] seriesDataStringArray = seriesDataString.Split(new string[] { Statics.SeparateLineSeries }, StringSplitOptions.RemoveEmptyEntries);

            if (seriesDataStringArray.Length < 1)
            {
                isSingleSeries = true;
            }

            foreach (string lineSeriesItemString in seriesDataStringArray)
            {
                object series;
                switch (chartType.ToUpper().Replace(" ",""))
                {
                    case Statics.Area:
                        series = new AreaSeries();
                        ((AreaSeries)series).IndependentValuePath = "Key";
                        ((AreaSeries)series).DependentValuePath = "Value";
                        break;

                    case Statics.Bar:
                        series = new ColumnSeries();
                        ((ColumnSeries)series).IndependentValuePath = "Key";
                        ((ColumnSeries)series).DependentValuePath = "Value";
                        break;

                    case Statics.Bubble:
                        series = new BubbleSeries();
                        ((BubbleSeries)series).IndependentValuePath = "Key";
                        ((BubbleSeries)series).DependentValuePath = "Value";
                        break;

                    case Statics.RotatedBar:
                        series = new BarSeries();
                        ((BarSeries)series).IndependentValuePath = "Key";
                        ((BarSeries)series).DependentValuePath = "Value";
                        break;

                    case Statics.Histogram:
                        series = new ColumnSeries();
                        ((ColumnSeries)series).IndependentValuePath = "Key";
                        ((ColumnSeries)series).DependentValuePath = "Value";
                        break;

                    case Statics.Line:
                        series = new LineSeries();
                        ((LineSeries)series).IndependentValuePath = "Key";
                        ((LineSeries)series).DependentValuePath = "Value";
                        break;

                    case Statics.Pie:
                        series = new PieSeries();
                        ((PieSeries)series).IndependentValuePath = "Key";
                        ((PieSeries)series).DependentValuePath = "Value";
                        break;

                    case Statics.Scatter:
                        series = new ScatterSeries();
                        ((ScatterSeries)series).IndependentValuePath = "Key";
                        ((ScatterSeries)series).DependentValuePath = "Value";
                        break;

                    case Statics.Stacked:
                        //series = new StackedBarSeries();
                        //((StackedBarSeries)series).IndependentValuePath = "Key";
                        //((StackedBarSeries)series).DependentValuePath = "Value";

                    case Statics.TreeMap:
                    default:
                        failOverMessage = "The specified graph type supplied in the input parameters (initParams) could not be parsed.";
                        return false;
                }

                string[] titleSplit = lineSeriesItemString.Split(new string[] { Statics.LineSeriesTitle }, StringSplitOptions.None);

                if (titleSplit.Length == 3)
                {
                    switch (chartType.ToUpper().Replace(" ", ""))
                    {
                        case Statics.Area:
                            ((AreaSeries)series).Title = titleSplit[1];
                            break;

                        case Statics.Bar:
                            ((ColumnSeries)series).Title = titleSplit[1];
                            break;

                        case Statics.Bubble:
                            ((BubbleSeries)series).Title = titleSplit[1];
                            break;

                        case Statics.RotatedBar:
                            ((BarSeries)series).Title = titleSplit[1];
                            break;

                        case Statics.Histogram:
                            ((ColumnSeries)series).Title = titleSplit[1];
                            break;

                        case Statics.Line:
                            ((LineSeries)series).Title = titleSplit[1];
                            break;

                        case Statics.Pie:
                            ((PieSeries)series).Title = titleSplit[1];
                            break;

                        case Statics.Scatter:
                            ((ScatterSeries)series).Title = titleSplit[1];
                            break;

                        case Statics.Stacked:
                        case Statics.TreeMap:
                        default:
                            break;
                    }
                }

                Dictionary<object, object> pointList = new Dictionary<object, object>();

                string[] dataSplit = lineSeriesItemString.Split(new string[] { Statics.LineSeriesDataString }, StringSplitOptions.None);

                object independentValue = string.Empty;
                object dependentValue = 0.0;

                if (dataSplit.Length == 3)
                {
                    string dataString = dataSplit[1];

                    string[] dataPairStringArray = dataString.Split(new string[] { Statics.SeparateDataPoints }, StringSplitOptions.None);

                    foreach (string pair in dataPairStringArray)
                    {
                        if (pair.Length > 0)
                        {
                            string[] set = pair.Split(new string[] { Statics.SeparateIndDepValues }, StringSplitOptions.None);

                            try
                            {
                                if (set.Length == 2)
                                {
                                    Double doubleCandidate;
                                    DateTime dateTimeCandidate;

                                    // < independent >
                                    if (Double.TryParse(set[0], out doubleCandidate))
                                    {
                                        independentValue = doubleCandidate;

                                        if (_minIndependentValueIsValid)
                                        {
                                            if ((double)independentValue < (double)_minIndependentValue)
                                            {
                                                _minIndependentValue = independentValue;
                                            }
                                        }
                                        else
                                        {
                                            _minIndependentValue = independentValue;
                                            _minIndependentValueIsValid = true;
                                        }

                                        if (_maxIndependentValueIsValid)
                                        {
                                            if ((double)independentValue > (double)_maxIndependentValue)
                                            {
                                                _maxIndependentValue = independentValue;
                                            }
                                        }
                                        else
                                        {
                                            _maxIndependentValue = independentValue;
                                            _maxIndependentValueIsValid = true;
                                        }
                                    }
                                    else if (DateTime.TryParse(set[0], out dateTimeCandidate))
                                    {
                                        independentValue = dateTimeCandidate;

                                        if (_minIndependentValueIsValid)
                                        {
                                            if ((DateTime)independentValue < (DateTime)_minIndependentValue)
                                            {
                                                _minIndependentValue = independentValue;
                                            }
                                        }
                                        else
                                        {
                                            _minIndependentValue = independentValue;
                                            _minIndependentValueIsValid = true;
                                        }

                                        if (_maxIndependentValueIsValid)
                                        {
                                            if ((DateTime)independentValue > (DateTime)_maxIndependentValue)
                                            {
                                                _maxIndependentValue = independentValue;
                                            }
                                        }
                                        else
                                        {
                                            _maxIndependentValue = independentValue;
                                            _maxIndependentValueIsValid = true;
                                        }
                                    }
                                    else
                                    {
                                        independentValue = set[0].ToString();
                                    }

                                    // < dependent >
                                    if (Double.TryParse(set[1], out doubleCandidate))
                                    {
                                        dependentValue = doubleCandidate;
                                    }
                                    else if (DateTime.TryParse(set[1], out dateTimeCandidate))
                                    {
                                        dependentValue = dateTimeCandidate;
                                    }
                                    else
                                    {
                                        dependentValue = set[1].ToString();
                                    }

                                    pointList.Add(independentValue, dependentValue);
                                }
                            }
                            catch
                            {
                                return false;
                            }
                        }
                    }
                }
                else
                {
                    failOverMessage = string.Format("Parse fail with '{0}'", lineSeriesItemString);
                    return false;
                }

                AddItemSourceToSeries(chartType, series, pointList);

                if (isSingleSeries)
                {
                    AddAxesToSeries(chartType, series, independentValue);
                }
                else
                {
                    //((ColumnSeries)series).IndependentAxis = new LinearAxis
                    //{
                    //    Title = _independentLabel,
                    //    Orientation = AxisOrientation.X,
                    //    Minimum = (double)_minIndependentValue,
                    //    Maximum = (double)_maxIndependentValue
                    //};
                }

                listOfSeries.Add(series);
                parsed = true;
            }
            return parsed;
        }
    public WaterBodyViewModel(AbstractWaterBody WB):base(WB)
    {
      _waterBody = WB;

      //If there is output
      if (_waterBody.Output.Items.Max(var => var.Values.Count()) > 1)
      {
        WB.Output.Summarize(100);



        _storageTimeStart = _waterBody.Output.Items.First(var => var.Values.Count() > 2).StartTime;
        _storageTimeEnd = _waterBody.Output.Items.First(var => var.Values.Count() > 2).EndTime;
        UpdateWB();
      }
      //Build the groundwater list
      _groundwaterBoundaries = new ObservableCollection<GroundWaterBoundary>();
      foreach (var GWB in _waterBody.GroundwaterBoundaries)
      {
        if (GWB is GroundWaterBoundary)
          _groundwaterBoundaries.Add((GroundWaterBoundary)GWB);
      }

      //Build the sources list
      _sources = new ObservableCollection<SourceBoundaryViewModel>();
      foreach (var S in _waterBody.Sources)
      {
        _sources.Add(new SourceBoundaryViewModel((AbstractBoundary)S, "Source"));
      }
      foreach (var S in _waterBody.Precipitation)
      {
        _sources.Add(new SourceBoundaryViewModel((AbstractBoundary)S, "Precipitation"));
      }

      //Build the sinks list
      _sinks = new ObservableCollection<SourceBoundaryViewModel>();
      foreach (var S in _waterBody.EvaporationBoundaries)
      {
        _sinks.Add(new SourceBoundaryViewModel((AbstractBoundary)S, "Evaporation"));
      }
      foreach (var S in _waterBody.Sinks)
      {
        _sinks.Add(new SourceBoundaryViewModel((AbstractBoundary)S, "Sinks"));
      }

      //Build the chemical lists
      Chemicals = new ObservableCollection<LineSeries>();
      foreach (var ts in _waterBody.Output.ChemicalsToLog.Values)
      {
        LineSeries ls = new LineSeries();
        ls.ItemsSource = ts.Items;
        ls.DependentValuePath = "Value";
        ls.IndependentValuePath = "Time";
        ls.Title = ts.Name;
        Chemicals.Add(ls);
      }

      //Build composition lists
      Compositions = new ObservableCollection<LineSeries>();
      foreach (var ts in _waterBody.Output.CompositionLog.Values)
      {
        LineSeries ls = new LineSeries();
        ls.ItemsSource = ts.Items;
        ls.DependentValuePath = "Value";
        ls.IndependentValuePath = "Time";
        ls.Title = ts.Name;
        Compositions.Add(ls);
      }

      ChemicalMeasurements = new ObservableCollection<ScatterSeries>();
      {
        foreach (var cts in _waterBody.RealData.ChemicalConcentrations.Values)
        {
          ScatterSeries ls = new ScatterSeries();
          ls.ItemsSource = cts.Items;
          ls.DependentValuePath = "Value";
          ls.IndependentValuePath = "Time";
          ls.Title = cts.Name;
          ChemicalMeasurements.Add(ls);
        }
      }
    }
Example #7
0
        //-------------------------------------------------------------------------------------
        /// <summary>
        /// </summary>
        //-------------------------------------------------------------------------------------
        private void SetupNewChartLine()
        {
            var pointStyle = new Style(typeof(ScatterDataPoint));
            pointStyle.Setters.Add(new Setter(ScatterDataPoint.ForegroundProperty, _brushes[series % _brushes.Length]));
            pointStyle.Setters.Add(new Setter(ScatterDataPoint.BackgroundProperty, _brushes[series % _brushes.Length]));
            pointStyle.Setters.Add(new Setter(ScatterDataPoint.BorderBrushProperty, Brushes.Transparent));
            pointStyle.Setters.Add(new Setter(ScatterDataPoint.BorderThicknessProperty, new Thickness(0)));
            pointStyle.Setters.Add(new Setter(ScatterDataPoint.HeightProperty, 3.0));
            pointStyle.Setters.Add(new Setter(ScatterDataPoint.WidthProperty, 3.0));

            var newLine = new ScatterSeries();
            newLine.Title = _mainModel.CurrentSatelliteConfigLabel;
            newLine.DependentValuePath = "Value";
            newLine.IndependentValuePath = "Key";
            newLine.DataPointStyle = pointStyle;

            CurrentLinePoints = new ObservableCollection<KeyValuePair<double, double>>();
            newLine.ItemsSource = CurrentLinePoints;
            MyChart.Series.Add(newLine);
            series++;
        }
 public void ActualMinimumActualMaximumCorrect()
 {
     Chart chart = new Chart();
     LinearAxis axis = new LinearAxis { Orientation = AxisOrientation.X, Minimum = 10, Maximum = 20 };
     chart.Axes.Add(axis);
     ScatterSeries series = new ScatterSeries();
     series.DependentValueBinding = new Binding();
     series.IndependentValueBinding = new Binding();
     int[] itemsSource = new int[] { 14 };
     series.ItemsSource = itemsSource;
     chart.Series.Add(series);
     TestAsync(
         chart,
         () => Assert.AreEqual(axis.Minimum, axis.ActualMinimum),
         () => Assert.AreEqual(axis.Maximum, axis.ActualMaximum));
 }
 public void CustomMinimumAndMaximumAreRespectedViaStyle()
 {
     Chart chart = new Chart();
     LinearAxis horizontalAxis = new LinearAxis { Orientation = AxisOrientation.X };
     Style horizontalStyle = new Style(typeof(LinearAxis));
     horizontalStyle.Setters.Add(new Setter(LinearAxis.MinimumProperty, 50.0));
     horizontalStyle.Setters.Add(new Setter(LinearAxis.MaximumProperty, 120.0));
     horizontalAxis.Style = horizontalStyle;
     chart.Axes.Add(horizontalAxis);
     LinearAxis verticalAxis = new LinearAxis { Orientation = AxisOrientation.Y };
     Style verticalStyle = new Style(typeof(LinearAxis));
     verticalStyle.Setters.Add(new Setter(LinearAxis.MinimumProperty, 40.0));
     verticalStyle.Setters.Add(new Setter(LinearAxis.MaximumProperty, 130.0));
     verticalAxis.Style = verticalStyle;
     chart.Axes.Add(verticalAxis);
     ScatterSeries series = new ScatterSeries();
     series.IndependentValueBinding = new Binding();
     series.ItemsSource = new int[] { 100 };
     chart.Series.Add(series);
     TestAsync(
         chart,
         () => Assert.AreEqual(50, horizontalAxis.ActualMinimum),
         () => Assert.AreEqual(120, horizontalAxis.ActualMaximum),
         () => Assert.AreEqual(40, verticalAxis.ActualMinimum),
         () => Assert.AreEqual(130, verticalAxis.ActualMaximum));
 }
 public void CustomMinimumAndMaximumAreRespected()
 {
     Chart chart = new Chart();
     LinearAxis horizontalAxis = new LinearAxis { Orientation = AxisOrientation.X, Minimum = 50, Maximum = 120 };
     chart.Axes.Add(horizontalAxis);
     LinearAxis verticalAxis = new LinearAxis { Orientation = AxisOrientation.Y, Minimum = 40, Maximum = 130 };
     chart.Axes.Add(verticalAxis);
     ScatterSeries series = new ScatterSeries();
     series.IndependentValueBinding = new Binding();
     series.ItemsSource = new int[] { 100 };
     chart.Series.Add(series);
     TestAsync(
         chart,
         () => Assert.AreEqual(50, horizontalAxis.ActualMinimum),
         () => Assert.AreEqual(120, horizontalAxis.ActualMaximum),
         () => Assert.AreEqual(40, verticalAxis.ActualMinimum),
         () => Assert.AreEqual(130, verticalAxis.ActualMaximum));
 }
Example #11
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.Main = ((Diplom.MainWindow)(target));
     return;
     case 2:
     this.MainPanel = ((System.Windows.Controls.DockPanel)(target));
     return;
     case 3:
     this.menu = ((System.Windows.Controls.Menu)(target));
     return;
     case 4:
     this.Exit = ((System.Windows.Controls.MenuItem)(target));
     
     #line 105 "..\..\..\MainWindow.xaml"
     this.Exit.Click += new System.Windows.RoutedEventHandler(this.Exit_Click);
     
     #line default
     #line hidden
     return;
     case 5:
     this.about = ((System.Windows.Controls.MenuItem)(target));
     
     #line 108 "..\..\..\MainWindow.xaml"
     this.about.Click += new System.Windows.RoutedEventHandler(this.about_Click);
     
     #line default
     #line hidden
     return;
     case 6:
     this.text_size_X = ((System.Windows.Controls.TextBox)(target));
     
     #line 116 "..\..\..\MainWindow.xaml"
     this.text_size_X.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.text_size_X_TextChanged);
     
     #line default
     #line hidden
     
     #line 116 "..\..\..\MainWindow.xaml"
     this.text_size_X.GotFocus += new System.Windows.RoutedEventHandler(this.text_size_X_GotFocus);
     
     #line default
     #line hidden
     return;
     case 7:
     this.text_size_Y = ((System.Windows.Controls.TextBox)(target));
     
     #line 117 "..\..\..\MainWindow.xaml"
     this.text_size_Y.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.text_size_Y_TextChanged);
     
     #line default
     #line hidden
     
     #line 117 "..\..\..\MainWindow.xaml"
     this.text_size_Y.GotFocus += new System.Windows.RoutedEventHandler(this.text_size_Y_GotFocus);
     
     #line default
     #line hidden
     return;
     case 8:
     this.numbGsmBase = ((System.Windows.Controls.TextBox)(target));
     
     #line 125 "..\..\..\MainWindow.xaml"
     this.numbGsmBase.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.numbGsmBase_TextChanged);
     
     #line default
     #line hidden
     
     #line 125 "..\..\..\MainWindow.xaml"
     this.numbGsmBase.GotFocus += new System.Windows.RoutedEventHandler(this.numbGsmBase_GotFocus);
     
     #line default
     #line hidden
     return;
     case 9:
     this.numbGsmAbon = ((System.Windows.Controls.TextBox)(target));
     
     #line 126 "..\..\..\MainWindow.xaml"
     this.numbGsmAbon.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.numbGsmAbon_TextChanged);
     
     #line default
     #line hidden
     
     #line 126 "..\..\..\MainWindow.xaml"
     this.numbGsmAbon.GotFocus += new System.Windows.RoutedEventHandler(this.numbGsmAbon_GotFocus);
     
     #line default
     #line hidden
     return;
     case 10:
     this.GSM_base_param = ((System.Windows.Controls.Button)(target));
     
     #line 127 "..\..\..\MainWindow.xaml"
     this.GSM_base_param.Click += new System.Windows.RoutedEventHandler(this.GSM_base_param_Click);
     
     #line default
     #line hidden
     return;
     case 11:
     this.GSM_abon_param = ((System.Windows.Controls.Button)(target));
     
     #line 128 "..\..\..\MainWindow.xaml"
     this.GSM_abon_param.Click += new System.Windows.RoutedEventHandler(this.GSM_abon_param_Click);
     
     #line default
     #line hidden
     return;
     case 12:
     this.numbCdmaBase = ((System.Windows.Controls.TextBox)(target));
     
     #line 136 "..\..\..\MainWindow.xaml"
     this.numbCdmaBase.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.numbCdmaBase_TextChanged);
     
     #line default
     #line hidden
     
     #line 136 "..\..\..\MainWindow.xaml"
     this.numbCdmaBase.GotFocus += new System.Windows.RoutedEventHandler(this.numbCdmaBase_GotFocus);
     
     #line default
     #line hidden
     return;
     case 13:
     this.numbCdmaAbon = ((System.Windows.Controls.TextBox)(target));
     
     #line 137 "..\..\..\MainWindow.xaml"
     this.numbCdmaAbon.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.numbCdmaAbon_TextChanged);
     
     #line default
     #line hidden
     
     #line 137 "..\..\..\MainWindow.xaml"
     this.numbCdmaAbon.GotFocus += new System.Windows.RoutedEventHandler(this.numbCdmaAbon_GotFocus);
     
     #line default
     #line hidden
     return;
     case 14:
     this.CDMA_base_param = ((System.Windows.Controls.Button)(target));
     
     #line 138 "..\..\..\MainWindow.xaml"
     this.CDMA_base_param.Click += new System.Windows.RoutedEventHandler(this.CDMA_base_param_Click);
     
     #line default
     #line hidden
     return;
     case 15:
     this.CDMA_abon_param = ((System.Windows.Controls.Button)(target));
     
     #line 139 "..\..\..\MainWindow.xaml"
     this.CDMA_abon_param.Click += new System.Windows.RoutedEventHandler(this.CDMA_abon_param_Click);
     
     #line default
     #line hidden
     return;
     case 16:
     this.Generation = ((System.Windows.Controls.Button)(target));
     
     #line 145 "..\..\..\MainWindow.xaml"
     this.Generation.Click += new System.Windows.RoutedEventHandler(this.Generation_Click);
     
     #line default
     #line hidden
     return;
     case 17:
     this.Clear = ((System.Windows.Controls.Button)(target));
     
     #line 146 "..\..\..\MainWindow.xaml"
     this.Clear.Click += new System.Windows.RoutedEventHandler(this.Clear_Click);
     
     #line default
     #line hidden
     return;
     case 18:
     this.kalkulate = ((System.Windows.Controls.Button)(target));
     
     #line 147 "..\..\..\MainWindow.xaml"
     this.kalkulate.Click += new System.Windows.RoutedEventHandler(this.kalkulate_Click);
     
     #line default
     #line hidden
     return;
     case 19:
     this.StatusPanel = ((System.Windows.Controls.StackPanel)(target));
     return;
     case 20:
     this.statusbar = ((System.Windows.Controls.TextBox)(target));
     return;
     case 21:
     this.Pole = ((System.Windows.Controls.DataVisualization.Charting.Chart)(target));
     return;
     case 22:
     this.GSM_base_graph = ((System.Windows.Controls.DataVisualization.Charting.ScatterSeries)(target));
     return;
     case 23:
     this.GSM_abon_graph = ((System.Windows.Controls.DataVisualization.Charting.ScatterSeries)(target));
     return;
     case 24:
     this.CDMA_base_graph = ((System.Windows.Controls.DataVisualization.Charting.ScatterSeries)(target));
     return;
     case 25:
     this.CDMA_abon_graph = ((System.Windows.Controls.DataVisualization.Charting.ScatterSeries)(target));
     return;
     }
     this._contentLoaded = true;
 }
Example #12
0
        private void RenderFinishSingleChart(List<List<StringDataValue>> stratifiedValues)
        {
            waitPanel.Visibility = System.Windows.Visibility.Collapsed;
            pnlMain.Children.Clear();

            Chart chart = new Chart();
            chart.Loaded += new RoutedEventHandler(chart_Loaded);
            chart.BorderThickness = new Thickness(0);
            LinearAxis dependentAxis = new LinearAxis();
            dependentAxis.Minimum = 0;
            dependentAxis.ShowGridLines = (bool)checkboxShowHorizontalGridLines.IsChecked;

            CategoryAxis independentAxis = new CategoryAxis();
            independentAxis.Orientation = AxisOrientation.X;

            foreach (List<StringDataValue> dataValues in stratifiedValues)
            {
                DataPointSeries series;
                LineSeries avgSeries = null;

                switch (((ComboBoxItem)cbxChartType.SelectedItem).Content.ToString())
                {
                    case "Bar":
                        series = new BarSeries();
                        dependentAxis.Orientation = AxisOrientation.X;
                        ((BarSeries)series).DependentRangeAxis = dependentAxis;

                        chart.PlotAreaStyle = new Style();
                        chart.PlotAreaStyle.Setters.Add(new Setter(Chart.BackgroundProperty, Brushes.White));

                        dependentAxis.GridLineStyle = new Style();
                        dependentAxis.GridLineStyle.Setters.Add(new Setter(Line.StrokeProperty, Brushes.LightGray));

                        chart.Palette = (System.Collections.ObjectModel.Collection<ResourceDictionary>)this.Resources["defaultBarPalette"];

                        break;
                    case "Column":
                        series = new ColumnSeries();
                        if (DashboardHelper.IsColumnText(cbxSingleField.SelectedItem.ToString()) && axisLabelMaxLength > 5)
                            independentAxis.AxisLabelStyle = Resources["RotateAxisStyle90"] as Style;

                        ((ColumnSeries)series).IndependentAxis = independentAxis;
                        dependentAxis.Orientation = AxisOrientation.Y;
                        ((ColumnSeries)series).DependentRangeAxis = dependentAxis;

                        chart.PlotAreaStyle = new Style();
                        chart.PlotAreaStyle.Setters.Add(new Setter(Chart.BackgroundProperty, Brushes.White));

                        dependentAxis.GridLineStyle = new Style();
                        dependentAxis.GridLineStyle.Setters.Add(new Setter(Line.StrokeProperty, Brushes.LightGray));

                        chart.Palette = (System.Collections.ObjectModel.Collection<ResourceDictionary>)this.Resources["defaultColumnPalette"];

                        //series.Effect = this.Resources["shadowEffect"] as System.Windows.Media.Effects.DropShadowEffect;

                        dependentAxis.GridLineStyle.Setters.Add(new Setter(Line.StrokeProperty, Brushes.LightGray));
                        //<Setter Property="Effect" Value="{StaticResource shadowEffect}"/>-->

                        break;
                    case "Pareto":
                        series = new ColumnSeries();
                        if (DashboardHelper.IsColumnText(cbxSingleField.SelectedItem.ToString()) && axisLabelMaxLength > 5)
                            independentAxis.AxisLabelStyle = Resources["RotateAxisStyle90"] as Style;
                        ((ColumnSeries)series).IndependentAxis = independentAxis;
                        dependentAxis.Orientation = AxisOrientation.Y;
                        ((ColumnSeries)series).DependentRangeAxis = dependentAxis;

                        LinearAxis percentAxis = new LinearAxis();
                        percentAxis.Minimum = 0;
                        percentAxis.Maximum = 100;
                        percentAxis.ShowGridLines = (bool)checkboxShowHorizontalGridLines.IsChecked;
                        percentAxis.Orientation = AxisOrientation.Y;
                        percentAxis.Location = AxisLocation.Right;

                        avgSeries = new LineSeries();
                        avgSeries.IndependentValuePath = "IndependentValue";
                        avgSeries.DependentValuePath = "CurrentMeanValue";
                        avgSeries.Title = "Accumulated %";
                        avgSeries.DependentRangeAxis = percentAxis;
                        avgSeries.IndependentAxis = independentAxis;
                        avgSeries.PolylineStyle = Resources["GooglePolylineStyle"] as Style;
                        avgSeries.DataPointStyle = Resources["GoogleDataPointStyle"] as Style;

                        chart.PlotAreaStyle = new Style();
                        chart.PlotAreaStyle.Setters.Add(new Setter(Chart.BackgroundProperty, Brushes.White));

                        dependentAxis.GridLineStyle = new Style();
                        dependentAxis.GridLineStyle.Setters.Add(new Setter(Line.StrokeProperty, Brushes.LightGray));

                        //series.Effect = this.Resources["shadowEffect"] as System.Windows.Media.Effects.DropShadowEffect;

                        chart.Palette = (System.Collections.ObjectModel.Collection<ResourceDictionary>)this.Resources["defaultColumnPalette"];

                        break;
                    case "Line":
                        series = new LineSeries();
                        if (DashboardHelper.IsColumnText(cbxSingleField.SelectedItem.ToString()) && axisLabelMaxLength > 5)
                            independentAxis.AxisLabelStyle = Resources["RotateAxisStyle90"] as Style;
                        ((LineSeries)series).IndependentAxis = independentAxis;
                        dependentAxis.Orientation = AxisOrientation.Y;
                        ((LineSeries)series).DependentRangeAxis = dependentAxis;
                        break;
                    case "Pie":
                        if (stratifiedValues.Count > 1)
                        {
                            if (dataValues.Count > 0)
                            {
                                Label lblStrata = new Label();
                                lblStrata.Margin = new Thickness(0, 10, 0, 0);
                                lblStrata.FontWeight = FontWeights.Bold;
                                lblStrata.Content = dataValues[0].StratificationValue;
                                pnlMain.Children.Add(lblStrata);
                            }
                        }
                        chart = new LabeledPieChart();
                        chart.Loaded += new RoutedEventHandler(chart_Loaded);
                        chart.BorderThickness = new Thickness(0);
                        series = new LabeledPieSeries();
                        series.LegendItemStyle = Resources["PieLegendStyle"] as Style;
                        ((LabeledPieSeries)series).PieChartLabelStyle=Resources["pieChartLabelStyle"] as Style;
                        ((LabeledPieSeries)series).PieChartLabelItemTemplate=Resources["pieChartLabelDataTemplate"] as DataTemplate;
                        ((LabeledPieSeries)series).LabelDisplayMode = DisplayMode.Auto;
                        chart.LegendTitle = cbxSingleField.SelectedItem.ToString();
                        chart.Series.Add(series);
                        chart.Height = 600;
                        chart.Width = 920;

                        chart.Margin = new Thickness(50, 0, 0, 0);

                        chart.PlotAreaStyle = new Style();
                        chart.PlotAreaStyle.Setters.Add(new Setter(Chart.BackgroundProperty, Brushes.White));

                        dependentAxis.GridLineStyle = new Style();
                        dependentAxis.GridLineStyle.Setters.Add(new Setter(Line.StrokeProperty, Brushes.LightGray));

                        chart.Palette = (System.Collections.ObjectModel.Collection<ResourceDictionary>)this.Resources["defaultPiePalette"];

                        pnlMain.Children.Add(chart);
                        break;
                    case "Scatter":
                        series = new ScatterSeries();
                        dependentAxis.Orientation = AxisOrientation.Y;
                        ((ScatterSeries)series).DependentRangeAxis = dependentAxis;
                        break;
                    default:
                        series = new LineSeries();
                        dependentAxis.Orientation = AxisOrientation.Y;
                        ((LineSeries)series).DependentRangeAxis = dependentAxis;
                        break;
                }

                series.IndependentValuePath = "IndependentValue";
                series.DependentValuePath = "DependentValue";

                series.ItemsSource = dataValues;
                if (avgSeries != null)
                {
                    List<StringDataValue> paretoDataValues = new List<StringDataValue>(dataValues);

                    double max = 0;

                    foreach (StringDataValue sdv in paretoDataValues)
                    {
                        max = max + sdv.DependentValue;
                    }

                    double runningPercent = 0;
                    foreach (StringDataValue sdv in paretoDataValues)
                    {
                        sdv.CurrentMeanValue = ((sdv.DependentValue / max) * 100) + runningPercent;
                        runningPercent = sdv.CurrentMeanValue;
                    }

                    avgSeries.ItemsSource = paretoDataValues;
                }

                if (stratifiedValues.Count > 1)
                {
                    if (!(series is LabeledPieSeries) && cbxStrataField.SelectedIndex > -1)
                    {
                        chart.LegendTitle = cbxStrataField.SelectedItem.ToString();
                    }

                    if (dataValues.Count > 0 && !IsBooleanWithNoStratas)
                    {
                        series.Title = dataValues[0].StratificationValue.Split('=')[1].Trim();
                    }
                    else if (dataValues.Count > 0 && IsBooleanWithNoStratas)
                    {
                        series.Title = dataValues[0].StratificationValue.Trim();
                        chart.LegendTitle = dataValues[0].IndependentValue;
                    }
                }
                else
                {
                    series.Title = "Count";
                }

                if (series is LabeledPieSeries)
                {
                    //chart.Height = 600;
                    //chart.Width = 800;
                }
                else if (series is BarSeries)
                {
                    if (dataValues.Count > 30)
                        chart.Height = dataValues.Count * 30;
                    else
                        chart.Height = 600;
                    chart.Width = 800;
                }
                else
                {
                    chart.Height = 600;
                    if (dataValues.Count > 20)
                        chart.Width = dataValues.Count * 40;
                    else
                        chart.Width = 800;
                }
                if (!(series is LabeledPieSeries))
                {
                    chart.Series.Add(series);
                    if (avgSeries != null)
                    {
                        chart.Series.Add(avgSeries);
                    }
                }

                ///////////////////////////////////////////////////////
                string chartSize = "Medium";

                if (GadgetOptions == null)
                {
                    return;
                }

                if (GadgetOptions.InputVariableList != null && GadgetOptions.InputVariableList.ContainsKey("chartsize"))
                {
                    chartSize = GadgetOptions.InputVariableList["chartsize"];
                }

                switch (chartSize)
                {
                    case "Small":
                        chart.Height = chart.Height / 2;
                        chart.Width = chart.Width / 2;
                        break;
                    case "Medium":
                        chart.Height = chart.Height / 1.5;
                        chart.Width = chart.Width / 1.5;
                        break;
                    case "Custom":
                        if (GadgetOptions.InputVariableList.ContainsKey("chartheight"))
                        {
                            int height;
                            bool success = int.TryParse(GadgetOptions.InputVariableList["chartheight"], out height);
                            if (success)
                            {
                                chart.Height = height;
                            }
                        }
                        if (GadgetOptions.InputVariableList.ContainsKey("chartwidth"))
                        {
                            int width;
                            bool success = int.TryParse(GadgetOptions.InputVariableList["chartwidth"], out width);
                            if (success)
                            {
                                chart.Width = width;
                            }
                        }
                        break;
                }
                ///////////////////////////////////////////////////////
            }
            if (!((ComboBoxItem)cbxChartType.SelectedItem).Content.ToString().Equals("Pie"))
            {
                pnlMain.Children.Add(chart);
            }
        }
Example #13
0
        private void RenderFinishScatterChart(List<NumericDataValue> dataValues, StatisticsRepository.LinearRegression.LinearRegressionResults results, NumericDataValue maxValue, NumericDataValue minValue)
        {
            Chart chart = new Chart();
            chart.Loaded += new RoutedEventHandler(chart_Loaded);
            chart.BorderThickness = new Thickness(0);
            ScatterSeries series = new ScatterSeries();

            LinearAxis xaxis = new LinearAxis();
            xaxis.Orientation = AxisOrientation.X;
            xaxis.Title = cbxScatterXAxisField.SelectedItem.ToString();
            series.IndependentAxis = xaxis;

            LinearAxis yaxis = new LinearAxis();
            yaxis.Orientation = AxisOrientation.Y;
            yaxis.Title = cbxScatterYAxisField.SelectedItem.ToString();
            series.DependentRangeAxis = yaxis;
            yaxis.ShowGridLines = (bool)checkboxShowHorizontalGridLines.IsChecked;

            series.IndependentValuePath = "IndependentValue";
            series.DependentValuePath = "DependentValue";
            series.ItemsSource = dataValues;
            chart.Series.Add(series);

            if (results.variables != null)
            {
                decimal coefficient = Convert.ToDecimal(results.variables[0].coefficient);
                decimal constant = Convert.ToDecimal(results.variables[1].coefficient);

                NumericDataValue newMaxValue = new NumericDataValue();
                newMaxValue.IndependentValue = maxValue.IndependentValue + 1;
                newMaxValue.DependentValue = (coefficient * maxValue.IndependentValue) + constant;
                NumericDataValue newMinValue = new NumericDataValue();
                newMinValue.IndependentValue = minValue.IndependentValue - 1;
                newMinValue.DependentValue = (coefficient * minValue.IndependentValue) + constant;

                List<NumericDataValue> regresValues = new List<NumericDataValue>();
                regresValues.Add(newMinValue);
                regresValues.Add(newMaxValue);

                LineSeries regression = new LineSeries();
                regression.DependentRangeAxis = yaxis;
                regression.IndependentAxis = xaxis;
                regression.IndependentValuePath = "IndependentValue";
                regression.DependentValuePath = "DependentValue";
                regression.ItemsSource = regresValues;
                chart.Series.Add(regression);

                series.LegendItems.Clear();
                regression.LegendItems.Clear();

                chart.Height = 600;
                if (dataValues.Count > 20)
                    chart.Width = dataValues.Count * 25;
                else
                    chart.Width = 800;
                pnlMain.Children.Clear();
                pnlMain.Children.Add(chart);
            }
            else
            {
                pnlMain.Children.Clear();
                RenderFinishWithWarning("Insufficient data to produce this chart.");
            }
            //RenderFinish();
        }
 public void ActualMinimumActualMaximumCorrect()
 {
     Chart chart = new Chart();
     DateTimeAxis axis = new DateTimeAxis { Orientation = AxisOrientation.X, Minimum = new DateTime(2009, 1, 20), Maximum = new DateTime(2009, 1, 30) }; 
     chart.Axes.Add(axis);
     ScatterSeries series = new ScatterSeries();
     series.DependentValueBinding = new Binding("Day");
     series.IndependentValueBinding = new Binding();
     DateTime[] itemsSource = new DateTime[] { new DateTime(2009, 1, 23) };
     series.ItemsSource = itemsSource;
     chart.Series.Add(series);
     TestAsync(
         chart,
         () => Assert.AreEqual(axis.Minimum, axis.ActualMinimum),
         () => Assert.AreEqual(axis.Maximum, axis.ActualMaximum));
 }
 public void DateTimeAxisLabelHonorsStringFormat()
 {
     Chart chart = new Chart();
     string dateTimeFormat = "|{0:MM,dd}|";
     DateTimeAxis axis = new DateTimeAxis { Orientation = AxisOrientation.X };
     Style labelStyle = new Style(typeof(DateTimeAxisLabel));
     labelStyle.Setters.Add(new Setter(DateTimeAxisLabel.StringFormatProperty, dateTimeFormat));
     axis.AxisLabelStyle = labelStyle;
     chart.Axes.Add(axis);
     ScatterSeries series = new ScatterSeries();
     series.DependentValueBinding = new Binding("Day");
     series.IndependentValueBinding = new Binding();
     DateTime[] itemsSource = new DateTime[] { new DateTime(2009, 1, 23) };
     series.ItemsSource = itemsSource;
     chart.Series.Add(series);
     TestAsync(
         chart,
         () =>
         {
             AxisLabel label = ChartTestUtilities.GetAxisLabels(axis).First();
             Assert.AreEqual(string.Format(CultureInfo.CurrentCulture, dateTimeFormat, label.DataContext), label.FormattedContent);
         });
 }