Пример #1
0
        private void InitializeCartesianChart()
        {
            const double step    = 0.5;
            const double factor  = 1000;
            const int    maxStep = 2;
            var          temp    = 0.0;

            var points = new List <Points>
            {
                new Points()
                {
                    Y = ComputeService.GetPhaseFrequencyСharacteristic(temp),
                    X = 1
                }
            };


            while (temp < maxStep)
            {
                temp += step;

                var frequency = ComputeService.GetPhaseFrequencyСharacteristic(temp * factor);

                points.Add(new Points()
                {
                    X = temp,
                    Y = frequency
                });
            }

            var chartValues = new ChartValues <double>();

            foreach (var point in points)
            {
                chartValues.Add(point.Y);
            }

            var series = new LiveCharts.Wpf.LineSeries()
            {
                Title  = "АЧХ",
                Values = chartValues
            };

            //cartesianChartShowData.Series = new SeriesCollection
            //{
            //    new LiveCharts.Wpf.LineSeries
            //    {
            //        Title = "АЧХ",
            //        Values = new ChartValues<double> {10, 6, 5, 2, 7}
            //    }
            //};

            cartesianChartShowData.Series = new SeriesCollection()
            {
                series
            };

            cartesianChartShowData.AxisX.Add(new LiveCharts.Wpf.Axis
            {
                Title  = "Frequency",
                Labels = new[] { "1", "0,5 * 10^3", "1 * 10^3", "1,5 * 10^3", "2 * 10^3" }
            });

            cartesianChartShowData.AxisY.Add(new LiveCharts.Wpf.Axis
            {
                Title          = "Sales",
                LabelFormatter = value => value.ToString(CultureInfo.InvariantCulture)
            });

            cartesianChartShowData.LegendLocation = LegendLocation.Right;
        }