Exemplo n.º 1
0
        public Chart CreateChart(ChartInformation ci)
        {
            Chart m_chart = new Chart();
            m_chart.BorderThickness = ci.m_BorderThickness;
            m_chart.Theme = ci.m_Theme;
            m_chart.View3D = ci.m_View3D;

            Axis m_axisX = new Axis();
            m_axisX.Title = ci.m_axisXTitle;
            m_chart.AxesX.Add(m_axisX);

            Axis m_asixY = new Axis();
            m_asixY.Title = ci.m_axisYTitle;
            m_asixY.Enabled = true;
            m_asixY.StartFromZero = true;
            m_asixY.AxisType = AxisTypes.Primary;
            m_asixY.AxisMaximum = ci.m_axisYMaximum;
            m_asixY.Interval = ci.m_axisYInterval;
            m_chart.AxesY.Add(m_asixY);
            for(int i = 0;i<ci.dsc.Count;i++)
            {
                DataSeries ds = new DataSeries();
                ds.LegendText = ci.dsc[i].LegendText;
                ds.RenderAs = ci.dsc[i].RenderAs;
                ds.AxisYType = ci.dsc[i].AxisYType;
                ds.DataPoints = new DataPointCollection(ci.dsc[i].DataPoints);
                m_chart.Series.Add(ds);
            }
            m_chart.Rendered+=new EventHandler(chart_Rendered);
            return m_chart;
        }
        protected void loadGraph()
        {
            CreateChart.ChartInformation ci1 = new ChartInformation()
            {
                m_BorderThickness = new Thickness(1.0),
                m_Theme = "Theme1",
                m_View3D = true,
                m_axisXTitle = "杰出校友",
                m_axisYTitle = "",
                m_axisYMaximum = 100,
                m_axisYInterval = 20,
                dsc = new DataSeriesCollection()
                    {
                        new DataSeries()
                        {
                            LegendText = "",
                            RenderAs = RenderAs.Column,
                            AxisYType = AxisTypes.Primary,
                            DataPoints = new DataPointCollection()
                            {
                                new DataPoint()
                                {
                                    AxisXLabel = "2001年",
                                    YValue = 15,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2002年",
                                    YValue = 26,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2003年",
                                    YValue = 27,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2004年",
                                    YValue = 28,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2005年",
                                    YValue = 39,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2006年",
                                    YValue = 30,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2007年",
                                    YValue = 41,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2008年",
                                    YValue = 32,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2009年",
                                    YValue = 53,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2010年",
                                    YValue = 34,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2011年",
                                    YValue = 65,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2012年",
                                    YValue = 36,
                                },
                            }
                        },
                    },
            };
            CreateChart.ChartInformation ci2 = new ChartInformation()
            {
                m_BorderThickness = new Thickness(1.0),
                m_Theme = "Theme1",
                m_View3D = true,
                m_axisXTitle = "社会捐赠",
                m_axisYTitle = "",
                m_axisYMaximum = 100,
                m_axisYInterval = 20,
                dsc = new DataSeriesCollection()
                    {
                        new DataSeries()
                        {
                            LegendText = "",
                            RenderAs = RenderAs.Line,
                            AxisYType = AxisTypes.Primary,
                            DataPoints = new DataPointCollection()
                            {
                                new DataPoint()
                                {
                                    AxisXLabel = "2001年",
                                    YValue = 25,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2002年",
                                    YValue = 26,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2003年",
                                    YValue = 37,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2004年",
                                    YValue = 28,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2005年",
                                    YValue = 49,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2006年",
                                    YValue = 30,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2007年",
                                    YValue = 51,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2008年",
                                    YValue = 32,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2009年",
                                    YValue = 63,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2010年",
                                    YValue = 34,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2011年",
                                    YValue = 75,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2012年",
                                    YValue = 36,
                                },
                            }
                        },
                    },
            };
            CreateChart.ChartInformation ci3 = new ChartInformation()
            {
                m_BorderThickness = new Thickness(1.0),
                m_Theme = "Theme1",
                m_View3D = true,
                m_axisXTitle = "学科水平",
                m_axisYTitle = "",
                m_axisYMaximum = 100,
                m_axisYInterval = 20,
                dsc = new DataSeriesCollection()
                    {
                        new DataSeries()
                        {
                            LegendText = "",
                            RenderAs = RenderAs.Area,
                            AxisYType = AxisTypes.Primary,
                            DataPoints = new DataPointCollection()
                            {
                                new DataPoint()
                                {
                                    AxisXLabel = "2001年",
                                    YValue = 25,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2002年",
                                    YValue = 26,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2003年",
                                    YValue = 27,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2004年",
                                    YValue = 28,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2005年",
                                    YValue = 29,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2006年",
                                    YValue = 30,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2007年",
                                    YValue = 31,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2008年",
                                    YValue = 32,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2009年",
                                    YValue = 33,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2010年",
                                    YValue = 34,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2011年",
                                    YValue = 35,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2012年",
                                    YValue = 36,
                                },
                            }
                        },
                    },
            };

            ChartHelper ch = new ChartHelper();
            Chart m_chart1 = ch.CreateChart(ci1);
            gridGraphJieChuXiaoYou.Children.Clear();
            gridGraphJieChuXiaoYou.Children.Add(m_chart1);

            Chart m_chart2 = ch.CreateChart(ci2);
            gridGraphSheHuiJuanZeng.Children.Clear();
            gridGraphSheHuiJuanZeng.Children.Add(m_chart2);

            //Chart m_chart3 = ch.CreateChart(ci3);
            //gridAcademic.Children.Clear();
            //gridAcademic.Children.Add(m_chart3);
        }
        protected void loadGraph()
        {
            CreateChart.ChartInformation ci1 = new ChartInformation()
            {
                m_BorderThickness = new Thickness(1.0),
                m_Theme = "Theme1",
                m_View3D = true,
                m_axisXTitle = "科研成果",
                m_axisYTitle = "",
                m_axisYMaximum = 100,
                m_axisYInterval = 20,
                dsc = new DataSeriesCollection()
                    {
                        new DataSeries()
                        {
                            LegendText = "",
                            RenderAs = RenderAs.Column,
                            AxisYType = AxisTypes.Primary,
                            DataPoints = new DataPointCollection()
                            {
                                new DataPoint()
                                {
                                    AxisXLabel = "2001年",
                                    YValue = 25,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2002年",
                                    YValue = 36,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2003年",
                                    YValue = 27,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2004年",
                                    YValue = 48,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2005年",
                                    YValue = 29,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2006年",
                                    YValue = 50,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2007年",
                                    YValue = 31,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2008年",
                                    YValue = 62,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2009年",
                                    YValue = 33,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2010年",
                                    YValue = 74,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2011年",
                                    YValue = 35,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2012年",
                                    YValue = 86,
                                },
                            }
                        },
                    },
            };
            CreateChart.ChartInformation ci2 = new ChartInformation()
            {
                m_BorderThickness = new Thickness(1.0),
                m_Theme = "Theme1",
                m_View3D = true,
                m_axisXTitle = "科研基地",
                m_axisYTitle = "",
                m_axisYMaximum = 100,
                m_axisYInterval = 20,
                dsc = new DataSeriesCollection()
                    {
                        new DataSeries()
                        {
                            LegendText = "",
                            RenderAs = RenderAs.Line,
                            AxisYType = AxisTypes.Primary,
                            DataPoints = new DataPointCollection()
                            {
                                new DataPoint()
                                {
                                    AxisXLabel = "2001年",
                                    YValue = 25,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2002年",
                                    YValue = 16,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2003年",
                                    YValue = 27,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2004年",
                                    YValue = 48,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2005年",
                                    YValue = 29,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2006年",
                                    YValue = 80,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2007年",
                                    YValue = 31,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2008年",
                                    YValue = 82,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2009年",
                                    YValue = 33,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2010年",
                                    YValue = 94,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2011年",
                                    YValue = 35,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2012年",
                                    YValue = 96,
                                },
                            }
                        },
                    },
            };
            CreateChart.ChartInformation ci3 = new ChartInformation()
            {
                m_BorderThickness = new Thickness(1.0),
                m_Theme = "Theme1",
                m_View3D = true,
                m_axisXTitle = "科研项目",
                m_axisYTitle = "",
                m_axisYMaximum = 100,
                m_axisYInterval = 20,
                dsc = new DataSeriesCollection()
                    {
                        new DataSeries()
                        {
                            LegendText = "",
                            RenderAs = RenderAs.Area,
                            AxisYType = AxisTypes.Primary,
                            DataPoints = new DataPointCollection()
                            {
                                new DataPoint()
                                {
                                    AxisXLabel = "2001年",
                                    YValue = 25,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2002年",
                                    YValue = 26,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2003年",
                                    YValue = 20,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2004年",
                                    YValue = 48,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2005年",
                                    YValue = 29,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2006年",
                                    YValue = 90,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2007年",
                                    YValue = 31,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2008年",
                                    YValue = 32,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2009年",
                                    YValue = 53,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2010年",
                                    YValue = 34,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2011年",
                                    YValue = 35,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2012年",
                                    YValue = 76,
                                },
                            }
                        },
                    },
            };

            ChartHelper ch = new ChartHelper();
            Chart m_chart1 = ch.CreateChart(ci1);
            gridAchievement.Children.Clear();
            gridAchievement.Children.Add(m_chart1);

            Chart m_chart2 = ch.CreateChart(ci2);
            gridBase.Children.Clear();
            gridBase.Children.Add(m_chart2);

            Chart m_chart3 = ch.CreateChart(ci3);
            gridProject.Children.Clear();
            gridProject.Children.Add(m_chart3);
        }
        protected void Page_Loaded(object sender, RoutedEventArgs e)
        {
            string strPATH;
            DirectoryInfo di;
            di = new DirectoryInfo(System.Environment.CurrentDirectory);
            strPATH = di.Parent.Parent.FullName;
            ds = new EmergencyBasic();
            W_xiaohao.Navigate(new Uri(strPATH + @"/html/GreenDetect1.htm", UriKind.RelativeOrAbsolute));
            W_xiaohao.ObjectForScripting = ds;
            W_huanjing.Navigate(new Uri(strPATH + @"/html/GreenDetect.htm", UriKind.RelativeOrAbsolute));
            W_huanjing.ObjectForScripting = ds;

            CreateChart.ChartInformation ci1 = new ChartInformation()
            {
                m_BorderThickness = new Thickness(1.0),
                m_Theme = "Theme1",
                m_View3D = true,
                m_axisXTitle = "水耗",
                m_axisYTitle = "",
                m_axisYMaximum = 100,
                m_axisYInterval = 20,
                dsc = new DataSeriesCollection()
                    {
                        new DataSeries()
                        {
                            LegendText = "",
                            RenderAs = RenderAs.Column,
                            AxisYType = AxisTypes.Primary,
                            DataPoints = new DataPointCollection()
                            {
                                new DataPoint()
                                {
                                    AxisXLabel = "1月",
                                    YValue = 25,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2月",
                                    YValue = 18,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "3月",
                                    YValue = 35,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "4月",
                                    YValue = 25,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "5月",
                                    YValue = 25,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "6月",
                                    YValue = 18,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "7月",
                                    YValue = 35,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "8月",
                                    YValue = 25,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "9月",
                                    YValue = 25,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "10月",
                                    YValue = 18,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "11月",
                                    YValue = 35,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "12月",
                                    YValue = 25,
                                },
                            }
                        },
                    },
            };
            CreateChart.ChartInformation ci2 = new ChartInformation()
            {
                m_BorderThickness = new Thickness(1.0),
                m_Theme = "Theme1",
                m_View3D = true,
                m_axisXTitle = "能耗",
                m_axisYTitle = "",
                m_axisYMaximum = 100,
                m_axisYInterval = 20,
                dsc = new DataSeriesCollection()
                    {
                        new DataSeries()
                        {
                            LegendText = "",
                            RenderAs = RenderAs.Line,
                            AxisYType = AxisTypes.Primary,
                            DataPoints = new DataPointCollection()
                            {
                                new DataPoint()
                                {
                                    AxisXLabel = "1月",
                                    YValue = 25,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "2月",
                                    YValue = 18,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "3月",
                                    YValue = 35,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "4月",
                                    YValue = 25,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "5月",
                                    YValue = 25,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "6月",
                                    YValue = 18,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "7月",
                                    YValue = 35,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "8月",
                                    YValue = 25,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "9月",
                                    YValue = 25,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "10月",
                                    YValue = 18,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "11月",
                                    YValue = 35,
                                },
                                new DataPoint()
                                {
                                    AxisXLabel = "12月",
                                    YValue = 25,
                                },
                            }
                        },
                    },
            };

            ChartHelper ch = new ChartHelper();
            Chart m_chart1 = ch.CreateChart(ci1);
            gridGraph1.Children.Clear();
            gridGraph1.Children.Add(m_chart1);

            Chart m_chart2 = ch.CreateChart(ci2);
            gridGraph2.Children.Clear();
            gridGraph2.Children.Add(m_chart2);
        }