Beispiel #1
0
        private void RotatedBar_Load(object sender, EventArgs e)
        {
            lineChart1.LegendLocation = LegendLocation.Right;
            lineChart1.Invert         = true;

            var config = new SeriesConfiguration <double>().X(val => val);

            lineChart1.Series = new SeriesCollection(config);

            lineChart1.Series.Add(new LineSeries
            {
                Title  = "A Series",
                Values = new ChartValues <double> {
                    3, 5, 8, 12, 8, 3
                }
            });

            lineChart1.Series.Add(new LineSeries
            {
                Title  = "A Series",
                Values = new ChartValues <double> {
                    4, 2, 10, 11, 9, 4
                }
            });

            lineChart1.AxisY[0].Labels = new List <string>
            {
                "Day 1",
                "Day 2",
                "Day 3",
                "Day 4",
                "Day 5",
                "Day 6"
            };
        }
Beispiel #2
0
        public IrregularLine()
        {
            InitializeComponent();

            //we create a configuration to map our values type, in this case System.Windows.Point
            var config = new SeriesConfiguration <Point>()
                         .X(point => point.X)  // we use point.X as the X of our chart (you don't say!)
                         .Y(point => point.Y); // we use point.Y as the Y of our chart -.-"

            //we pass the config to the SeriesCollection constructor, or you can use Series.Setup(config)
            Series = new SeriesCollection(config)
            {
                new LineSeries
                {
                    Values = new ChartValues <Point>
                    {
                        new Point(1, 10),
                        new Point(2, 15),
                        new Point(4, 29),
                        new Point(8, 38),
                        new Point(16, 45),
                        new Point(32, 55),
                        new Point(64, 62),
                        new Point(128, 76),
                        new Point(256, 95)
                    },
                    Fill = Brushes.Transparent
                }
            };

            DataContext = this;
        }
Beispiel #3
0
 public SalesViewModel()
 {
     var config = new SeriesConfiguration<SalesData>().Y(data => data.ItemsSold);
     Salesmen = new SeriesCollection(config)
     {
         new PieSeries
         {
             Title = "Charles",
             Values = new ChartValues<SalesData>
             {
                 new SalesData {ItemsSold = 15, Rentability = .15, ItemsAverageSellPrice = 5000}
             }
         },
         new PieSeries
         {
             Title = "Frida",
             Values = new ChartValues<SalesData>
             {
                 new SalesData {ItemsSold = 16, Rentability = .12, ItemsAverageSellPrice = 5200}
             }
         },
         new PieSeries
         {
             Title = "George",
             Values = new ChartValues<SalesData>
             {
                 new SalesData {ItemsSold = 22, Rentability = .11, ItemsAverageSellPrice = 5100}
             }
         }
     };
 }
Beispiel #4
0
        /// <summary>
        /// Check if the series is cached in the given configuration
        /// </summary>
        /// <param name="seriesId">Id of the series</param>
        /// <param name="lang">Language of the series</param>
        /// <param name="checkEpisodesLoaded">are episodes loaded</param>
        /// <param name="checkBannersLoaded">are banners loaded</param>
        /// <param name="checkActorsLoaded">are actors loaded</param>
        /// <returns>true if the series is cached, false otherwise</returns>
        public bool IsCached(int seriesId, TvdbLanguage lang, bool checkEpisodesLoaded,
                             bool checkBannersLoaded, bool checkActorsLoaded)
        {
            String fName = _rootFolder + Path.DirectorySeparatorChar + seriesId +
                           Path.DirectorySeparatorChar + "series_" + seriesId + ".cfg";

            if (File.Exists(fName))
            {
                try
                {
                    FileStream          fs     = new FileStream(fName, FileMode.Open);
                    SeriesConfiguration config = (SeriesConfiguration)_formatter.Deserialize(fs);
                    fs.Close();

                    return(config.EpisodesLoaded || !checkEpisodesLoaded &&
                           config.BannersLoaded || !checkBannersLoaded &&
                           config.ActorsLoaded || !checkActorsLoaded);
                }
                catch (SerializationException)
                {
                    Log.Warn("Cannot deserialize SeriesConfiguration object");
                    return(false);
                }
            }
            return(false);
        }
Beispiel #5
0
        public RotatedStackedBar()
        {
            InitializeComponent();

            var config = new SeriesConfiguration <double>().X(val => val);

            SeriesCollection = new SeriesCollection(config)
            {
                new StackedBarSeries
                {
                    Title  = "Stacked Serie 1",
                    Values = new double[] { 3, 6, 2, 7 }.AsChartValues(),
                    DataLabels = true
                },
                new StackedBarSeries
                {
                    Title  = "Stacked Serie 1",
                    Values = new double[] { 6, 3, 5, 2 }.AsChartValues(),
                    DataLabels = true
                },
                new LineSeries
                {
                    Title  = "Line Series",
                    Values = new double[] { 10, 11, 8, 9 }.AsChartValues(),
                    Fill = Brushes.Transparent
                }
            };

            DataContext = this;
        }
Beispiel #6
0
        private void RotatedBar_Load(object sender, EventArgs e)
        {
            barChart1.Invert = true;
            barChart1.LegendLocation = LegendLocation.Top;

            var config = new SeriesConfiguration<double>().X(val => val);
            barChart1.Series = new SeriesCollection(config);

            barChart1.Series.Add(new BarSeries
            {
                Title = "A Series",
                Values = new ChartValues<double> { 3, 5, 8, 12, 8, 3 }
            });

            barChart1.Series.Add(new BarSeries
            {
                Title = "A Series",
                Values = new ChartValues<double> { 4, 2, 10, 11, 9, 4 }
            });

            barChart1.AxisY.Labels = new List<string>
            {
                "Day 1",
                "Day 2",
                "Day 3",
                "Day 4",
                "Day 5",
                "Day 6"
            };
        }
Beispiel #7
0
        public RotatedBar()
        {
            InitializeComponent();

            var config = new SeriesConfiguration<double>().X(value => value);

            SeriesCollection =
                new SeriesCollection(config)
                {
                    new BarSeries
                    {
                        Title = "inverted series",
                        Values = new double[] {10, 15, 18, 20, 15, 13}.AsChartValues(),
                        DataLabels = true
                    },
                    new BarSeries
                    {
                        Title = "inverted series 2",
                        Values = new double[] {4, 8, 19, 19, 16, 12}.AsChartValues(),
                        DataLabels = true
                    },
                    new LineSeries
                    {
                        Title = "inverted line series",
                        Values = new double[] {10, 15, 18, 20, 15, 13}.AsChartValues(),
                        Fill = Brushes.Transparent
                    }
                };

            DataContext = this;
        }
Beispiel #8
0
        private void button12_Click(object sender, EventArgs e)
        {
            var sample = new StackedSample();
            var config = new SeriesConfiguration <double>();

            sample.ShowDialog();
        }
        public RotatedStackedBar()
        {
            InitializeComponent();

            var config = new SeriesConfiguration<double>().X(val => val);

            SeriesCollection = new SeriesCollection(config)
            {
                new StackedBarSeries
                {
                    Title = "Stacked Serie 1",
                    Values = new double[] {3,6,2,7}.AsChartValues(),
                    DataLabels = true
                },
                new StackedBarSeries
                {
                    Title = "Stacked Serie 1",
                    Values = new double[] {6,3,5,2}.AsChartValues(),
                    DataLabels = true
                },
                new LineSeries
                {
                    Title = "Line Series",
                    Values = new double[] {10, 11, 8, 9}.AsChartValues(),
                    Fill = Brushes.Transparent
                }
            };

            DataContext = this;
        }
