private void OnRenderGraph(ZedGraphWeb webObject, Graphics g, MasterPane pane)
        {
            DataSet   ds     = (DataSet)Cache["CurseCache"];
            GraphPane myPane = pane[0];

            myPane.Title.Text       = "Nr total de statii in functie de statia de pornire";
            myPane.XAxis.Title.Text = "Statie pornire";
            myPane.YAxis.Title.Text = "Nr. statii";
            Color[] colors =
            {
                Color.Red,    Color.Yellow, Color.Green, Color.Blue,
                Color.Purple, Color.Pink,   Color.Plum,  Color.Silver, Color.Salmon
            };
            if (ds != null)
            {
                List <string> listaX = new List <string>();
                PointPairList list   = new PointPairList();
                int           i      = 0;
                foreach (DataRow r in ds.Tables[0].Rows)
                {
                    listaX.Add(r[2].ToString()); //rezultat

                    list.Add(0, (int)r[3], i++); // k
                }
                i = 0;

                foreach (DataRow r in ds.Tables[0].Rows)
                {
                    PieItem segment1 = myPane.AddPieSlice((
                                                              int)r[3], colors[(i++) % colors.Length],
                                                          Color.White, 45f, (i % 2 == 0) ? 0.2 : 0,
                                                          r[2].ToString());
                }
            }
        }
Exemplo n.º 2
0
        protected void ZedGraphWeb1_RenderGraph(ZedGraphWeb webObject,
                                                Graphics g, MasterPane pane)
        {
                                                                                     //GraphPane class came from the ZedGraph DLL
                        GraphPane myPane        = pane[0];                           //create an empty Graph Pane object
                        myPane.Title.Text       = "Approximate Site Traffic (2017)"; //Title text property of pane object
                        myPane.XAxis.Title.Text = "Month";                           //Title X axis label text property
                        myPane.YAxis.Title.Text = "Visits (thousands)";              //Title Y axis label text property
                                                                                     //PointPairList class came from the ZedGraph DLL
                        PointPairList list1 = new PointPairList();                   //New Point Pair List object
                                                                                     //Create some plotting line to display
                        for (int i = 0; i < 18; i++)
            {
                double x = Convert.ToDouble(i);
                double y = .75 * x * x * x;
                list1.Add(x, y);
            }
                        //Use a LineItem type chart came from the ZedGraph DLL
                        string textForLegend = "Site Visits";

            myPane.CurveList.Clear();
            LineItem myCurve = myPane.AddCurve(textForLegend,
                                               list1, Color.Red, SymbolType.Diamond);

            myCurve.Symbol.IsVisible = true;
        }
Exemplo n.º 3
0
        private void OnRenderGraph(ZedGraphWeb webObject, Graphics g, MasterPane pane)
        {
            DataSet   ds     = (DataSet)Cache["CurseCache"];
            GraphPane myPane = pane[0];

            myPane.Title.Text       = "Nr total de statii in functie de statia de pornire";
            myPane.XAxis.Title.Text = "Statie pornire";
            myPane.YAxis.Title.Text = "Nr. statii";
            Color[] colors =
            {
                Color.Red,    Color.Yellow, Color.Green, Color.Blue,
                Color.Purple, Color.Pink,   Color.Plum,  Color.Silver, Color.Salmon
            };
            if (ds != null)
            {
                List <string> listaX = new List <string>();
                PointPairList list   = new PointPairList();
                int           i      = 0;
                foreach (DataRow r in ds.Tables[0].Rows)
                {
                    listaX.Add(r[2].ToString()); //rezultat

                    list.Add(0, (int)r[3], i++); // k
                }


                BarItem myCurve = myPane.AddBar("Curve 2", list, Color.Blue);
                myCurve.Bar.Fill              = new Fill(colors);
                myCurve.Bar.Fill.Type         = FillType.GradientByZ;
                myCurve.Bar.Fill.RangeMin     = 0;
                myCurve.Bar.Fill.RangeMax     = list.Count;
                myPane.XAxis.Type             = AxisType.Text;
                myPane.XAxis.Scale.TextLabels = listaX.ToArray();
            }
        }
