示例#1
0
        //ObservableCollection<Point>  LinePoints = new ObservableCollection<Point>();

        private void AddChart(Size finalSize, List <KeyValuePair <int, int> > collection)
        {
            var maxValueFromHeight = ValueList(finalSize);
            var maxValueFromWidth  = KeyList(finalSize);
            ObservableCollection <LineSeries> dc = new ObservableCollection <LineSeries>();
            PointCollection pointCollection      = new PointCollection();

            foreach (var item in collection)
            {
                chartModelCollection.Xstep = (finalSize.Width - 40) / collection.Count;
                chartModelCollection.Ystep = (finalSize.Height - 40) / collection.Count;

                var point = (new Point(((((finalSize.Width - 40) / maxValueFromWidth) * item.Key) + 20),
                                       (finalSize.Height - 20) - (((finalSize.Height - 40) / maxValueFromHeight) * item.Value)));

                pointCollection.Add(point);
                var myEllipse = CreateEllipse(point);
                canvas.Children.Add(myEllipse);
            }
            lineSeries.SetLinePattern(lineSeries.LinePattern);
            Polyline line = new Polyline();

            line.Points          = pointCollection;
            line.Stroke          = lineSeries.LineColor;
            line.StrokeThickness = lineSeries.LineThickness;
            line.StrokeDashArray = lineSeries.LineDashPattern;
            line.StrokeDashCap   = PenLineCap.Square;
            canvas.Children.Add(line);

            dc.Add(lineSeries);

            //SetLines(dc);
        }