Beispiel #10
0
        public DynamicLine()
        {
            InitializeComponent();

            //In this case we will not only plot double values
            //to make it easier to handle "live-data" we are going to use WeatherViewModel class
            //we need to let LiveCharts know how to use this model

            //first we create a new configuration for WeatherViewModel
            var config = new SeriesConfiguration<WeatherViewModel>();

            //now we map X and Y
            //we will use Temperature as Y
            config.Y(model => model.Temperature);
            //and DateTime as X, we convert to OADate so we can plot it easly.
            config.X(model => model.DateTime.ToOADate());

            //now we create our series with this configuration
            Series = new SeriesCollection(config) {new LineSeries {Values = new ChartValues<WeatherViewModel>()}};

            //to display a custom label we will use a formatter,
            //formatters are just functions that take a double value as parameter
            //and return a string, in this case we will convert the OADate to DateTime
            //and then use a custom date format
            XFormatter = val => DateTime.FromOADate(val).ToString("hh:mm:ss tt");
            //now for Y we are rounding and adding ° for degrees
            YFormatter = val => Math.Round(val) + " °";

            //Don't forget DataContext so we can bind these properties.
            DataContext = this;

            _timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
            _timer.Tick += TimerOnTick;
        }
        public LogarithmicAxis()
        {
            InitializeComponent();

            //we create a configuration to map our values type, in this case System.Windows.Point
            var config = new SeriesConfiguration<Point>()
                .X(point => Math.Log(point.X, 10)) // we use log10(point.X) as X
                .Y(point => point.Y); // we use point.Y as the Y of our chart (amm.... yes, we are so f* smart!)

            //we pass the config to the SeriesCollection constructor, or you can use Series.Setup(config)
            Series = new SeriesCollection(config)
            {
                new LineSeries
                {
                    Values = new ChartValues<Point>
                    {
                        new Point(1, 10),
                        new Point(10, 15),
                        new Point(100, 29),
                        new Point(1000, 38),
                        new Point(10000, 45),
                        new Point(100000, 55)
                    }
                }
            };

            //to display labels we convert back from log
            //this is just the inverse operation 
            XFormatter = x =>
            {
                return Math.Pow(10, x).ToString();
            };

            DataContext = this;
        }
Beispiel #12
0
        public FilterChart()
        {
            InitializeComponent();

            //create a configuration for City class
            var config = new SeriesConfiguration<City>()
                .Y(city => city.Population); // use Population an Y
                                             // X will use default config, a zero based index
            
            //create a series collection with this config
            Series = new SeriesCollection(config);

            //lets pull some initials results
            var results = DataBase.Cities.OrderByDescending(city => city.Population).Take(15).ToArray();

            PopulationSeries = new BarSeries
            {
                Title = "Population by city 2015",
                Values = results.AsChartValues(),
                DataLabels = true
            };

            //there are 2 types of labels, when we use a formatter, and a strong array mapping
            //in this case instead of a label formatter we use a strong array labels
            //since X is a zero based index LiveCharts automatically maps this array with X
            //so when X = 0 label will be labels[0], when X = 1 labels[1], X = 2 labels[2], X = n labels[n]
            Labels = results.Select(city => city.Name).ToArray();

            Series.Add(PopulationSeries);

            DataContext = this;
        }
        public RotatedBar()
        {
            InitializeComponent();

            var config = new SeriesConfiguration <double>().X(value => value);

            SeriesCollection =
                new SeriesCollection(config)
            {
                new BarSeries
                {
                    Title  = "inverted series",
                    Values = new double[] { 10, 15, 18, 20, 15, 13 }.AsChartValues(),
                    DataLabels = true
                },
                new BarSeries
                {
                    Title  = "inverted series 2",
                    Values = new double[] { 4, 8, 19, 19, 16, 12 }.AsChartValues(),
                    DataLabels = true
                },
                new LineSeries
                {
                    Title  = "inverted line series",
                    Values = new double[] { 10, 15, 18, 20, 15, 13 }.AsChartValues(),
                    Fill = Brushes.Transparent
                }
            };

            DataContext = this;
        }
Beispiel #14
0
        public FilterChart()
        {
            InitializeComponent();

            //create a configuration for City class
            var config = new SeriesConfiguration <City>()
                         .Y(city => city.Population); // use Population an Y

            // X will use default config, a zero based index

            //create a series collection with this config
            Series = new SeriesCollection(config);

            //lets pull some initials results
            var results = DataBase.Cities.OrderByDescending(city => city.Population).Take(15).ToArray();

            PopulationSeries = new BarSeries
            {
                Title      = "Population by city 2015",
                Values     = results.AsChartValues(),
                DataLabels = true
            };

            //there are 2 types of labels, when we use a formatter, and a strong array mapping
            //in this case instead of a label formatter we use a strong array labels
            //since X is a zero based index LiveCharts automatically maps this array with X
            //so when X = 0 label will be labels[0], when X = 1 labels[1], X = 2 labels[2], X = n labels[n]
            Labels = results.Select(city => city.Name).ToArray();

            Series.Add(PopulationSeries);

            DataContext = this;
        }