Exemplo n.º 4
0
 private void OnRenderGraph(ZedGraphWeb zgw, Graphics g, MasterPane masterPane)
 {
     ErrorMsg.Text = "";
     CY.GFive.DALProviders.SqlServerProvider.ScoreProvider sp = new CY.GFive.DALProviders.SqlServerProvider.ScoreProvider();
     string coursecode = Request.Form.Get("ddlCourse");
     string term = Request.Form.Get("ddlTerm");
     if (coursecode == null || coursecode == "请选择" || term == null || term == "请选择")
     {
         ErrorMsg.Text = "有参数不正确";
         ZedGraphWeb1.Visible = false;
         return;
     }
     if (string.IsNullOrEmpty(ddlYearNum.SelectedValue) || ddlYearNum.SelectedValue == "请选择")
     {
         ErrorMsg.Text = "有参数不正确";
         ZedGraphWeb1.Visible = false;
         return;
     }
     string year = ddlYearNum.SelectedItem.ToString();//year term course class teacher
     GraphPane myPane = masterPane[0];
     myPane.Title.Text = "同课程分数段统计";       //设计图表的标题
     myPane.XAxis.Title.Text = "分数段";    //X轴标题
     myPane.YAxis.Title.Text = "人数";          //Y轴标题
     string[] labels = new string[6];
     labels[0] = "60以下";
     labels[1] = "60-69";
     labels[2] = "70-79";
     labels[3] = "80-89";
     labels[4] = "90-99";
     labels[5] = "100";
     List<string> dic = sp.PrapareTeacherAndClassByCourse(year, Convert.ToInt32(term), coursecode);
     foreach (string s in dic)
     {
         string[] value = s.Split(','); //teachercode,classcode
         Random rand = new Random();
         int r = rand.Next(8);
         int gg = rand.Next(10);
         int b = rand.Next(5);
         Color temp = Color.FromArgb(r * 30, gg * 25, b * 50);
         DataSet ds = sp.GetScoreUnionByParam(year, Convert.ToInt32(term), value[1], coursecode);
         PointPairList list = new PointPairList();
         for (int i = 0; i < 6; i++)
             list.Add(0, Convert.ToInt32(ds.Tables[0].Rows[i]["人数"]));
         CY.GFive.Core.Business.StaffInfo si = CY.GFive.Core.Business.StaffInfo.GetInstance(value[0]);
         CY.GFive.Core.Business.ClassInfo ci = CY.GFive.Core.Business.ClassInfo.GetByCode(value[1]);
         BarItem myCurve = myPane.AddBar(si.Name + "-" + ci.ClassName, list, temp);
         myCurve.Bar.Fill = new Fill(temp, Color.White, temp);
     }
     myPane.XAxis.MajorTic.IsBetweenLabels = false; //柱状显示位置,true为在两个下标题值的中间,flase为两边
     myPane.XAxis.Scale.TextLabels = labels;//下标题的内容
     myPane.XAxis.Type = AxisType.Text;
     myPane.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 90.0f);//图表外层背景填充色,由color1到color2渐变,参数3为方向
     myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 270.0f);//图表内层背景填充色,由color1到color2渐变,参数3为方向
     ZedGraphWeb1.Visible = true;
     masterPane.AxisChange(g);
 }
Exemplo n.º 5
0
    /// <summary>
    /// This method is where you generate your graph.
    /// </summary>
    /// <param name="masterPane">You are provided with a MasterPane instance that
    /// contains one GraphPane by default (accessible via masterPane[0]).</param>
    /// <param name="g">A graphics instance so you can easily make the call to AxisChange()</param>
    /// <param name="z">And a ZedGraphWeb instance because the event handler requires it</param>
    /// <param name="row">Selected row n gridview.</param>
    private static void OnRenderGraphVillagePie(ZedGraphWeb z,
        Graphics g,
        MasterPane masterPane,
        TableRow row)
    {
        // Get the GraphPane so we can work with it
        GraphPane myPane = masterPane[0];

        // Fill the pane background with a color gradient
        myPane.Fill = new Fill(Color.White, Color.White, 45.0f);
        // No fill for the chart background
        myPane.Chart.Fill.Type = FillType.None;

        myPane.Legend.IsVisible = false;
        myPane.Legend.IsShowLegendSymbols = true;
        myPane.Legend.IsHStack = false;

        // Add some pie slices
        const string srcTable = "Goods";
        DataBase dataBase = new DataBase();
        DataSet dataSet = dataBase.GetGoods(srcTable, Misc.String2Number(row.Cells[0].Text.Trim()));
        DataRow dataRow = dataSet.Tables[srcTable].Rows[0];
        int wood = Misc.String2Number(dataRow.ItemArray[0].ToString());
        int clay = Misc.String2Number(dataRow.ItemArray[1].ToString());
        int iron = Misc.String2Number(dataRow.ItemArray[2].ToString());
        int crop = Misc.String2Number(dataRow.ItemArray[3].ToString());

        PieItem segmentWood = myPane.AddPieSlice(wood, Color.Green, Color.Green, 45f, 0, wood.ToString());
        PieItem segmentClay = myPane.AddPieSlice(clay, Color.OrangeRed, Color.OrangeRed, 45f, .0, clay.ToString());
        PieItem segmentIron = myPane.AddPieSlice(iron, Color.Blue, Color.Blue, 45f, 0, iron.ToString());
        PieItem segmentCrop = myPane.AddPieSlice(crop, Color.Yellow, Color.Yellow, 45f, 0.2, crop.ToString());

        segmentWood.LabelDetail.FontSpec.Size = 20f;
        segmentClay.LabelDetail.FontSpec.Size = 20f;
        segmentIron.LabelDetail.FontSpec.Size = 20f;
        segmentCrop.LabelDetail.FontSpec.Size = 20f;

        // Sum up the pie values
        CurveList curves = myPane.CurveList;
        double total = 0;
        for (int x = 0; x < curves.Count; x++)
        {
            total += ((PieItem) curves[x]).Value;
        }

        // Set the GraphPane title
        //myPane.Title.Text = String.Format("Total Goods : {0}\nWood : {1}\nClay : {2}\nIron : {3}\nCrop : {4}", total,
        //                                  wood, clay, iron, crop);
        myPane.Title.Text = String.Format("Total Goods : {0}", total);
        myPane.Title.FontSpec.IsItalic = true;
        myPane.Title.FontSpec.Size = 24f;
        myPane.Title.FontSpec.Family = "Times New Roman";

        masterPane.AxisChange(g);
    }
