コード例 #1
0
        private void DrawHorizontalBar(Point pt, ChartStyleGridlines csg, DataSeriesBar ds, double width, double x)
        {
            Polygon plg = new Polygon();

            plg.Fill            = ds.FillColor;
            plg.Stroke          = ds.BorderColor;
            plg.StrokeThickness = ds.BorderThickness;

            double y = pt.Y - 0.5 * csg.YTick;

            plg.Points.Add(csg.NormalizePoint(new Point(x, y - width / 2)));
            plg.Points.Add(csg.NormalizePoint(new Point(x, y + width / 2)));
            plg.Points.Add(csg.NormalizePoint(new Point(x + pt.X, y + width / 2)));
            plg.Points.Add(csg.NormalizePoint(new Point(x + pt.X, y - width / 2)));
            csg.ChartCanvas.Children.Add(plg);
        }
コード例 #2
0
        private void DrawVerticalBar(Point pt, ChartStyleGridlines csg, DataSeriesBar ds, double width, double y)
        {
            Polygon plg = new Polygon();

            plg.Fill            = ds.FillColor;
            plg.Stroke          = ds.BorderColor;
            plg.StrokeThickness = ds.BorderThickness;

            double x = pt.X - 0.5 * csg.XTick;

            plg.Points.Add(csg.NormalizePoint(new Point(x - width / 2, y)));
            plg.Points.Add(csg.NormalizePoint(new Point(x + width / 2, y)));
            plg.Points.Add(csg.NormalizePoint(new Point(x + width / 2, y + pt.Y)));
            plg.Points.Add(csg.NormalizePoint(new Point(x - width / 2, y + pt.Y)));
            csg.ChartCanvas.Children.Add(plg);
        }
コード例 #3
0
        private void AddVerticalBarChart()
        {
            cs = new ChartStyleGridlines();
            dc = new DataCollectionBar();
            ds = new DataSeriesBar();

            dc.BarType         = DataCollectionBar.BarTypeEnum.Vertical;
            cs.ChartCanvas     = chartCanvas;
            cs.TextCanvas      = textCanvas;
            cs.Title           = "Bar Chart";
            cs.Xmin            = 0;
            cs.Xmax            = 5;
            cs.Ymin            = 0;
            cs.Ymax            = 10;
            cs.XTick           = 1;
            cs.YTick           = 2;
            cs.GridlinePattern = ChartStyleGridlines.GridlinePatternEnum.Dot;
            cs.GridlineColor   = Brushes.Black;
            cs.AddChartStyle(tbTitle, tbXLabel, tbYLabel);

            // Draw the bar chart:
            dc.DataList.Clear();
            ds             = new DataSeriesBar();
            ds.BorderColor = Brushes.Red;
            ds.FillColor   = Brushes.Green;
            ds.BarWidth    = 0.6;

            /*for (int i = 0; i < 5; i++)
             * {
             *  double x = i + 1.0;
             *  double y = 2.0 * x;
             *  ds.LineSeries.Points.Add(new Point(x, y));
             * }*/

            double[] x = new double[] { 1, 2, 3, 4, 5 };
            double[] y = new double[] { 2, 0, 3, 8, 10 };
            for (int i = 0; i < x.Length; i++)
            {
                ds.LineSeries.Points.Add(new Point(x[i], y[i]));
            }

            dc.DataList.Add(ds);
            dc.AddBars(cs);
        }
コード例 #4
0
        private void DrawHorizontalBar1(Point pt, ChartStyleGridlines csg, DataSeriesBar ds, int nSeries, int n)
        {
            Polygon plg = new Polygon();

            plg.Fill            = ds.FillColor;
            plg.Stroke          = ds.BorderColor;
            plg.StrokeThickness = ds.BorderThickness;

            double width = 0.7 * csg.YTick;
            double w1    = width / nSeries;
            double w     = ds.BarWidth * w1;
            double space = (w1 - w) / 2;
            double y     = pt.Y - 0.5 * csg.YTick;

            plg.Points.Add(csg.NormalizePoint(new Point(0, y - width / 2 + space + n * w1)));
            plg.Points.Add(csg.NormalizePoint(new Point(0, y - width / 2 + space + n * w1 + w)));
            plg.Points.Add(csg.NormalizePoint(new Point(pt.X, y - width / 2 + space + n * w1 + w)));
            plg.Points.Add(csg.NormalizePoint(new Point(pt.X, y - width / 2 + space + n * w1)));
            csg.ChartCanvas.Children.Add(plg);
        }