Beispiel #15
0
        /// <summary>
        /// Check if the series is cached in the given configuration
        /// </summary>
        /// <param name="_seriesId">Id of the series</param>
        /// <param name="_episodesLoaded">are episodes loaded</param>
        /// <param name="_bannersLoaded">are banners loaded</param>
        /// <param name="_actorsLoaded">are actors loaded</param>
        /// <returns>true if the series is cached, false otherwise</returns>
        public bool IsCached(int _seriesId, bool _episodesLoaded,
                             bool _bannersLoaded, bool _actorsLoaded)
        {
            if (File.Exists(m_rootFolder + "\\series_" + _seriesId + ".cfg"))
            {
                try
                {
                    FileStream          fs     = new FileStream(m_rootFolder + "\\series_" + _seriesId + ".cfg", FileMode.Open);
                    SeriesConfiguration config = (SeriesConfiguration)m_formatter.Deserialize(fs);
                    fs.Close();

                    if (config.EpisodesLoaded || !_episodesLoaded &&
                        config.BannersLoaded || !_bannersLoaded &&
                        config.ActorsLoaded || !_actorsLoaded)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (SerializationException)
                {
                    Log.Warn("Cannot deserialize SeriesConfiguration object");
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Beispiel #16
0
        public IrregularLine()
        {
            InitializeComponent();

            //we create a configuration to map our values type, in this case System.Windows.Point
            var config = new SeriesConfiguration<Point>()
                .X(point => point.X) // we use point.X as the X of our chart (you don't say!)
                .Y(point => point.Y); // we use point.Y as the Y of our chart -.-"

            //we pass the config to the SeriesCollection constructor, or you can use Series.Setup(config)
            Series = new SeriesCollection(config)
            {
                new LineSeries
                {
                    Values = new ChartValues<Point>
                    {
                        new Point(1, 10),
                        new Point(2, 15),
                        new Point(4, 29),
                        new Point(8, 38),
                        new Point(16, 45),
                        new Point(32, 55),
                        new Point(64, 62),
                        new Point(128, 76),
                        new Point(256, 95)
                    },
                    Fill = Brushes.Transparent
                }
            };
            
            DataContext = this;
        }
        public HighPerformanceLine()
        {
            InitializeComponent();

            //First you need to install LiveCharts.Optimizations
            //from Nuget:
            //Install-Package LiveCharts.Optimizations

            //LiveCharts.Optimization contains a class called ChartOptimizations where you can find 
            //algorithms according to your chart type, they also have a good description, indicating 
            //which is the best according to your case, using a wrong algorithm could not display data
            //to an optimized quality.

            //var algorithm = ChartOptimizations.Lines.RegularX<double>()
            //    // low quality is the default, but it is really accurate, it could fail only for +-3 pixels
            //    .WithQuality(DataQuality.Low);

            //create a configuration in this case we will use X as a zero based index,
            //and Y as the stored value in Series.Values
            //we will also attach the algorithm we just selected.
            var config = new SeriesConfiguration<double>()
                .X((val, index) => index)
                .Y(val => val);
                //.HasHighPerformanceMethod(algorithm);

            //create a SeriesCollection with this configuration
            Series = new SeriesCollection(config);

            //create a new line series
            var line = new LineSeries {Values = new ChartValues<double>()};


            //add some random values to test
            var r = new Random();
            var trend = 0d;

            for (var i = 0; i < 1000000; i++)
            {
                if (i%1000 == 0) trend += r.Next(-500, 500);
                line.Values.Add(trend + r.Next(-10, 10));
            }

            Series.Add(line);

            //some format
            var now = DateTime.Now.ToOADate();
            XFormat = val => DateTime.FromOADate(now + val/100).ToShortDateString();
            YFormat = val => Math.Round(val) + " ms";

            //set zooming if needed.
            ZoomingMode = ZoomingOptions.XY;

            DataContext = this;
        }
        public ScatterChart()
        {
            AxisY = new Axis();
            AxisX = new Axis();
            Hoverable = true;
            ShapeHoverBehavior = ShapeHoverBehavior.Dot;
            LineType = LineChartLineType.Bezier;
            DataToolTip = new DefaultScatterTooltip();

            var defaultConfig = new SeriesConfiguration<Point>().X(pt => pt.X).Y(pt => pt.Y);
            SetCurrentValue(SeriesProperty, new SeriesCollection(defaultConfig));
        }
        public GenericLine()
        {
            InitializeComponent();

            //In this case we are not only plotting double values,
            //instead each point is an instance of MonthSalesData class.

            //We need to let LiveCharts know how to use MonthSalesData class.
            //you can specify wich property to use as X or Y in chart.
            //in this case we are going to use the SoldItems property as Y
            //we are going to use an indexed X
            //this means first point is 0, second 1, third 2 and so on.
            //X and Y are indexed by default, and it is not necessary to specify it
            //we are doing it just to exmplain how LiveCharts works.
            var config = new SeriesConfiguration <MonthSalesData>()
                         .Y(point => point.SoldItems)
                         .X((point, index) => index);

            //now we create a new SeriesCollection with this configuration
            Sales = new SeriesCollection(config);

            //we add some default series
            Sales.Add(new LineSeries
            {
                Title  = "Charles",
                Values = new ChartValues <MonthSalesData>
                {
                    new MonthSalesData {
                        SoldItems = 15, BestSellers = new[] { "Apple", "Grape" }
                    },
                    new MonthSalesData {
                        SoldItems = 8, BestSellers = new[] { "Orange", "Tomate" }
                    },
                    new MonthSalesData {
                        SoldItems = 8, BestSellers = new[] { "Banana" }
                    }
                }
            });

            //Some labels for X axis
            Labels = new List <string>
            {
                "Jan", "Feb", "Mar", "Apr", "May", "Jun",
                "Jul", "Agu", "Sep", "Oct", "Nov", "Dec"
            };
            //Specify a custom format for Y values.
            YFormatter = y => y + ".00k items";
            //And a custom tooltip
            Chart.DataTooltip = new SalesTooltip();

            DataContext = this;
        }
Beispiel #20
0
 public IngestionProcessor(IPersistentDataProvider persistence, IDataAggregator aggregator, IModelProvider model, IDataMessenger messenger, IRangeMerger <AggregatedDataRange> aggregatedMerger, IRangeMerger <TimeRange> timeMerger, IRangeFilterer <AggregatedDataRange> filterer, SeriesConfiguration configuration, ILogger <IngestionProcessor> logger)
 {
     _persistence                  = persistence;
     _aggregator                   = aggregator;
     _model                        = model;
     _messenger                    = messenger;
     _aggregatedMerger             = aggregatedMerger;
     _timeMerger                   = timeMerger;
     _filterer                     = filterer;
     _configuration                = configuration;
     _logger                       = logger;
     _telemetry.InstrumentationKey = "0def8f5e-9482-48ec-880d-4d2a81834a49";
 }
Beispiel #21
0
        public CassandraPersistentDataProvider(CassandraConfiguration configuration, SeriesConfiguration series, IRangeFilterer <TimeRange> filterer, IModelProvider model)
        {
            _filterer          = filterer;
            _model             = model;
            _lowestAggregation = series.AggregationsSeconds.Min();
            var cluster = Cluster.Builder()
                          .AddContactPoints(configuration.Address)
                          .WithCredentials(configuration.Username, configuration.Password)
                          .WithDefaultKeyspace(configuration.Keyspace)
                          .WithQueryTimeout(configuration.QueryTimeout)
                          .Build();

            _session = cluster.Connect();
        }
Beispiel #22
0
        /// <summary>
        /// Saves the series to cache
        /// </summary>
        /// <param name="_series"></param>
        public void SaveToCache(TvdbSeries _series)
        {
            if (_series != null)
            {
                m_filestream = new FileStream(m_rootFolder + "\\series_" + _series.Id + ".ser", FileMode.Create);
                m_formatter.Serialize(m_filestream, _series);
                m_filestream.Close();

                SeriesConfiguration cfg = new SeriesConfiguration(_series.Id, _series.EpisodesLoaded,
                                                                  _series.BannersLoaded, _series.TvdbActorsLoaded);
                m_filestream = new FileStream(m_rootFolder + "\\series_" + _series.Id + ".cfg", FileMode.Create);
                m_formatter.Serialize(m_filestream, cfg);
                m_filestream.Close();
            }
        }
Beispiel #23
0
        public SeriesModel()
        {
            Configuration = new SeriesConfiguration<SalesInfo>().Y(val => (double) val.Income);

            //series using SeriesCollection configuration
            Add(new BarSeries
            {
                Title = "Series 1",
                Values = new ChartValues<SalesInfo>
                {
                    new SalesInfo{Income = 10000, Rentability = .10},
                    new SalesInfo{Income = 8000, Rentability = .12},
                    new SalesInfo{Income = 6000, Rentability = .13},
                    new SalesInfo{Income = 13000, Rentability = .12},
                    new SalesInfo{Income = 11000, Rentability = .11}
                }
            });
            //this one too, using SeriesCollection configuration 
            Add(new BarSeries
            {
                Title = "Series 2",
                Values = new ChartValues<SalesInfo>
                {
                    new SalesInfo{Income = 10000, Rentability = .10},
                    new SalesInfo{Income = 8000, Rentability = .12},
                    new SalesInfo{Income = 6000, Rentability = .13},
                    new SalesInfo{Income = 13000, Rentability = .12},
                    new SalesInfo{Income = 11000, Rentability = .11}
                }
            });

            //now lets map to another type, we need to configure this type too.
            var averageConfig = new SeriesConfiguration<AverageSalesDto>()
                .Y(val => val.AverageIncome);

            Add(new BarSeries
            {
                Title = "Average Series",
                Values = new ChartValues<AverageSalesDto>
                {
                    new AverageSalesDto {AverageIncome = 9000},
                    new AverageSalesDto {AverageIncome = 7000},
                    new AverageSalesDto {AverageIncome = 8000},
                    new AverageSalesDto {AverageIncome = 16000},
                    new AverageSalesDto {AverageIncome = 12000}
                }
            }.Setup(averageConfig));
        }
        public PointPropertyChangedBar()
        {
            InitializeComponent();

            //create a config for StoreViewModel
            var config = new SeriesConfiguration <StoreViewModel>()
                         .Y(y => y.Income); //use Income property as Y

            //do not configure X
            //this will pull a zero based index as X

            //create a SeriesCollection with this config
            StoresCollection = new SeriesCollection(config);

            //add some Series with ChartValues<StoreViewModel>
            StoresCollection.Add(new BarSeries
            {
                Title  = "Apple Store",
                Values = new ChartValues <StoreViewModel>
                {
                    new StoreViewModel {
                        Income = 15
                    },
                    new StoreViewModel {
                        Income = 18
                    }
                },
                DataLabels = true
            });
            StoresCollection.Add(new BarSeries
            {
                Title  = "Google Play",
                Values = new ChartValues <StoreViewModel>
                {
                    new StoreViewModel {
                        Income = 5
                    },
                    new StoreViewModel {
                        Income = 7
                    }
                },
                DataLabels = true
            });

            DataContext = this;
        }
Beispiel #25
0
        public DynamicLine()
        {
            InitializeComponent();

            //In this case we will not only plot double values
            //to make it easier to handle "live-data" we are going to use WeatherViewModel class
            //we need to let LiveCharts know how to use this model

            //first we create a new configuration for WeatherViewModel
            var config = new SeriesConfiguration <WeatherViewModel>();

            //now we map X and Y
            //we will use Temperature as Y
            config.Y(model => model.Temperature);
            //and DateTime as X, we convert to OADate so we can plot it easly.
            //config.X(model => model.DateTime.ToOADate());
            config.X(x => x.Test);

            //now we create our series with this configuration
            Series = new SeriesCollection(config)
            {
                new LineSeries {
                    Values = new ChartValues <WeatherViewModel>(), PointRadius = 0
                }
            };

            //to display a custom label we will use a formatter,
            //formatters are just functions that take a double value as parameter
            //and return a string, in this case we will convert the OADate to DateTime
            //and then use a custom date format
            //XFormatter = val => DateTime.FromOADate(val).ToString("hh:mm:ss tt");
            //now for Y we are rounding and adding ° for degrees
            YFormatter = val => Math.Round(val) + " °";

            //Don't forget DataContext so we can bind these properties.
            DataContext = this;

            _timer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(500)
            };
            _timer.Tick += TimerOnTick;
        }
        private void InitializeChart()
        {
            var config = new SeriesConfiguration <UsageViewModel>();

            config.Y(x => x.Usage);
            config.X(x => x.Time.ToOADate());
            Series = new SeriesCollection(config)
            {
                new LineSeries {
                    Values      = new ChartValues <UsageViewModel>(),
                    PointRadius = 0,
                },
                new LineSeries
                {
                    Values      = new ChartValues <UsageViewModel>(),
                    PointRadius = 0,
                }
            };
            DataContext = this;
            YFormatter  = val => "";
            XFormatter  = val => "";
        }
        public Logarithmic()
        {
            InitializeComponent();

            var map = new SeriesConfiguration<Point>()
                .X(point => Math.Log(point.X, 10)) // Map X value to Log(X)
                .Y(point => point.Y);              // Use Y without Log

            Series = new SeriesCollection(map) 
            {
                new ScatterSeries
                {
                    Values = new[]
                    {
                        new Point(1, 100), new Point(10, 100), new Point(1000, 300), new Point(10000, 400),
                        new Point(100000, 500), new Point(1000000, 600)
                    }.AsChartValues()
                }
            };

            DataContext = this;
        }
Beispiel #28
0
        public SalesViewModel()
        {
            var config = new SeriesConfiguration <SalesData>().Y(data => data.ItemsSold);

            Salesmen = new SeriesCollection(config)
            {
                new PieSeries
                {
                    Title  = "Charles",
                    Values = new ChartValues <SalesData>
                    {
                        new SalesData {
                            ItemsSold = 15, Rentability = .15, ItemsAverageSellPrice = 5000
                        }
                    }
                },
                new PieSeries
                {
                    Title  = "Frida",
                    Values = new ChartValues <SalesData>
                    {
                        new SalesData {
                            ItemsSold = 16, Rentability = .12, ItemsAverageSellPrice = 5200
                        }
                    }
                },
                new PieSeries
                {
                    Title  = "George",
                    Values = new ChartValues <SalesData>
                    {
                        new SalesData {
                            ItemsSold = 22, Rentability = .11, ItemsAverageSellPrice = 5100
                        }
                    }
                }
            };
        }
Beispiel #29
0
        public LogarithmicAxis()
        {
            InitializeComponent();

            //we create a configuration to map our values type, in this case System.Windows.Point
            var config = new SeriesConfiguration <Point>()
                         .X(point => Math.Log(point.X, 10)) // we use log10(point.X) as X
                         .Y(point => point.Y);              // we use point.Y as the Y of our chart :)

            //we pass the config to the SeriesCollection constructor, or you can use Series.Setup(config)
            Series = new SeriesCollection(config)
            {
                new LineSeries
                {
                    Values = new ChartValues <Point>
                    {
                        new Point(1, 10),
                        new Point(10, 15),
                        new Point(100, 29),
                        new Point(1000, 38),
                        new Point(10000, 45),
                        new Point(100000, 55)
                    },
                    Fill = Brushes.Transparent
                }
            };

            //to display labels we convert back from log
            //this is just the inverse operation
            XFormatter = x =>
            {
                return(Math.Pow(10, x).ToString());
            };

            DataContext = this;
        }
Beispiel #30
0
        public RotatedLine()
        {
            InitializeComponent();

            //we just need to create a configuration to map X, and Y
            var config = new SeriesConfiguration<double>()
                .X(value => value) // use stored value
                .Y((value, index) => index); //this line is not necessary, this is the default config, it is just to explain how LiveCharts works

            SeriesCollection =
                new SeriesCollection(config)
                {
                    new LineSeries
                    {
                        Title = "inverted series",
                        Values = new [] {10, 15, 18, 20, 15, double.NaN, double.NaN, -2, -1, 2, 3, 6}.AsChartValues(),
                        DataLabels = true
                    }
                };

            Formatter = val => "Day " + (val + 1);

            DataContext = this;
        }
Beispiel #31
0
        public RotatedLine()
        {
            InitializeComponent();

            //we just need to create a configuration to map X, and Y
            var config = new SeriesConfiguration <double>()
                         .X(value => value)           // use stored value
                         .Y((value, index) => index); //this line is not necessary, this is the default config, it is just to explain how LiveCharts works

            SeriesCollection =
                new SeriesCollection(config)
            {
                new LineSeries
                {
                    Title  = "inverted series",
                    Values = new [] { 10, 15, 18, 20, 15, double.NaN, -3, -2, -1, 2, 3, 6 }.AsChartValues(),
                    DataLabels = true
                }
            };

            Formatter = val => "Day " + (val + 1);

            DataContext = this;
        }
Beispiel #32
0
 /// <summary>
 /// Setup a configuration for this collection, notice this method returns the current instance to support fleunt syntax. if Series.Cofiguration is not null then SeriesCollection.Configuration will be ignored.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="config"></param>
 /// <returns></returns>
 public Series Setup <T>(SeriesConfiguration <T> config)
 {
     Configuration = config;
     return(this);
 }
        /// <summary>
        /// Saves the series to cache
        /// </summary>
        /// <param name="_series"></param>
        public void SaveToCache(TvdbSeries _series)
        {
            if (_series != null)
              {
            if (!Directory.Exists(m_rootFolder)) Directory.CreateDirectory(m_rootFolder);
            m_filestream = new FileStream(m_rootFolder + "\\series_" + _series.Id + ".ser", FileMode.Create);
            m_formatter.Serialize(m_filestream, _series);
            m_filestream.Close();

            SeriesConfiguration cfg = new SeriesConfiguration(_series.Id, _series.EpisodesLoaded,
                                                  _series.BannersLoaded, _series.TvdbActorsLoaded);
            m_filestream = new FileStream(m_rootFolder + "\\series_" + _series.Id + ".cfg", FileMode.Create);
            m_formatter.Serialize(m_filestream, cfg);
            m_filestream.Close();
              }
        }
        /// <summary>
        /// Saves the series to cache
        /// </summary>
        /// <param name="_series"></param>
        public void SaveToCache(TvdbSeries _series)
        {
            if (_series != null)
              {
            String seriesRoot = m_rootFolder + Path.DirectorySeparatorChar + _series.Id;
            if (!Directory.Exists(seriesRoot)) Directory.CreateDirectory(seriesRoot);

            #region delete all loaded images (since they should be already cached)

            //delete banners
            foreach (TvdbBanner b in _series.Banners)
            {
              if (b.IsLoaded)
              {//banner is loaded
            b.UnloadBanner();
              }

              //remove the ref to the cacheprovider
              b.CacheProvider = null;

              if (b.GetType() == typeof(TvdbBannerWithThumb))
              {//thumb is loaded
            if (((TvdbBannerWithThumb)b).IsThumbLoaded)
            {
              ((TvdbBannerWithThumb)b).UnloadThumb();
            }
              }

              if (b.GetType() == typeof(TvdbFanartBanner))
              {//vignette is loaded
            if (((TvdbFanartBanner)b).IsVignetteLoaded)
            {
              ((TvdbFanartBanner)b).UnloadVignette();
            }
              }
            }

            //delete Actor Images
            if (_series.TvdbActorsLoaded)
            {
              foreach (TvdbActor a in _series.TvdbActors)
              {
            if (a.ActorImage.IsLoaded)
            {
              a.ActorImage.UnloadBanner();
            }
            //remove the ref to the cacheprovider
            a.ActorImage.CacheProvider = null;
              }
            }

            //delete episode images
            if (_series.EpisodesLoaded)
            {
              foreach (TvdbEpisode e in _series.Episodes)
              {
            if (e.Banner.IsLoaded)
            {
              e.Banner.UnloadBanner();
            }
            //remove the ref to the cacheprovider
            e.Banner.CacheProvider = null;
              }
            }
            #endregion
            //serialize series to hdd
            m_filestream = new FileStream(seriesRoot + Path.DirectorySeparatorChar + "series_" + _series.Id + ".ser", FileMode.Create);
            m_formatter.Serialize(m_filestream, _series);
            m_filestream.Close();

            //serialize series config to hdd
            SeriesConfiguration cfg = new SeriesConfiguration(_series.Id, _series.EpisodesLoaded,
                                                  _series.BannersLoaded, _series.TvdbActorsLoaded);
            m_filestream = new FileStream(seriesRoot + Path.DirectorySeparatorChar + "series_" + _series.Id + ".cfg", FileMode.Create);
            m_formatter.Serialize(m_filestream, cfg);
            m_filestream.Close();
              }
        }
        public MainWindow()
        {
            InitializeComponent();
            timer.Start();
            setUpBaudRates();

            var config = new SeriesConfiguration<tempGraph>();
            config.Y(model => model.temperature);
            config.X(model => model.time.ToOADate());
            Series = new SeriesCollection(config) { new LineSeries { Values = new ChartValues<tempGraph>() } };
            Series.Add(new LineSeries { Values = new ChartValues<tempGraph>() });
            Series.Add(new LineSeries { Values = new ChartValues<tempGraph>() });
            Series[0].Title = "External Temperature";
            Series[1].Title = "Internal Temperature";
            Series[2].Title = "Ground Temperature";
            XFormatter = val => DateTime.FromOADate(val).ToString("mm.ss");
            YFormatter = val => val + " °";
            DataContext = this;
            _timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(1000) };
            _timer.Tick += TimerOnTick;
            _timer.Start();

            var config2 = new SeriesConfiguration<pressureGraph>();
            config2.Y(model => model.pressure);
            config2.X(model => model.time.ToOADate());
            Series2 = new SeriesCollection(config2) { new LineSeries { Values = new ChartValues<pressureGraph>() } };
            Series2.Add(new LineSeries { Values = new ChartValues<pressureGraph>() });
            Series2[0].Title = "Barometric Pressure";
            Series2[1].Title = "Ground Barometric Pressure";
            XFormatter2 = val => DateTime.FromOADate(val).ToString("mm.ss");
            YFormatter2 = val => val + "hPa";
            DataContext = this;
            _timer2 = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(1000) };
            _timer2.Tick += Timer2OnTick;
            _timer2.Start();
            this.Show();
            setUpPossibleInputsForSerialPort();
            ///AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
            Binding binding_1 = new Binding("SelectedValue");
            binding_1.Source = VideoDevicesComboBox;
            WebcamCtrl.SetBinding(Webcam.VideoDeviceProperty, binding_1);

            Binding binding_2 = new Binding("SelectedValue");
            binding_2.Source = AudioDevicesComboBox;
            WebcamCtrl.SetBinding(Webcam.AudioDeviceProperty, binding_2);

            // Create directory for saving video files
            string videoPath = @"C:\VideoClips";

            if (!Directory.Exists(videoPath))
            {
                Directory.CreateDirectory(videoPath);
            }
            // Create directory for saving image files
            string imagePath = @"C:\WebcamSnapshots";

            if (!Directory.Exists(imagePath))
            {
                Directory.CreateDirectory(imagePath);
            }
            //AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
            // Set some properties of the Webcam control
            WebcamCtrl.VideoDirectory = videoPath;
            WebcamCtrl.ImageDirectory = imagePath;
            WebcamCtrl.FrameRate = 72;
            WebcamCtrl.FrameSize = new System.Drawing.Size(1080, 720);

            // Find available a/v devices
            var vidDevices = EncoderDevices.FindDevices(EncoderDeviceType.Video);
            var audDevices = EncoderDevices.FindDevices(EncoderDeviceType.Audio);
            VideoDevicesComboBox.ItemsSource = vidDevices;
            AudioDevicesComboBox.ItemsSource = audDevices;
            VideoDevicesComboBox.SelectedIndex = 0;
            AudioDevicesComboBox.SelectedIndex = 0;
            releaseServo.IsEnabled = false;
            servoArm.IsEnabled = false;
            t1.IsEnabled = false;
            t2.IsEnabled = false;
            bw.DoWork += Bw_DoWork;
            bw.RunWorkerCompleted += Bw_RunWorkerCompleted;
            bw.RunWorkerAsync();
            
        }
Beispiel #36
0
        public SalesViewModel()
        {
            AvailableMonths = _months;

            // We create a configuration to map X and Y values
            // in this case we only map Y, X by defualt will be a zero based index.
            var config = new SeriesConfiguration <SalesData>().Y(data => data.ItemsSold);

            //we specify the config to the SeriesCollection
            SalesmenSeries = new SeriesCollection(config)
            {
                //will use SeriesCollection config
                new LineSeries
                {
                    Title  = "Charles",
                    Values = new ChartValues <SalesData>
                    {
                        new SalesData {
                            ItemsSold = 15, Rentability = .15, ItemsAverageSellPrice = 5000
                        },
                        new SalesData {
                            ItemsSold = 16, Rentability = .12, ItemsAverageSellPrice = 5200
                        },
                        new SalesData {
                            ItemsSold = 22, Rentability = .11, ItemsAverageSellPrice = 5100
                        },
                        new SalesData {
                            ItemsSold = 25, Rentability = .13, ItemsAverageSellPrice = 5400
                        },
                        new SalesData {
                            ItemsSold = 20, Rentability = .12, ItemsAverageSellPrice = 5100
                        },
                        new SalesData {
                            ItemsSold = 10, Rentability = .11, ItemsAverageSellPrice = 5200
                        },
                        new SalesData {
                            ItemsSold = 12, Rentability = .13, ItemsAverageSellPrice = 5400
                        }
                    }
                },
                //Will use series collection config too
                new LineSeries
                {
                    Title  = "Frida",
                    Values = new ChartValues <SalesData>
                    {
                        new SalesData {
                            ItemsSold = 25, Rentability = .12, ItemsAverageSellPrice = 5200
                        },
                        new SalesData {
                            ItemsSold = 12, Rentability = .19, ItemsAverageSellPrice = 5100
                        },
                        new SalesData {
                            ItemsSold = 24, Rentability = .12, ItemsAverageSellPrice = 5400
                        },
                        new SalesData {
                            ItemsSold = 15, Rentability = .13, ItemsAverageSellPrice = 5200
                        },
                        new SalesData {
                            ItemsSold = 14, Rentability = .14, ItemsAverageSellPrice = 5100
                        },
                        new SalesData {
                            ItemsSold = 15, Rentability = .13, ItemsAverageSellPrice = 5600
                        },
                        new SalesData {
                            ItemsSold = 14, Rentability = .11, ItemsAverageSellPrice = 4900
                        }
                    }
                },

                //Override config for this series to plot another property or even another type
                new LineSeries
                {
                    Title  = "Average Series",
                    Values = new ChartValues <AverageSalesData>
                    {
                        new AverageSalesData {
                            AverageItemsSold = 22
                        },
                        new AverageSalesData {
                            AverageItemsSold = 23
                        },
                        new AverageSalesData {
                            AverageItemsSold = 21
                        },
                        new AverageSalesData {
                            AverageItemsSold = 22
                        },
                        new AverageSalesData {
                            AverageItemsSold = 23
                        },
                        new AverageSalesData {
                            AverageItemsSold = 24
                        },
                        new AverageSalesData {
                            AverageItemsSold = 22
                        }
                    }
                }.Setup(new SeriesConfiguration <AverageSalesData>().Y(data => data.AverageItemsSold)) // this is the line that overrides SeriesCollection Setup
            };
        }
Beispiel #37
0
 private void button12_Click(object sender, EventArgs e)
 {
     var sample = new StackedSample();
     var config = new SeriesConfiguration<double>();
     sample.ShowDialog();
 }
        public MainWindow()
        {
            InitializeComponent();
            timer.Start();
            setUpBaudRates();

            var config = new SeriesConfiguration <tempGraph>();

            config.Y(model => model.temperature);
            config.X(model => model.time.ToOADate());
            Series = new SeriesCollection(config)
            {
                new LineSeries {
                    Values = new ChartValues <tempGraph>()
                }
            };
            Series.Add(new LineSeries {
                Values = new ChartValues <tempGraph>()
            });
            Series.Add(new LineSeries {
                Values = new ChartValues <tempGraph>()
            });
            Series[0].Title = "External Temperature";
            Series[1].Title = "Internal Temperature";
            Series[2].Title = "Ground Temperature";
            XFormatter      = val => DateTime.FromOADate(val).ToString("mm.ss");
            YFormatter      = val => val + " °";
            DataContext     = this;
            _timer          = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(1000)
            };
            _timer.Tick += TimerOnTick;
            _timer.Start();

            var config2 = new SeriesConfiguration <pressureGraph>();

            config2.Y(model => model.pressure);
            config2.X(model => model.time.ToOADate());
            Series2 = new SeriesCollection(config2)
            {
                new LineSeries {
                    Values = new ChartValues <pressureGraph>()
                }
            };
            Series2.Add(new LineSeries {
                Values = new ChartValues <pressureGraph>()
            });
            Series2[0].Title = "Barometric Pressure";
            Series2[1].Title = "Ground Barometric Pressure";
            XFormatter2      = val => DateTime.FromOADate(val).ToString("mm.ss");
            YFormatter2      = val => val + "hPa";
            DataContext      = this;
            _timer2          = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(1000)
            };
            _timer2.Tick += Timer2OnTick;
            _timer2.Start();
            this.Show();
            setUpPossibleInputsForSerialPort();
            ///AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
            Binding binding_1 = new Binding("SelectedValue");

            binding_1.Source = VideoDevicesComboBox;
            WebcamCtrl.SetBinding(Webcam.VideoDeviceProperty, binding_1);

            Binding binding_2 = new Binding("SelectedValue");

            binding_2.Source = AudioDevicesComboBox;
            WebcamCtrl.SetBinding(Webcam.AudioDeviceProperty, binding_2);

            // Create directory for saving video files
            string videoPath = @"C:\VideoClips";

            if (!Directory.Exists(videoPath))
            {
                Directory.CreateDirectory(videoPath);
            }
            // Create directory for saving image files
            string imagePath = @"C:\WebcamSnapshots";

            if (!Directory.Exists(imagePath))
            {
                Directory.CreateDirectory(imagePath);
            }
            //AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
            // Set some properties of the Webcam control
            WebcamCtrl.VideoDirectory = videoPath;
            WebcamCtrl.ImageDirectory = imagePath;
            WebcamCtrl.FrameRate      = 72;
            WebcamCtrl.FrameSize      = new System.Drawing.Size(1080, 720);

            // Find available a/v devices
            var vidDevices = EncoderDevices.FindDevices(EncoderDeviceType.Video);
            var audDevices = EncoderDevices.FindDevices(EncoderDeviceType.Audio);

            VideoDevicesComboBox.ItemsSource   = vidDevices;
            AudioDevicesComboBox.ItemsSource   = audDevices;
            VideoDevicesComboBox.SelectedIndex = 0;
            AudioDevicesComboBox.SelectedIndex = 0;
            releaseServo.IsEnabled             = false;
            servoArm.IsEnabled     = false;
            t1.IsEnabled           = false;
            t2.IsEnabled           = false;
            bw.DoWork             += Bw_DoWork;
            bw.RunWorkerCompleted += Bw_RunWorkerCompleted;
            bw.RunWorkerAsync();
        }
        public SalesViewModel()
        {
            AvailableMonths = _months;

            // We create a configuration to map X and Y values
            // in this case we only map Y, X by defualt will be a zero based index.
            var config = new SeriesConfiguration<SalesData>().Y(data => data.ItemsSold);

            //we specify the config to the SeriesCollection
            SalesmenSeries = new SeriesCollection(config)
            {
                //will use SeriesCollection config
                new LineSeries
                {
                    Title = "Charles",
                    Values = new ChartValues<SalesData>
                    {
                        new SalesData {ItemsSold = 15, Rentability = .15, ItemsAverageSellPrice = 5000},
                        new SalesData {ItemsSold = 16, Rentability = .12, ItemsAverageSellPrice = 5200},
                        new SalesData {ItemsSold = 22, Rentability = .11, ItemsAverageSellPrice = 5100},
                        new SalesData {ItemsSold = 25, Rentability = .13, ItemsAverageSellPrice = 5400},
                        new SalesData {ItemsSold = 20, Rentability = .12, ItemsAverageSellPrice = 5100},
                        new SalesData {ItemsSold = 10, Rentability = .11, ItemsAverageSellPrice = 5200},
                        new SalesData {ItemsSold = 12, Rentability = .13, ItemsAverageSellPrice = 5400}
                    }
                },
                //Will use series collection config too
                new LineSeries
                {
                    Title = "Frida",
                    Values = new ChartValues<SalesData>
                    {
                        new SalesData {ItemsSold = 25, Rentability = .12, ItemsAverageSellPrice = 5200},
                        new SalesData {ItemsSold = 12, Rentability = .19, ItemsAverageSellPrice = 5100},
                        new SalesData {ItemsSold = 24, Rentability = .12, ItemsAverageSellPrice = 5400},
                        new SalesData {ItemsSold = 15, Rentability = .13, ItemsAverageSellPrice = 5200},
                        new SalesData {ItemsSold = 14, Rentability = .14, ItemsAverageSellPrice = 5100},
                        new SalesData {ItemsSold = 15, Rentability = .13, ItemsAverageSellPrice = 5600},
                        new SalesData {ItemsSold = 14, Rentability = .11, ItemsAverageSellPrice = 4900}
                    }
                },

                //Override config for this series to plot another property or even another type
                new LineSeries
                {
                    Title = "Average Series",
                    Values = new ChartValues<AverageSalesData>
                    {
                        new AverageSalesData {AverageItemsSold = 22},
                        new AverageSalesData {AverageItemsSold = 23},
                        new AverageSalesData {AverageItemsSold = 21},
                        new AverageSalesData {AverageItemsSold = 22},
                        new AverageSalesData {AverageItemsSold = 23},
                        new AverageSalesData {AverageItemsSold = 24},
                        new AverageSalesData {AverageItemsSold = 22}
                    }
                }.Setup(new SeriesConfiguration<AverageSalesData>().Y(data => data.AverageItemsSold)) // this is the line that overrides SeriesCollection Setup

            };
        }