Exemplo n.º 6
0
        /// <summary>
        /// This method is where you generate your graph.
        /// </summary>
        /// <param name="masterPane">You are provided with a MasterPane instance that
        /// contains one GraphPane by default (accessible via masterPane[0]).</param>
        /// <param name="g">A graphics instance so you can easily make the call to AxisChange()</param>
        private void OnRenderGraph1(ZedGraphWeb zgw, Graphics g, MasterPane masterPane)
        {
            // Get the GraphPane so we can work with it
            GraphPane myPane = masterPane[0];

            // Set the title and axis labels
            myPane.Title.Text       = "Cat Stats";
            myPane.YAxis.Title.Text = "Big Cats";
            myPane.XAxis.Title.Text = "Population";

            // Make up some data points
            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard" };
            double[] x      = { 100, 115, 75, 22, 98, 40 };
            double[] x2     = { 120, 175, 95, 57, 113, 110 };
            double[] x3     = { 204, 192, 119, 80, 134, 156 };

            // Generate a red bar with "Curve 1" in the legend
            BarItem myCurve = myPane.AddBar("Here", x, null, Color.Red);

            // Fill the bar with a red-white-red color gradient for a 3d look
            myCurve.Bar.Fill = new Fill(Color.Red, Color.White, Color.Red, 90f);

            // Generate a blue bar with "Curve 2" in the legend
            myCurve = myPane.AddBar("There", x2, null, Color.Blue);
            // Fill the bar with a Blue-white-Blue color gradient for a 3d look
            myCurve.Bar.Fill = new Fill(Color.Blue, Color.White, Color.Blue, 90f);

            // Generate a green bar with "Curve 3" in the legend
            myCurve = myPane.AddBar("Elsewhere", x3, null, Color.Green);
            // Fill the bar with a Green-white-Green color gradient for a 3d look
            myCurve.Bar.Fill = new Fill(Color.Green, Color.White, Color.Green, 90f);

            // Draw the Y tics between the labels instead of at the labels
            myPane.YAxis.MajorTic.IsBetweenLabels = true;

            // Set the YAxis labels
            myPane.YAxis.Scale.TextLabels = labels;
            // Set the YAxis to Text type
            myPane.YAxis.Type = AxisType.Text;

            // Set the bar type to stack, which stacks the bars by automatically accumulating the values
            myPane.BarSettings.Type = BarType.Stack;

            // Make the bars horizontal by setting the BarBase to "Y"
            myPane.BarSettings.Base = BarBase.Y;

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill(Color.White,
                                         Color.FromArgb(255, 255, 166), 45.0F);

            masterPane.AxisChange(g);
        }
