示例#1
0
 public BarControl()
 {
     InitializeComponent();
     ChartStyleGridLines = new ChartStyleGridLines
     {
         ChartCanvas = ChartCanvas,
         TextCanvas = TextCanvas
     };
     DataCollectionBar = new VerticalBar();
     DataSeriesBar = new DataSeriesBar();
 }
        private void Grid8_OnSizeChanged(object sender, SizeChangedEventArgs e)
        {
            bar4.Height = grid8.ActualHeight;
            bar4.Width = grid8.ActualWidth;
            bar4.ChartStyleGridLines.Title = "4th Bar Chart";
            bar4.ChartStyleGridLines.Xmin = 0;
            bar4.ChartStyleGridLines.Xmax = 25;
            bar4.ChartStyleGridLines.Ymin = 0;
            bar4.ChartStyleGridLines.Ymax = 5;
            bar4.ChartStyleGridLines.XTick = 5;
            bar4.ChartStyleGridLines.YTick = 1;
            bar4.ChartStyleGridLines.LinePattern = LinePattern.Dot;
            bar4.ChartStyleGridLines.LineColor = Brushes.Black;

            bar4.DataCollectionBar = new HorizontalStackBar();
            DataSeriesBar ds = new DataSeriesBar
            {
                BorderColor = Brushes.Red,
                FillColor = Brushes.Green,
                BarWidth = 0.8
            };
            for (int i = 0; i < 5; i++)
            {
                double x = i + 1.0;
                double y = x * 2.0;
                ds.LineSeries.Points.Add(new Point(y, x));
            }
            bar4.DataCollectionBar.DataList.Add(ds);
            ds = new DataSeriesBar
            {
                BorderColor = Brushes.Red,
                FillColor = Brushes.Yellow,
                BarWidth = 0.8
            };
            for (int i = 0; i < 5; i++)
            {
                double x = i + 1.0;
                double y = x * 1.5;
                ds.LineSeries.Points.Add(new Point(y, x));
            }
            bar4.DataCollectionBar.DataList.Add(ds);
            ds = new DataSeriesBar
            {
                BorderColor = Brushes.Red,
                FillColor = Brushes.Blue,
                BarWidth = 0.8
            };
            for (int i = 0; i < 5; i++)
            {
                double x = i + 1.0;
                double y = x;
                ds.LineSeries.Points.Add(new Point(y, x));
            }
            bar4.DataCollectionBar.DataList.Add(ds);
            bar4.DataCollectionBar.AddBars(bar4.ChartStyleGridLines);
        }
        private void Grid5_OnSizeChanged(object sender, SizeChangedEventArgs e)
        {
            bar1.Height = grid5.ActualHeight;
            bar1.Width = grid5.ActualWidth;
            bar1.ChartStyleGridLines.Title = "1st Bar Chart";
            bar1.ChartStyleGridLines.Xmin = 0;
            bar1.ChartStyleGridLines.Xmax = 5;
            bar1.ChartStyleGridLines.Ymin = 0;
            bar1.ChartStyleGridLines.Ymax = 11;
            bar1.ChartStyleGridLines.XTick = 1;
            bar1.ChartStyleGridLines.YTick = 2;
            bar1.ChartStyleGridLines.LinePattern = LinePattern.Dot;
            bar1.ChartStyleGridLines.LineColor = Brushes.Black;

            DataSeriesBar ds = new DataSeriesBar
            {
                BorderColor = Brushes.Red,
                FillColor = Brushes.Green,
                BarWidth = 0.6
            };
            for (int i = 0; i < 5; i++)
            {
                double x = i + 1.0;
                double y = x*2.0;
                ds.LineSeries.Points.Add(new Point(x, y));
            }
            bar1.DataCollectionBar = new VerticalBar();
            bar1.DataCollectionBar.DataList.Add(ds);
            bar1.DataCollectionBar.AddBars(bar1.ChartStyleGridLines);
        }