Beispiel #40
0
        public SeriesModel()
        {
            Configuration = new SeriesConfiguration <SalesInfo>().Y(val => (double)val.Income);

            //series using SeriesCollection configuration
            Add(new BarSeries
            {
                Title  = "Series 1",
                Values = new ChartValues <SalesInfo>
                {
                    new SalesInfo {
                        Income = 10000, Rentability = .10
                    },
                    new SalesInfo {
                        Income = 8000, Rentability = .12
                    },
                    new SalesInfo {
                        Income = 6000, Rentability = .13
                    },
                    new SalesInfo {
                        Income = 13000, Rentability = .12
                    },
                    new SalesInfo {
                        Income = 11000, Rentability = .11
                    }
                }
            });
            //this one too, using SeriesCollection configuration
            Add(new BarSeries
            {
                Title  = "Series 2",
                Values = new ChartValues <SalesInfo>
                {
                    new SalesInfo {
                        Income = 10000, Rentability = .10
                    },
                    new SalesInfo {
                        Income = 8000, Rentability = .12
                    },
                    new SalesInfo {
                        Income = 6000, Rentability = .13
                    },
                    new SalesInfo {
                        Income = 13000, Rentability = .12
                    },
                    new SalesInfo {
                        Income = 11000, Rentability = .11
                    }
                }
            });

            //now lets map to another type, we need to configure this type too.
            var averageConfig = new SeriesConfiguration <AverageSalesDto>()
                                .Y(val => val.AverageIncome);

            Add(new BarSeries
            {
                Title  = "Average Series",
                Values = new ChartValues <AverageSalesDto>
                {
                    new AverageSalesDto {
                        AverageIncome = 9000
                    },
                    new AverageSalesDto {
                        AverageIncome = 7000
                    },
                    new AverageSalesDto {
                        AverageIncome = 8000
                    },
                    new AverageSalesDto {
                        AverageIncome = 16000
                    },
                    new AverageSalesDto {
                        AverageIncome = 12000
                    }
                }
            }.Setup(averageConfig));
        }