Exemplo n.º 7
0
        private void OnRenderGraph(ZedGraphWeb zgw, Graphics g, MasterPane masterPane)
        {
            ErrorMsg.Text = "";
            CY.GFive.DALProviders.SqlServerProvider.ScoreProvider sp = new CY.GFive.DALProviders.SqlServerProvider.ScoreProvider();
            if (string.IsNullOrEmpty(Request.Form.Get("Term")) || string.IsNullOrEmpty(Request.Form.Get("Course")))
            {
                ErrorMsg.Text = "参数错误";
                ZedGraphWeb1.Visible = false;
                return;
            }
            int term = Convert.ToInt32(Request.Form.Get("Term"));
            string course = Request.Form.Get("Course");
            string year = ddlYearNum.SelectedItem.ToString();
            string teacher = ddlTeacher.SelectedValue;
            List<string> classlist = sp.GetClassList(year, term, teacher, course);
            if (classlist.Count < 1)
                return;
            GraphPane myPane = masterPane[0];

            myPane.Title.Text = "分数段统计";       //设计图表的标题
            myPane.XAxis.Title.Text = "分数段";    //X轴标题
            myPane.YAxis.Title.Text = "人数";          //Y轴标题
            string[] labels = new string[6];
            labels[0] = "60以下";
            labels[1] = "60-69";
            labels[2] = "70-79";
            labels[3] = "80-89";
            labels[4] = "90-99";
            labels[5] = "100";

            foreach (string classcode in classlist)
            {
                Random rand = new Random();
                int n = rand.Next(4);
                Color temp = Color.FromArgb(n * 10, n * 60, n * 50);
                DataSet ds = sp.GetScoreUnionByParam(year, term, classcode, course);
                CY.GFive.Core.Business.ClassInfo citemp = CY.GFive.Core.Business.ClassInfo.GetByCode(classcode);
                PointPairList list = new PointPairList();
                for (int i = 0; i < 6; i++)
                    list.Add(0, Convert.ToInt32(ds.Tables[0].Rows[i]["人数"]));
                BarItem myCurve = myPane.AddBar(citemp.ClassName, list, temp);
                myCurve.Bar.Fill = new Fill(temp, Color.White, temp);
            }

            myPane.XAxis.MajorTic.IsBetweenLabels = false; //柱状显示位置,true为在两个下标题值的中间,flase为两边
            myPane.XAxis.Scale.TextLabels = labels;//下标题的内容
            myPane.XAxis.Type = AxisType.Text;
            myPane.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 90.0f);//图表外层背景填充色,由color1到color2渐变,参数3为方向
            myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 270.0f);//图表内层背景填充色,由color1到color2渐变,参数3为方向
            ZedGraphWeb1.Visible = true;
            masterPane.AxisChange(g);
        }
 private void OnRenderGraph1(ZedGraphWeb zgw, Graphics g, MasterPane masterPane)
 {
     try
     {
         GraphPane myPane = masterPane[0];
         BindDataForChart(myPane);
         SetDisplayForChart(myPane);
         masterPane.AxisChange(g);
     }
     catch
     {
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Here is a completely independent second graph.  In InitializeComponent() above,
        /// ZedGraphWeb1 calls OnRenderGraph1, and ZedGraphWeb2 calls OnRenderGraph2.
        /// </summary>
        private void OnRenderGraph2(ZedGraphWeb zgw, Graphics g, MasterPane masterPane)
        {
            // Get the GraphPane so we can work with it
            GraphPane myPane = masterPane[0];

            // Set the titles and axis labels
            myPane.Title.Text       = "My Test Date Graph";
            myPane.XAxis.Title.Text = "Date";
            myPane.YAxis.Title.Text = "My Y Axis";

            // Make up some data points from the Sine function
            PointPairList list  = new PointPairList();
            PointPairList list2 = new PointPairList();

            for (int i = 0; i < 36; i++)
            {
                double x  = new XDate(1995, i + 1, 1);
                double y  = Math.Sin((double)i * Math.PI / 15.0);
                double y2 = 2 * y;

                list.Add(x, y);
                list2.Add(x, y2);
            }

            // Generate a blue curve with circle symbols, and "My Curve 2" in the legend
            LineItem myCurve2 = myPane.AddCurve("My Curve 2", list, Color.Blue,
                                                SymbolType.Circle);

            // Fill the area under the curve with a white-red gradient at 45 degrees
            myCurve2.Line.Fill = new Fill(Color.White, Color.Red, 45F);
            // Make the symbols opaque by filling them with white
            myCurve2.Symbol.Fill = new Fill(Color.White);

            // Generate a red curve with diamond symbols, and "My Curve" in the legend
            LineItem myCurve = myPane.AddCurve("My Curve",
                                               list2, Color.MediumVioletRed, SymbolType.Diamond);

            // Fill the area under the curve with a white-green gradient
            myCurve.Line.Fill = new Fill(Color.White, Color.Green);
            // Make the symbols opaque by filling them with white
            myCurve.Symbol.Fill = new Fill(Color.White);

            // Set the XAxis to date type
            myPane.XAxis.Type      = AxisType.Date;
            myPane.XAxis.CrossAuto = true;

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F);

            masterPane.AxisChange(g);
        }
Exemplo n.º 10
0
        private void OnRenderzgwEducationalBackgroundPie(ZedGraphWeb zgw, Graphics g, MasterPane masterPane)
        {
            try
            {
                GraphPane myPane = masterPane[0];
                BindDataForChart(myPane);
                SetDisplayForChart(myPane);

                masterPane.AxisChange();
            }
            catch
            {
            }
        }
Exemplo n.º 11
0
    protected void PopulateSPAGauge(ZedGraphWeb z, Graphics g, MasterPane masterPane)
    {
        GraphPane myPane = masterPane[0];

        // Define the title
        myPane.Title.Text                 = (String)ViewState["territory"];
        myPane.Title.FontSpec.Size        = 34;
        myPane.Title.FontSpec.IsAntiAlias = false;
        myPane.Title.FontSpec.IsBold      = false;
        myPane.Title.FontSpec.FontColor   = Util.ColourTryParse("#989898");

        // Fill the pane and chart
        myPane.Fill                = new Fill(Util.ColourTryParse("#ff191919"), Util.ColourTryParse("#ff191919"), 45.0f);
        myPane.Chart.Fill          = new Fill(Util.ColourTryParse("#333333"), Util.ColourTryParse("#333333"), 45.0f); //Color.LightGray, Color.Black,
        myPane.Chart.Fill.RangeMax = 16;
        myPane.Chart.Fill.RangeMin = 0;

        // Don't show any axes for the gas gauge
        myPane.XAxis.IsVisible  = false;
        myPane.Y2Axis.IsVisible = false;
        myPane.YAxis.IsVisible  = false;

        //Define needles
        // Plot average RAG value by converting to percentage of 18 max then reverse value as chart plots backwards.
        float          plotVal = 100 - (((float)ViewState["avgRAG"] / (float)16) * 100);
        GasGaugeNeedle gg1     = new GasGaugeNeedle("Suspects", plotVal, Color.DimGray);

        gg1.NeedleWidth = 100;
        myPane.CurveList.Add(gg1);

        //Define all regions
        GasGaugeRegion ggr1 = new GasGaugeRegion("Green", 0.0f, 7.0f, Color.Green);
        GasGaugeRegion ggr2 = new GasGaugeRegion("Yellow", 7.0f, 63.0f, Color.Gold);
        GasGaugeRegion ggr3 = new GasGaugeRegion("Red", 63.0f, 100.0f, Color.Red);

        // Add the regions
        myPane.CurveList.Add(ggr1);
        myPane.CurveList.Add(ggr2);
        myPane.CurveList.Add(ggr3);
        myPane.Legend.IsVisible   = false;
        myPane.Chart.Border.Color = Color.DimGray;
        myPane.Margin.Left        = 34;
        myPane.Margin.Right       = 34;
        myPane.Margin.Bottom      = 30;
        myPane.Margin.Top         = 4;
        myPane.AxisChange();

        ViewState["myPane"] = myPane;
    }
Exemplo n.º 12
0
        private void OnRenderUserChart(ZedGraphWeb z, Graphics g, MasterPane masterPane)
        {
            if (module == null)
            {
                return;
            }
            if (moduleGuid == Guid.Empty)
            {
                return;
            }

            GraphPane graphPane = masterPane[0];

            graphPane.Title.Text       = Resource.SalesByMonthChartLabel;
            graphPane.XAxis.Title.Text = Resource.SalesByMonthChartMonthLabel;
            graphPane.YAxis.Title.Text = Resource.SalesByMonthChartSalesLabel;

            PointPairList pointList = new PointPairList();

            if (salesByMonthData == null)
            {
                salesByMonthData = CommerceReport.GetSalesByYearMonthByModule(moduleGuid);
            }

            foreach (DataRow row in salesByMonthData.Rows)
            {
                double x = new XDate(Convert.ToInt32(row["Y"]), Convert.ToInt32(row["M"]), 1);
                double y = Convert.ToDouble(row["Sales"]);
                pointList.Add(x, y);
            }

            LineItem myCurve2 = graphPane.AddCurve(Resource.SalesByMonthChartLabel, pointList, Color.Blue, SymbolType.Circle);

            // Fill the area under the curve with a white-red gradient at 45 degrees
            myCurve2.Line.Fill = new Fill(Color.White, Color.Green, 45F);
            // Make the symbols opaque by filling them with white
            myCurve2.Symbol.Fill = new Fill(Color.White);

            // Set the XAxis to date type
            graphPane.XAxis.Type      = AxisType.Date;
            graphPane.XAxis.CrossAuto = true;

            // Fill the axis background with a color gradient
            graphPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F);

            masterPane.AxisChange(g);
        }
