public void RefreshPieChart()
        {
            ChartPoints.RemoveAllPoints();
            monthList.OrderBy(s => s.Rok).ThenBy(s => s.NumerMiesiaca);

            //Ilość wyświetlanych miesięcy bazując na rozmiarze okna
            int displayMonth = 3;

            if (newWindowHeight > 440 && newWindowWidth > 440)
            {
                displayMonth = 6;
            }
            if (newWindowHeight > 800 && newWindowWidth > 800)
            {
                displayMonth = 12;
            }

            Month tmp;

            for (int i = 0; i < displayMonth && i < monthList.Count; i++)
            {
                tmp = monthList.ElementAt(i);
                ChartPoints.AddPoint(tmp.Wydatek, tmp.Rok + " " + tmp.NazwaMiesiaca);
            }
        }
        public void RefreshPieChart()
        {
            ChartPoints.RemoveAllPoints();
            productList.OrderBy(s => (s.Cena * s.Ilosc));

            //Ilość wyświetlanych produktów bazując na rozmiarze okna
            int displayProducts = 3;

            if (newWindowHeight > 440 && newWindowWidth > 440)
            {
                displayProducts = 6;
            }
            if (newWindowHeight > 800 && newWindowWidth > 800)
            {
                displayProducts = 12;
            }

            Product tmp;
            int     i;

            for (i = 0; i < displayProducts - 1 && i < productList.Count; i++)
            {
                tmp = productList.ElementAt(i);
                ChartPoints.AddPoint(tmp.Cena * tmp.Ilosc, tmp.NazwaProduktu);
            }

            double sum = 0;

            for (; i < productList.Count; i++)
            {
                tmp  = productList.ElementAt(i);
                sum += tmp.Cena * tmp.Ilosc;
            }
            if (sum > 0)
            {
                ChartPoints.AddPoint(sum, "Inne");
            }
        }
Exemple #3
0
        public override void Plot(bool animate = true)
        {
            var s = new List <Shape>();

            if (LineChart.LineType == LineChartLineType.Bezier)
            {
                s.AddRange(_addSerieAsBezier(ChartPoints.Select(x => new Point(
                                                                    ToPlotArea(x.X, AxisTags.X) + Chart.XOffset, ToPlotArea(x.Y, AxisTags.Y))).ToArray(), animate));
            }

            if (LineChart.LineType == LineChartLineType.Polyline)
            {
                s.AddRange(_addSeriesAsPolyline(ChartPoints.Select(x => new Point(
                                                                       ToPlotArea(x.X, AxisTags.X) + Chart.XOffset, ToPlotArea(x.Y, AxisTags.Y))).ToArray(), animate));
            }

            var hoverableAreas = new List <HoverableShape>();

            if (Chart.Hoverable)
            {
                foreach (var point in ChartPoints)
                {
                    var plotPoint = ToPlotArea(point);
                    plotPoint.X += Chart.XOffset;
                    var e = new Ellipse
                    {
                        Width  = PointRadius * 2,
                        Height = PointRadius * 2,
                        Fill   = Stroke,
                        Stroke = new SolidColorBrush {
                            Color = Chart.PointHoverColor
                        },
                        StrokeThickness = 2,
                        ClipToBounds    = true
                    };
                    var r = new Rectangle
                    {
                        Fill            = Brushes.Transparent,
                        Width           = 40,
                        Height          = 40,
                        StrokeThickness = 0
                    };

                    r.MouseEnter += Chart.DataMouseEnter;
                    r.MouseLeave += Chart.DataMouseLeave;

                    Canvas.SetLeft(r, ToPlotArea(point.X, AxisTags.X) - r.Width / 2);
                    Canvas.SetTop(r, ToPlotArea(point.Y, AxisTags.Y) - r.Height / 2);
                    Panel.SetZIndex(r, int.MaxValue);
                    Canvas.SetLeft(e, plotPoint.X - e.Width * .5);
                    Canvas.SetTop(e, plotPoint.Y - e.Height * .5);

                    Chart.Canvas.Children.Add(r);
                    Chart.Canvas.Children.Add(e);

                    s.Add(e);
                    hoverableAreas.Add(new HoverableShape
                    {
                        Series = this,
                        Shape  = r,
                        Value  = point,
                        Target = e
                    });
                }
            }
            Shapes.AddRange(s);
            Chart.HoverableShapes.AddRange(hoverableAreas);
        }