Beispiel #41
0
        public HighPerformanceLine()
        {
            InitializeComponent();

            //First you need to install LiveCharts.Optimizations
            //from Nuget:
            //Install-Package LiveCharts.Optimizations

            //LiveCharts.Optimization contains a class called ChartOptimizations where you can find
            //algorithms according to your chart type, they also have a good description, indicating
            //which is the best according to your case, using a wrong algorithm could not display data
            //to an optimized quality.

            //var algorithm = ChartOptimizations.Lines.RegularX<double>()
            //    // low quality is the default, but it is really accurate, it could fail only for +-3 pixels
            //    .WithQuality(DataQuality.Low);

            //create a configuration in this case we will use X as a zero based index,
            //and Y as the stored value in Series.Values
            //we will also attach the algorithm we just selected.
            var config = new SeriesConfiguration <double>()
                         .X((val, index) => index)
                         .Y(val => val);

            //.HasHighPerformanceMethod(algorithm);

            //create a SeriesCollection with this configuration
            Series = new SeriesCollection(config);

            //create a new line series
            var line = new LineSeries {
                Values = new ChartValues <double>()
            };


            //add some random values to test
            var r     = new Random();
            var trend = 0d;

            for (var i = 0; i < 1000000; i++)
            {
                if (i % 1000 == 0)
                {
                    trend += r.Next(-500, 500);
                }
                line.Values.Add(trend + r.Next(-10, 10));
            }

            Series.Add(line);

            //some format
            var now = DateTime.Now.ToOADate();

            XFormat = val => DateTime.FromOADate(now + val / 100).ToShortDateString();
            YFormat = val => Math.Round(val) + " ms";

            //set zooming if needed.
            ZoomingMode = ZoomingOptions.XY;

            DataContext = this;
        }