Exemplo n.º 13
0
        /// <summary>
        /// This method is where you generate your graph.
        /// </summary>
        /// <param name="masterPane">You are provided with a MasterPane instance that
        /// contains one GraphPane by default (accessible via masterPane[0]).</param>
        /// <param name="g">A graphics instance so you can easily make the call to AxisChange()</param>
        private void OnRenderGraph(ZedGraphWeb zgw, Graphics g, MasterPane masterPane)
        {
            // Get the GraphPane so we can work with it
            GraphPane myPane = masterPane[0];

            myPane.Title.Text       = "Sales By Region";
            myPane.XAxis.Title.Text = "Region";
            myPane.YAxis.Title.Text = "Gross Sales, $Thousands";

            PointPairList list  = new PointPairList();
            PointPairList list2 = new PointPairList();
            PointPairList list3 = new PointPairList();
            Random        rand  = new Random();

            for (double x = 0; x < 5; x += 1.0)
            {
                double y  = rand.NextDouble() * 1000;
                double y2 = rand.NextDouble() * 1000;
                double y3 = rand.NextDouble() * 1000;
                list.Add(x, y);
                list2.Add(x, y2);
                list3.Add(x, y3);
            }

            BarItem myCurve = myPane.AddBar("Blue Team", list, Color.Blue);

            myCurve.Bar.Fill = new Fill(Color.Blue, Color.White, Color.Blue);
            BarItem myCurve2 = myPane.AddBar("Red Team", list2, Color.Red);

            myCurve2.Bar.Fill = new Fill(Color.Red, Color.White, Color.Red);
            BarItem myCurve3 = myPane.AddBar("Green Team", list3, Color.Green);

            myCurve3.Bar.Fill = new Fill(Color.Green, Color.White, Color.Green);

            myPane.XAxis.MajorTic.IsBetweenLabels = true;
            string[] labels = { "Africa", "Americas", "Asia", "Europe", "Australia" };
            myPane.XAxis.Scale.TextLabels = labels;
            myPane.XAxis.Type             = AxisType.Text;
            myPane.Fill       = new Fill(Color.White, Color.FromArgb(200, 200, 255), 45.0f);
            myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45.0f);

            masterPane.AxisChange(g);
        }
Exemplo n.º 14
0
    public void OnRenderGraph(ZedGraphWeb zgw, System.Drawing.Graphics g, ZedGraph.MasterPane masterPane)
    {
        GraphPane myPane = masterPane[0];

        myPane.Title.Text       = "Statistic for studet " + d.user.LastName + " for curriculum " + d.curriculum.Name;;
        myPane.XAxis.Title.Text = "Stage";
        myPane.YAxis.Title.Text = "Count";

        PointPairList list  = new PointPairList();
        PointPairList list2 = new PointPairList();


        for (int x = 0; x < d.Get_Name_Stage().Count; x++)
        {
            double y  = d.Get_Student_Stage_Count()[x];
            double y2 = d.Get_Total_Stage_Count()[x];

            list.Add(x, y);
            list2.Add(x, y2);
        }

        BarItem myCurve  = myPane.AddBar("Student Resoult", list, Color.Green);
        BarItem myCurve2 = myPane.AddBar("Stage Rank", list2, Color.Red);

        string[] label11 = new string[d.Get_Student_Stage_Count().Count];
        for (int x = 0; x < d.Get_Student_Stage_Count().Count; x++)
        {
            label11[x] = d.Get_Name_Stage()[x];
        }

        myPane.XAxis.MajorTic.IsBetweenLabels = true;

        myPane.XAxis.Scale.TextLabels = label11;
        myPane.XAxis.Type             = AxisType.Text;
        myPane.Fill       = new Fill(Color.White, Color.FromArgb(200, 200, 255), 45.0f);
        myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45.0f);

        masterPane.AxisChange(g);
    }