コード例 #5
0
        private void AddHorizontalBarChart()
        {
            cs = new ChartStyleGridlines();
            dc = new DataCollectionBar();
            ds = new DataSeriesBar();

            dc.BarType         = DataCollectionBar.BarTypeEnum.Horizontal;
            cs.ChartCanvas     = chartCanvas;
            cs.TextCanvas      = textCanvas;
            cs.Title           = "Bar Chart";
            cs.Xmin            = 0;
            cs.Xmax            = 10;
            cs.Ymin            = 0;
            cs.Ymax            = 5;
            cs.XTick           = 2;
            cs.YTick           = 1;
            cs.GridlinePattern = ChartStyleGridlines.GridlinePatternEnum.Dot;
            cs.GridlineColor   = Brushes.Black;
            cs.AddChartStyle(tbTitle, tbXLabel, tbYLabel);

            // Draw the bar chart:
            dc.DataList.Clear();
            ds             = new DataSeriesBar();
            ds.BorderColor = Brushes.Red;
            ds.FillColor   = Brushes.Green;
            ds.BarWidth    = 0.6;

            for (int i = 0; i < 5; i++)
            {
                double x = i + 1.0;
                double y = 2.0 * x;
                ds.LineSeries.Points.Add(new Point(y, x));
            }
            dc.DataList.Add(ds);
            dc.AddBars(cs);
        }
コード例 #6
0
        private void AddVerticalGroupBarChart()
        {
            cs = new ChartStyleGridlines();
            dc = new DataCollectionBar();
            ds = new DataSeriesBar();

            dc.BarType         = DataCollectionBar.BarTypeEnum.VerticalStack;
            cs.ChartCanvas     = chartCanvas;
            cs.TextCanvas      = textCanvas;
            cs.Title           = dc.BarType.ToString();
            cs.Xmin            = 0;
            cs.Xmax            = 5;
            cs.Ymin            = 0;
            cs.Ymax            = 25;
            cs.XTick           = 1;
            cs.YTick           = 5;
            cs.GridlinePattern = ChartStyleGridlines.GridlinePatternEnum.Dot;
            cs.GridlineColor   = Brushes.Black;
            cs.AddChartStyle(tbTitle, tbXLabel, tbYLabel);

            // Add the first bar series:
            dc.DataList.Clear();
            ds             = new DataSeriesBar();
            ds.BorderColor = Brushes.Red;
            ds.FillColor   = Brushes.Green;
            ds.BarWidth    = 0.8;

            for (int i = 0; i < 5; i++)
            {
                double x = i + 1.0;
                double y = 2.0 * x;
                ds.LineSeries.Points.Add(new Point(x, y));
            }
            dc.DataList.Add(ds);

            // Add the second bar series:
            ds             = new DataSeriesBar();
            ds.BorderColor = Brushes.Red;
            ds.FillColor   = Brushes.Yellow;
            ds.BarWidth    = 0.8;

            for (int i = 0; i < 5; i++)
            {
                double x = i + 1.0;
                double y = 1.5 * x;
                ds.LineSeries.Points.Add(new Point(x, y));
            }
            dc.DataList.Add(ds);

            // Add the third bar series:
            ds             = new DataSeriesBar();
            ds.BorderColor = Brushes.Red;
            ds.FillColor   = Brushes.Blue;
            ds.BarWidth    = 0.8;

            for (int i = 0; i < 5; i++)
            {
                double x = i + 1.0;
                double y = 1.0 * x;
                ds.LineSeries.Points.Add(new Point(x, y));
            }
            dc.DataList.Add(ds);
            dc.AddBars(cs);
        }