Beispiel #42
0
        protected Chart()
        {
            var b = new Border();
            Canvas = new Canvas();
            b.Child = Canvas;
            Content = b;

            if (RandomizeStartingColor) ColorStartIndex = Randomizer.Next(0, Colors.Count - 1);

            AnimatesNewPoints = false;

            var defaultConfig = new SeriesConfiguration<double>().Y(x => x);
            SetCurrentValue(SeriesProperty, new SeriesCollection(defaultConfig));
            DataTooltip = new DefaultIndexedTooltip();
            Shapes = new List<FrameworkElement>();
            ShapesMapper = new List<ShapeMap>();
            PointHoverColor = System.Windows.Media.Colors.White;

            Background = Brushes.Transparent;

            SizeChanged += Chart_OnsizeChanged;
            MouseWheel += MouseWheelOnRoll;
            MouseLeftButtonDown += MouseDownForPan;
            MouseLeftButtonUp += MouseUpForPan;
            MouseMove += MouseMoveForPan;

            _resizeTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(100)
            };
            _resizeTimer.Tick += (sender, e) =>
            {
                _resizeTimer.Stop();
                Update();
            };
            TooltipTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(1000)
            };
            TooltipTimer.Tick += TooltipTimerOnTick;

            _serieValuesChanged = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(100)};
            _serieValuesChanged.Tick += UpdateModifiedDataSeries;

            SeriesChanged = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(100)};
            SeriesChanged.Tick += UpdateSeries;
        }