Exemplo n.º 15
0
        protected void zgwCtl_OnRenderGraph(ZedGraphWeb zgw, Graphics g, MasterPane masterPane)
        {
            if (g != null)
            {
                g.Clear(Color.White);
            }
            double[]  valuesY   = TranslateSpeedValues(this.speedValues);
            XDate[]   valuesX   = TranslateTimeValues(this.timeLabels);
            GraphPane graphPane = null;

            if (masterPane != null)
            {
                graphPane = masterPane[0];
            }
            else
            {
                graphPane = new GraphPane();
            }
            PointPairList listMean       = new PointPairList();
            PointPairList listMax        = new PointPairList();
            PointPairList listMin        = new PointPairList();
            PointPairList listSplineMax  = new PointPairList();
            PointPairList listSplineMin  = new PointPairList();
            PointPairList listSplineMean = new PointPairList();

            //Create PointPair lists to use later. (Either to plot them directly, or as below)
            for (int i = 0; i < valuesX.Length; i++)
            {
                listMean.Add(valuesX[i], valuesY[i]);
                listMax.Add(valuesX[i], maxSpeedValues[i]);
                listMin.Add(valuesX[i], minSpeedValues[i]);
            }
            listMax.Sort();
            listMin.Sort();
            listMean.Sort();

            //I´d whish the charts to be nice and "round", not edgy. Zed has a way of interpolating with Splines, making it easy
            //So lets create 150 new points to plot instead.
            int count = 150;

            for (int i = 0; i < count && valuesX.Length != 0; i++)
            {
                //interval size
                double x = listMax[0].X + (double)i * (listMax[valuesX.Length - 1].X - listMax[0].X) / count;

                // Zedgraph throws an exception here if we do not have enough data.
                try
                {
                    listSplineMax.Add(x, listMax.SplineInterpolateX(x, 0.2));
                    listSplineMin.Add(x, listMin.SplineInterpolateX(x, 0.2));
                    listSplineMean.Add(x, listMean.SplineInterpolateX(x, 0.5));
                }
                catch (Exception)
                {
                    break;
                    // ignore
                }
            }

            // because next added Curve place in back to from, we display first max & min lines
            if (minSpeedValues != null || minSpeedValues.Length != 0)
            {
                LineItem minLineCurve = graphPane.AddCurve("Minimum Wind", listSplineMin, Color.Red, SymbolType.None);
                minLineCurve.Line.Width = 1.6f;
                //minLineCurve.Line.Fill = new Fill(Color.FromArgb(0, 230, 0), Color.FromArgb(0, 94, 0), 90F);
                minLineCurve.Line.Fill = new Fill(Color.White);
            }

            LineItem myCurve = graphPane.AddCurve("Average Wind", listSplineMean, Color.FromArgb(43, 75, 157), SymbolType.None);

            // Fill the area under the curve with a white-red gradient at 90 degrees
            //myCurve.Line.Fill = new Fill(Color.FromArgb(118, 164, 251), Color.FromArgb(118, 164, 251), 90F);
            myCurve.Line.Fill        = new Fill(Color.FromArgb(152, 251, 152), Color.FromArgb(0, 255, 127), 90F);
            myCurve.Line.Width       = 1.6f;
            myCurve.Line.IsAntiAlias = true;
            // Make the symbols opaque by filling them with white
            myCurve.Symbol.Fill = new Fill(Color.DarkGray);

            graphPane.XAxis.Scale.FontSpec.FontColor = Color.Black;

            graphPane.XAxis.Type = AxisType.Date;
            if (valuesX.Length > 0)
            {
                graphPane.XAxis.Scale.Min = (double)valuesX[valuesX.Length - 1];
                graphPane.XAxis.Scale.Max = (double)valuesX[0];
            }
            graphPane.XAxis.MajorGrid.IsVisible = true;

            graphPane.YAxis.Scale.Min = 0;
            graphPane.YAxis.Scale.Max = 15;
            if (GetMaxValue(maxSpeedValues) > 15)
            {
                graphPane.YAxis.Scale.Max = GetMaxValue(maxSpeedValues) + 1;
            }
            graphPane.YAxis.IsAxisSegmentVisible = false;

            graphPane.Y2Axis.Scale.Align        = AlignP.Inside;
            graphPane.YAxis.Title.Text          = "m/s";
            graphPane.YAxis.Title.FontSpec.Size = 22;

            graphPane.YAxis.MajorTic.IsBetweenLabels = false;
            graphPane.YAxis.MajorTic.Color           = Color.DarkGray;
            graphPane.YAxis.MajorTic.IsInside        = false;
            graphPane.YAxis.MajorTic.IsOpposite      = false;
            graphPane.YAxis.MinorTic.Color           = Color.DarkGray;
            graphPane.YAxis.MinorTic.IsInside        = false;
            graphPane.YAxis.MinorTic.IsOpposite      = false;
            graphPane.YAxis.MinorTic.IsOutside       = false;
            graphPane.YAxis.MajorGrid.IsVisible      = true;
            graphPane.YAxis.MinorGrid.IsVisible      = false;
            graphPane.YAxis.Scale.Align = AlignP.Inside;
            graphPane.YAxis.Title.FontSpec.FontColor = Color.DarkGray;
            graphPane.YAxis.Color = Color.DarkGray;

            if (maxSpeedValues != null || maxSpeedValues.Length != 0)
            {
                LineItem maxLineCurve = graphPane.AddCurve("Maximum Wind", /*listMax*/ listSplineMax, Color.Red, SymbolType.None);
                maxLineCurve.Line.Width = 1.6f;
                maxLineCurve.Line.Fill  = new Fill(Color.FromArgb(152, 251, 152), Color.FromArgb(0, 255, 127), 90F);
            }

            // disable legend
            graphPane.Legend.IsVisible         = false;
            graphPane.Legend.FontSpec.Size     = 20;
            graphPane.Border.Color             = Color.White;
            graphPane.BarSettings.Type         = BarType.SortedOverlay;
            graphPane.Chart.Border.Color       = Color.DarkGray;
            graphPane.Title.FontSpec.FontColor = Color.DarkGray;
            // to disable scaling
            //graphPane.IsPenWidthScaled = false;
            //graphPane.IsFontsScaled = false;

            masterPane.AxisChange(g);

            // Draw wind direction arrows

            ImageObj[] dirImages  = new ImageObj[dirValues.Length];
            int        nbrOfPlots = Math.Min(20, dirImages.Length);

            float  step, xMin, xMax;
            double next, yMin, yMax;

            step = 0;
            xMin = xMax = 0;
            if (valuesX.Length != 0)
            {
                xMin = valuesX[valuesX.Length - 1];
                xMax = valuesX[0];
            }

            yMin = yMax = 0;
            if (valuesY.Length != 0)
            {
                yMin = 0;
                yMax = graphPane.YAxis.Scale.Max;
            }

            step = (xMax - xMin) / nbrOfPlots;
            next = 0;

            Image image = Image.FromFile(Server.MapPath("~/design/wind_arrow.png"));

            float[] rot;

            rot = getDirections(dirValues, (float)dirValues.Length / (float)nbrOfPlots, nbrOfPlots);

            if (rot != null)
            {
                if (dirImages.Length < nbrOfPlots)
                {
                    for (int i = 0; i < nbrOfPlots - dirImages.Length; i++)
                    {
                        next += step;
                    }
                }
                for (int i = 0; i < dirImages.Length && i < rot.Length && i < nbrOfPlots; i++)
                {
                    dirImages[i] = new ImageObj(rotateImage(image, rot[i]), xMin + next, (yMax / 10) * 9, step, yMax / 7);
                    graphPane.GraphObjList.Add(dirImages[i]);
                    next += step;
                }
            }

            // Write the date
            if (valuesX.Length > 0)
            {
                DateTime date = valuesX[0];
                graphPane.Title.Text = getInfoText(date);
            }
            graphPane.Title.FontSpec.Size       = 24;
            graphPane.Title.FontSpec.Fill.Color = Color.Black;

            // Get interval so we can name the picture
            String name = "graph_" + this.interval + ".png";


            try
            {
                String path = HttpContext.Current.Server.MapPath("/") + "Applet/" + location;
                if (!System.IO.Directory.Exists(path))
                {
                    System.IO.Directory.CreateDirectory(path);
                }

                masterPane.GetImage().Save(Server.MapPath("~/Applet/" + location + "/" + name), System.Drawing.Imaging.ImageFormat.Png);
            }
            catch (Exception)
            {
                Debug.WriteLine("Problem3");
                Debug.WriteLine("Exception raised. Location: " + location);
            }
        }
