コード例 #1
0
 public static ChartControl CreatXYChart(SolidColorBrush forecolor, string ChartTitle, List<ChartDataChartCommonData> dtchart)
 {
     mausac = 0;
     ChartControl abc = new ChartControl();
     XYDiagram2D dg1 = new XYDiagram2D();
     //Tao Tile cho Chart
     Title nt = new Title();
     nt.Content = ChartTitle;
     nt.Foreground = forecolor;
     abc.Titles.Add(nt);
     //Tinh so Series
     List<string> countsr = (from p in dtchart group p by p.Series into g select g.Key).ToList();
     //Creat Diagram
     abc.Diagram = dg1;
     //Begin tao guong
     Pane pane1 = new Pane();
     pane1.MirrorHeight = 100;//Do cao guong
     dg1.DefaultPane = pane1;
     //End tao guong
     //Begin set kieu bieu do
     for (int i = 0; i < countsr.Count; i++)
     {
         BarSideBySideSeries2D dgs1 = new BarSideBySideSeries2D() { DisplayName = countsr[i].ToString() };//Neu ko co DisplayName chu thich khong hien thi
         Quasi3DBar2DModel an1 = new Quasi3DBar2DModel();
         dgs1.Model = an1;
         foreach (ChartDataChartCommonData dr in dtchart)//Tao cac point
         {
             if (dr.Series == countsr.ElementAt(i))
             {
                 //Tao Series
                 SeriesPoint sr1 = new SeriesPoint();
                 sr1.Argument = dr.Agrument;
                 sr1.Value = dr.Value;
                 sr1.Tag = mausac.ToString();
                 dgs1.Points.Add(sr1);
                 mausac++;
             }
         }
         SeriesLabel lbl1 = new SeriesLabel();
         dgs1.LabelsVisibility = true;//Hien thi Lablel cho tung vung
         lbl1.Indent = 10;
         lbl1.ConnectorThickness = 1;
         lbl1.ResolveOverlappingMode = ResolveOverlappingMode.Default;
         dgs1.Label = lbl1;
         dg1.Series.Add(dgs1);
     }
     //Tao chu thich
     abc.Legend = new Legend()
     {
         VerticalPosition = VerticalPosition.BottomOutside,
         HorizontalPosition = HorizontalPosition.Center,
         Orientation = Orientation.Horizontal
     };
     //End tao chu thich
     return abc;
 }
コード例 #2
0
        public static ChartControl CreatXYChart(SolidColorBrush forecolor, string ChartTitle, List <ChartDataChartCommonData> dtchart)
        {
            mausac = 0;
            ChartControl abc = new ChartControl();
            XYDiagram2D  dg1 = new XYDiagram2D();
            //Tao Tile cho Chart
            Title nt = new Title();

            nt.Content    = ChartTitle;
            nt.Foreground = forecolor;
            abc.Titles.Add(nt);
            //Tinh so Series
            List <string> countsr = (from p in dtchart group p by p.Series into g select g.Key).ToList();

            //Creat Diagram
            abc.Diagram = dg1;
            //Begin tao guong
            Pane pane1 = new Pane();

            pane1.MirrorHeight = 100;//Do cao guong
            dg1.DefaultPane    = pane1;
            //End tao guong
            //Begin set kieu bieu do
            for (int i = 0; i < countsr.Count; i++)
            {
                BarSideBySideSeries2D dgs1 = new BarSideBySideSeries2D()
                {
                    DisplayName = countsr[i].ToString()
                };                                                                                               //Neu ko co DisplayName chu thich khong hien thi
                Quasi3DBar2DModel an1 = new Quasi3DBar2DModel();
                dgs1.Model = an1;
                foreach (ChartDataChartCommonData dr in dtchart)//Tao cac point
                {
                    if (dr.Series == countsr.ElementAt(i))
                    {
                        //Tao Series
                        SeriesPoint sr1 = new SeriesPoint();
                        sr1.Argument = dr.Agrument;
                        sr1.Value    = dr.Value;
                        sr1.Tag      = mausac.ToString();
                        dgs1.Points.Add(sr1);
                        mausac++;
                    }
                }
                SeriesLabel lbl1 = new SeriesLabel();
                dgs1.LabelsVisibility       = true;//Hien thi Lablel cho tung vung
                lbl1.Indent                 = 10;
                lbl1.ConnectorThickness     = 1;
                lbl1.ResolveOverlappingMode = ResolveOverlappingMode.Default;
                dgs1.Label = lbl1;
                dg1.Series.Add(dgs1);
            }
            //Tao chu thich
            abc.Legend = new Legend()
            {
                VerticalPosition   = VerticalPosition.BottomOutside,
                HorizontalPosition = HorizontalPosition.Center,
                Orientation        = Orientation.Horizontal
            };
            //End tao chu thich
            return(abc);
        }