示例#1
0
        public void TakeTheChart()
        {
            var viewbox = new Viewbox();

            viewbox.Child = chart;
            viewbox.Measure(chart.RenderSize);
            viewbox.Arrange(new Rect(new Point(0, 0), chart.RenderSize));
            chart.Update(true, true);
            viewbox.UpdateLayout();
            SaveToPng(chart, chart.Tag.ToString());
        }
示例#2
0
        private void CreateChart(PdfPage page, PdfLayoutResult result, PdfTextElement element, RapportVragenlijstVM answerlist)
        {
            List <RapportVragenlijstStap> chartList = new List <RapportVragenlijstStap>();

            foreach (var x in answerlist.Stappen)
            {
                if (x.TypeNaam.Equals("Getal"))
                {
                    chartList.Add(x);
                }
            }

            CartesianChart Chart = new CartesianChart
            {
                DisableAnimations = true,
                Width             = 600,
                Height            = 400,
                Series            = new SeriesCollection
                {
                    new ColumnSeries
                    {
                        Values = new ChartValues <double> {
                            4, 3, 2, 5, 10
                        }
                    }
                }
            };

            Chart.AxisY.Add(new Axis
            {
                MinValue  = 0,
                MaxValue  = 10,
                Separator = new LiveCharts.Wpf.Separator
                {
                    Step      = 1,
                    IsEnabled = true
                }
            });

            string path = "chart.png";

            Chart.Update(true, true);
            SaveToPng(Chart, path);
        }
示例#3
0
        public void SharingSeries()
        {
            var aGuy = new CartesianChart();
            var bGuy = new CartesianChart();

            aGuy.MockIt(new CoreSize(200, 200));
            bGuy.MockIt(new CoreSize(200, 200));

            var aSeries = new LineSeries();

            aGuy.Series.Add(aSeries);
            aGuy.Update();
            Debug.WriteLine(aGuy.Series.Count);

            bGuy.Series.Add(aSeries);
            bGuy.Update();
            Debug.WriteLine(aGuy.Series.Count);
            Debug.WriteLine(bGuy.Series.Count);
        }
示例#4
0
        //сохранение графика как картинку
        private void SaveFile(string _fileName, string pathForSave)
        {
            var save = DataContext as MainWindiwViewModel;
            ChartValues <double> valueLeft  = null;
            ChartValues <double> valueRight = null;
            string titleAxisY = null;

            //выбор данных
            switch (_fileName)
            {
            case "График Вертикальных силы ":
                valueLeft  = save.selectedForce.LeftVerticalForMovingAverage;
                valueRight = save.selectedForce.RightVerticalForMovingAverage;
                titleAxisY = "Вертикальные силы, кН";
                break;

            case "График Боковых силы ":
                valueLeft  = save.selectedForce.LeftLateralForMovingAverage;
                valueRight = save.selectedForce.RightLateralForMovingAverage;
                titleAxisY = "Боковых силы, кН";
                break;

            case "График Коэффициента запаса от схода ":
                valueLeft  = save.selectedForce.LeftSafetyFactorForMovingAverage;
                valueRight = save.selectedForce.RightSafetyFactorForMovingAverage;
                titleAxisY = "Коэффициент запаса от схода";
                break;
            }
            //создавание графика
            if (save.selectedForce != null)
            {
                var myChart = new CartesianChart
                {
                    DataTooltip       = null,
                    DisableAnimations = true,
                    Hoverable         = true,
                    LegendLocation    = LegendLocation.Bottom,
                    Width             = 1920,
                    Height            = 1080,
                    Series            = new SeriesCollection
                    {
                        new LineSeries
                        {
                            StrokeThickness   = 1,
                            LineSmoothness    = 1,
                            Title             = "Левое колесо",
                            Stroke            = Brushes.Blue,
                            Fill              = Brushes.Transparent,
                            PointGeometrySize = 6,
                            PointForeground   = Brushes.White,
                            PointGeometry     = null,
                            Values            = valueLeft
                        },
                        new LineSeries
                        {
                            StrokeThickness   = 1,
                            LineSmoothness    = 1,
                            Title             = "Правое колесо",
                            Stroke            = Brushes.Red,
                            Fill              = Brushes.Transparent,
                            PointGeometrySize = 6,
                            PointForeground   = Brushes.Gold,
                            PointGeometry     = null,
                            Values            = valueRight
                        }
                    }
                };

                var _AxisAbscissa = new Axis();
                _AxisAbscissa.Title  = "Время,сек";
                _AxisAbscissa.Labels = save.selectedForce.TimeForMovingAverage;
                myChart.AxisX.Add(_AxisAbscissa);

                var _AxisOrdinate = new Axis();
                _AxisOrdinate.Title = titleAxisY;
                myChart.AxisY.Add(_AxisOrdinate);

                var viewbox = new Viewbox();
                viewbox.Child = myChart;
                viewbox.Measure(myChart.RenderSize);
                viewbox.Arrange(new Rect(new Point(0, 0), myChart.RenderSize));
                myChart.Update(true, true);
                myChart.Background = Brushes.White;
                viewbox.UpdateLayout();
                var allName = _fileName + save.selectedForce._NameSignal + ".png";

                SaveToPng(myChart, allName, pathForSave);
            }
        }
示例#5
0
 public void ForceRefresh()
 {
     Element.Update(false, true);
 }