Exemplo n.º 16
0
        private void OnRenderUserChart(ZedGraphWeb z, Graphics g, MasterPane masterPane)
        {
            GraphPane graphPane = masterPane[0];
            graphPane.Title.Text = Resource.SalesByMonthChartLabel;
            graphPane.XAxis.Title.Text = Resource.SalesByMonthChartMonthLabel;
            graphPane.YAxis.Title.Text = Resource.SalesByMonthChartSalesLabel;

            PointPairList pointList = new PointPairList();

            if (salesByMonthData == null) { salesByMonthData = CommerceReport.GetSalesByYearMonthBySite(siteSettings.SiteGuid); }

            foreach (DataRow row in salesByMonthData.Rows)
            {
                double x = new XDate(Convert.ToInt32(row["Y"]), Convert.ToInt32(row["M"]), 1);
                double y = Convert.ToDouble(row["Sales"]);
                pointList.Add(x, y);
            }

            LineItem myCurve2 = graphPane.AddCurve(Resource.SalesByMonthChartLabel, pointList, Color.Blue, SymbolType.Circle);
            // Fill the area under the curve with a white-red gradient at 45 degrees
            myCurve2.Line.Fill = new Fill(Color.White, Color.Green, 45F);
            // Make the symbols opaque by filling them with white
            myCurve2.Symbol.Fill = new Fill(Color.White);

            // Set the XAxis to date type
            graphPane.XAxis.Type = AxisType.Date;
            graphPane.XAxis.CrossAuto = true;

            // Fill the axis background with a color gradient
            graphPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F);

            masterPane.AxisChange(g);
        }
