Exemplo n.º 1
0
        private void AddSerie(object sender, RoutedEventArgs e)
        {
            var r = new Random();

            var s = new LineSerie { PrimaryValues = new ObservableCollection<double>() };
            var lineSerie = LineChart.Series[0] as LineSerie;
            if (lineSerie != null)
            {
                var l = LineChart.Series.Count == 0 ? 0 : lineSerie.PrimaryValues.Count;
                for (int i = 0; i < l; i++)
                {
                    s.PrimaryValues.Add(r.Next(-30, 30));
                }
            }
            LineChart.Series.Add(s);

            var s1 = new BarSerie { PrimaryValues = new ObservableCollection<double>() };
            var barSerie = BarChart.Series[0] as BarSerie;
            if (barSerie != null)
            {
                var l1 = BarChart.Series.Count == 0 ? 0 : barSerie.PrimaryValues.Count;
                for (int i = 0; i < l1; i++)
                {
                    s1.PrimaryValues.Add(r.Next(-30, 30));
                }
            }
            BarChart.Series.Add(s1);
        }
Exemplo n.º 2
0
        private void AddSerie(object sender, RoutedEventArgs e)
        {
            var r = new Random();

            var s = new LineSerie {
                PrimaryValues = new ObservableCollection <double>()
            };
            var lineSerie = LineChart.Series.Count > 0 ? (LineChart.Series[0] as LineSerie) : null;

            if (lineSerie != null)
            {
                var l = LineChart.Series.Count == 0 ? 0 : lineSerie.PrimaryValues.Count;
                for (int i = 0; i < l; i++)
                {
                    s.PrimaryValues.Add(r.Next(-30, 30));
                }
            }
            else
            {
                s = new LineSerie
                {
                    PrimaryValues = new ObservableCollection <double>(new double[] { 1, -1, 2, -2, 3, -3, 4, -4, 5, -5 })
                };
            }

            LineChart.Series.Add(s);

            var s1 = new BarSerie {
                PrimaryValues = new ObservableCollection <double>()
            };
            var barSerie = BarChart.Series.Count > 0 ? BarChart.Series[0] as BarSerie : null;

            if (barSerie != null)
            {
                var l1 = BarChart.Series.Count == 0 ? 0 : barSerie.PrimaryValues.Count;
                for (int i = 0; i < l1; i++)
                {
                    s1.PrimaryValues.Add(r.Next(0, 30));
                }
            }
            else
            {
                s1 = new BarSerie
                {
                    PrimaryValues = new ObservableCollection <double>(new double[] { 1, 2, 3, 4, 5 })
                };
            }
            BarChart.Series.Add(s1);

            var s2 = new StackedBarSerie {
                PrimaryValues = new ObservableCollection <double>()
            };
            var stackedSerie = StackedBarChart.Series.Count > 0 ? StackedBarChart.Series[0] as StackedBarSerie : null;

            if (stackedSerie != null)
            {
                var l1 = StackedBarChart.Series.Count == 0 ? 0 : stackedSerie.PrimaryValues.Count;
                for (int i = 0; i < l1; i++)
                {
                    s2.PrimaryValues.Add(r.Next(0, 30));
                }
            }
            else
            {
                s2 = new StackedBarSerie
                {
                    PrimaryValues = new ObservableCollection <double>(new double[] { 1, 2, 3, 4, 5 })
                };
            }
            StackedBarChart.Series.Add(s2);

            var s8 = new RadarSerie {
                PrimaryValues = new ObservableCollection <double>()
            };
            var radarSerie = RadarChart.Series.Count > 0 ? RadarChart.Series[0] as RadarSerie : null;

            if (radarSerie != null)
            {
                var l1 = RadarChart.Series.Count == 0 ? 0 : radarSerie.PrimaryValues.Count;
                for (int i = 0; i < l1; i++)
                {
                    s8.PrimaryValues.Add(r.Next(0, 30));
                }
            }
            else
            {
                s8 = new RadarSerie
                {
                    PrimaryValues = new ObservableCollection <double>(new double[] { 1, 2, 3, 4, 5 })
                };
            }
            RadarChart.Series.Add(s8);
        }