Beispiel #43
0
        /// <summary>
        /// Saves the series to cache
        /// </summary>
        /// <param name="_series">Tvdb series</param>
        public void SaveToCache(TvdbSeries _series)
        {
            if (_series != null)
            {
                String seriesRoot = m_rootFolder + Path.DirectorySeparatorChar + _series.Id;
                if (!Directory.Exists(seriesRoot))
                {
                    Directory.CreateDirectory(seriesRoot);
                }

                #region delete all loaded images (since they should be already cached)

                //delete banners
                foreach (TvdbBanner b in _series.Banners)
                {
                    if (b.IsLoaded)
                    {//banner is loaded
                        b.UnloadBanner();
                    }

                    //remove the ref to the cacheprovider
                    b.CacheProvider = null;

                    if (b.GetType() == typeof(TvdbBannerWithThumb))
                    {//thumb is loaded
                        if (((TvdbBannerWithThumb)b).IsThumbLoaded)
                        {
                            ((TvdbBannerWithThumb)b).UnloadThumb();
                        }
                    }

                    if (b.GetType() == typeof(TvdbFanartBanner))
                    {//vignette is loaded
                        if (((TvdbFanartBanner)b).IsVignetteLoaded)
                        {
                            ((TvdbFanartBanner)b).UnloadVignette();
                        }
                    }
                }

                //delete Actor Images
                if (_series.TvdbActorsLoaded)
                {
                    foreach (TvdbActor a in _series.TvdbActors)
                    {
                        if (a.ActorImage.IsLoaded)
                        {
                            a.ActorImage.UnloadBanner();
                        }
                        //remove the ref to the cacheprovider
                        a.ActorImage.CacheProvider = null;
                    }
                }

                //delete episode images
                if (_series.EpisodesLoaded)
                {
                    foreach (TvdbEpisode e in _series.Episodes)
                    {
                        if (e.Banner.IsLoaded)
                        {
                            e.Banner.UnloadBanner();
                        }
                        //remove the ref to the cacheprovider
                        e.Banner.CacheProvider = null;
                    }
                }
                #endregion
                //serialize series to hdd
                m_filestream = new FileStream(seriesRoot + Path.DirectorySeparatorChar + "series_" + _series.Id + ".ser", FileMode.Create);
                m_formatter.Serialize(m_filestream, _series);
                m_filestream.Close();

                //serialize series config to hdd
                SeriesConfiguration cfg = new SeriesConfiguration(_series.Id, _series.EpisodesLoaded,
                                                                  _series.BannersLoaded, _series.TvdbActorsLoaded);
                m_filestream = new FileStream(seriesRoot + Path.DirectorySeparatorChar + "series_" + _series.Id + ".cfg", FileMode.Create);
                m_formatter.Serialize(m_filestream, cfg);
                m_filestream.Close();
            }
        }
        public Window1()
        {
            InitializeComponent();

            TopLeftLimit = new LagTest();
            TopRightLimit = new LagTest();
            BotLeftLimit = new LagTest();
            BotRightLimit = new LagTest();

            _r = new Random();

            //ok in this case we are plotting the lag of some different servers according to a date
            //we also need to highlight the max and min values in each test.

            //notice that the LagTestClass implements IObservableChartPoint
            //this allows the char to notice when a value changes

            //Lets define a configuration by default for all the series in the SeriesCollection
            var defConfig = new SeriesConfiguration<LagTest>()
                .X(lagTest => lagTest.DateTime.ToOADate())
                .Y(lagTest => lagTest.Value);

            var serverA = new LineSeries
            {
                Title = "Server A",
                Values = new ChartValues<LagTest>
                {
                    new LagTest {DateTime = DateTime.Now.AddDays(0), Value = _r.Next(0, 100)},
                    new LagTest {DateTime = DateTime.Now.AddDays(1), Value = _r.Next(0, 100)},
                    new LagTest {DateTime = DateTime.Now.AddDays(2), Value = _r.Next(0, 100)},
                },
                Fill = Brushes.Transparent
            };
            var serverB = new LineSeries
            {
                Title = "Server B",
                Values = new ChartValues<LagTest>
                {
                    new LagTest {DateTime = DateTime.Now.AddDays(0), Value = _r.Next(0, 100)},
                    new LagTest {DateTime = DateTime.Now.AddDays(1), Value = _r.Next(0, 100)},
                    new LagTest {DateTime = DateTime.Now.AddDays(2), Value = _r.Next(0, 100)},
                },
                Fill = Brushes.Transparent
            };

            //to highlight the max and min values, we will also plot 2 more series
            //every series contains 2 points: max and min

            _min = new LineSeries
            {
                Values = new ChartValues<LagTest> {BotLeftLimit, BotRightLimit},
                StrokeThickness = 1,
                StrokeDashArray = new DoubleCollection {2}, //make it dashed
                Stroke = Brushes.DarkBlue,
                Fill = Brushes.Transparent
            };
            _max = new LineSeries
            {
                Values = new ChartValues<LagTest> {TopLeftLimit, TopRightLimit},
                StrokeThickness = 1,
                StrokeDashArray = new DoubleCollection {2}, //make it dashed
                Stroke = Brushes.DarkBlue,
                Fill = Brushes.Transparent
            };

            Servers = new SeriesCollection(defConfig)
            {
                _min,
                _max,
                serverA,
                serverB
            };

            _maxAndMin = new List<Series> {_min, _max}.AsEnumerable();
            CalculateLimits();

            DateFormatter = val => DateTime.FromOADate(val).ToString("M");

            DataContext = this;
        }
        public PointPropertyChangedBar()
        {
            InitializeComponent();

            //create a config for StoreViewModel
            var config = new SeriesConfiguration<StoreViewModel>()
                .Y(y => y.Income); //use Income property as Y
                                   //do not configure X
                                   //this will pull a zero based index as X

            //create a SeriesCollection with this config
            StoresCollection = new SeriesCollection(config);

            //add some Series with ChartValues<StoreViewModel>
            StoresCollection.Add(new BarSeries
            {
                Title = "Apple Store",
                Values = new ChartValues<StoreViewModel>
                {
                    new StoreViewModel {Income = 15}
                }
            });
            StoresCollection.Add(new BarSeries
            {
                Title = "Google Play",
                Values = new ChartValues<StoreViewModel>
                {
                    new StoreViewModel {Income = 5}
                }
            });

            DataContext = this;
        }