Exemplo n.º 17
0
        private void OnRenderGraph(ZedGraphWeb zgw, Graphics g, MasterPane masterPane)
        {
            ErrorMsg.Text = "";
            CY.GFive.DALProviders.SqlServerProvider.ScoreProvider sp = new CY.GFive.DALProviders.SqlServerProvider.ScoreProvider();
            string classcode = Request.Form.Get("ddlClass");
            string[] year = Request.Form.GetValues("cyear");
            string[] term = Request.Form.GetValues("cterm");
            if (classcode == null || string.IsNullOrEmpty(classcode) || year == null || year.Length == 0 || term == null || term.Length == 0)
            {
                ErrorMsg.Text = "有参数不正确";
                ZedGraphWeb1.Visible = false;
                return;
            }
            List<YearTerm> ytlist = new List<YearTerm>();
            List<YearTermCourse> ytclist = new List<YearTermCourse>();
            for (int i = 0; i < year.Length; i++)
            {
                bool isIn = false;
                foreach (YearTerm yt in ytlist)
                {
                    if (yt.Year == year[i] && yt.Term == term[i])
                        isIn = true;
                }
                if (!isIn)
                    ytlist.Add(new YearTerm { Year = year[i], Term = term[i] });
            }
            foreach (YearTerm yt in ytlist)
            {
                List<string> courselist = sp.GetCourseList(yt.Year, Convert.ToInt32(yt.Term), classcode);
                if (courselist.Count > 0)
                    foreach (string s in courselist)
                    {
                        ytclist.Add(new YearTermCourse { Year = yt.Year, Term = yt.Term, Course = s });
                    }
            }
            GraphPane myPane = masterPane[0];

            myPane.Title.Text = "分数段统计";       //设计图表的标题
            myPane.XAxis.Title.Text = "分数段";    //X轴标题
            myPane.YAxis.Title.Text = "人数";          //Y轴标题
            string[] labels = new string[6];
            labels[0] = "60以下";
            labels[1] = "60-69";
            labels[2] = "70-79";
            labels[3] = "80-89";
            labels[4] = "90-99";
            labels[5] = "100";
            foreach (YearTermCourse ytc in ytclist)
            {
                Random rand = new Random();
                int r = rand.Next(8);
                int gg = rand.Next(10);
                int b = rand.Next(5);
                Color temp = Color.FromArgb(r * 30, gg * 25, b * 50);
                DataSet ds = sp.GetScoreUnionByParam(ytc.Year, Convert.ToInt32(ytc.Term), classcode, ytc.Course);
                CY.GFive.Core.Business.Course ctemp = CY.GFive.Core.Business.Course.GetByCode(ytc.Course);
                PointPairList list = new PointPairList();
                for (int i = 0; i < 6; i++)
                    list.Add(0, Convert.ToInt32(ds.Tables[0].Rows[i]["人数"]));
                BarItem myCurve = myPane.AddBar(ytc.Year + "年" + ctemp.Name, list, temp);
                myCurve.Bar.Fill = new Fill(temp, Color.White, temp);
            }
            myPane.XAxis.MajorTic.IsBetweenLabels = false; //柱状显示位置,true为在两个下标题值的中间,flase为两边
            myPane.XAxis.Scale.TextLabels = labels;//下标题的内容
            myPane.XAxis.Type = AxisType.Text;
            myPane.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 90.0f);//图表外层背景填充色,由color1到color2渐变,参数3为方向
            myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(200, 200, 255), 270.0f);//图表内层背景填充色,由color1到color2渐变,参数3为方向
            ZedGraphWeb1.Visible = true;
            masterPane.AxisChange(g);
        }
Exemplo n.º 18
0
    // Populate Graphs
    protected void PopulateSPAGauge(ZedGraphWeb z, Graphics g, MasterPane masterPane)
    {
        String user_territory = Util.GetUserTerritory();

        GraphPane myPane = masterPane[0];

        // Define the title
        myPane.Title.FontSpec.Size        = 34;
        myPane.Title.FontSpec.IsAntiAlias = false;
        myPane.Title.FontSpec.IsBold      = false;
        myPane.Title.FontSpec.FontColor   = Util.ColourTryParse("#989898");

        // Fill the pane and chart
        myPane.Fill                = new Fill(Util.ColourTryParse("#ff191919"), Util.ColourTryParse("#ff191919"), 45.0f);
        myPane.Chart.Fill          = new Fill(Util.ColourTryParse("#333333"), Util.ColourTryParse("#333333"), 45.0f);
        myPane.Chart.Fill.RangeMax = 16;
        myPane.Chart.Fill.RangeMin = 0;

        // Don't show any axes for the gas gauge
        myPane.XAxis.IsVisible  = false;
        myPane.Y2Axis.IsVisible = false;
        myPane.YAxis.IsVisible  = false;

        float  needleVal = (float)0.0;
        String office    = z.ID.Replace("1", " ").Replace("zg_", "").Replace("_", " ");

        needleVal         = CalculateRAG(office);
        myPane.Title.Text = office;

        // If admin/finance (or your territory) show all
        //if (!Roles.IsUserInRole("db_HomeHubTL") || z.ID.ToString().ToLower().Contains(user_territory.ToLower().Replace(" ", "")))
        //{
        // Define needles
        // Plot average RAG value by converting to percentage of 18 max then reverse value as chart plots backwards.
        float plotVal = 100 - (((float)needleVal / (float)16) * 100);

        if (plotVal.ToString() == "NaN")
        {
            plotVal = (float)100.0;
        }
        GasGaugeNeedle gg1 = new GasGaugeNeedle("Suspects", plotVal, System.Drawing.Color.DimGray);

        gg1.NeedleWidth = 100;
        myPane.CurveList.Add(gg1);
        //}

        //Define all regions
        GasGaugeRegion ggr1 = new GasGaugeRegion("Green", 0.0f, 7.0f, System.Drawing.Color.Green);
        GasGaugeRegion ggr2 = new GasGaugeRegion("Yellow", 7.0f, 63.0f, System.Drawing.Color.Gold);
        GasGaugeRegion ggr3 = new GasGaugeRegion("Red", 63.0f, 100.0f, System.Drawing.Color.Red);

        // Add the regions
        myPane.CurveList.Add(ggr1);
        myPane.CurveList.Add(ggr2);
        myPane.CurveList.Add(ggr3);
        myPane.Legend.IsVisible   = false;
        myPane.Chart.Border.Color = System.Drawing.Color.DimGray;
        myPane.Margin.Left        = 34;
        myPane.Margin.Right       = 34;
        myPane.Margin.Bottom      = 30;
        myPane.Margin.Top         = 4;
        myPane.AxisChange();
    }