当前位置: 首页>>代码示例>>C#>>正文


C# GraphPane.AddBar方法代码示例

本文整理汇总了C#中ZedGraph.GraphPane.AddBar方法的典型用法代码示例。如果您正苦于以下问题:C# GraphPane.AddBar方法的具体用法?C# GraphPane.AddBar怎么用?C# GraphPane.AddBar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZedGraph.GraphPane的用法示例。


在下文中一共展示了GraphPane.AddBar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: drawGraph

 private void drawGraph()
 {
     Dictionary<double, double> coordinats = new Dictionary<double, double>();
     for (double x = xMin; x <= xMax; x += top)
     {
         if (x!=0)
         coordinats.Add(x, a/x);
     }
     GraphPane myPane = new GraphPane();
     zedGraphControl1.GraphPane = myPane;
     myPane.XAxis.Title.Text = "Координата X";
     myPane.YAxis.Title.Text = "Координата Y";
       //  myPane.Fill = new Fill(Color.White, Color.LightSkyBlue, 45.0f);
     myPane.Chart.Fill.Type = FillType.None;
     myPane.Legend.Position = LegendPos.Float;
     myPane.Legend.IsHStack = false;
     if (comboBox1.GetItemText(comboBox1.SelectedIndex) == "1")
     {
         myPane.AddBar("", coordinats.Keys.ToArray(), coordinats.Values.ToArray(), penColor);
     }
     else
     {
         LineItem myCurve = myPane.AddCurve("", coordinats.Keys.ToArray(), coordinats.Values.ToArray(), penColor, SymbolType.None);
         myCurve.Line.Width = penWeight;
         myCurve.Symbol.Fill = new Fill(Color.White);
     }
     zedGraphControl1.AxisChange();
     zedGraphControl1.Refresh();
     zedGraphControl1.Visible = true;
 }
开发者ID:knyaseff,项目名称:University-C-Sharp-labs,代码行数:30,代码来源:Form1.cs

示例2: HorizStkBarGraph

        public void HorizStkBarGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "	Horizontal Stack	Bar Graph Test", "Label", "My Y Axis" );

            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard", "Kitty", "Wildcat" };
            double[] y = { 100, 115, 75, -22, 98, 40, -10, 20 };
            double[] y2 = { 90, 100, 95, 35, 80, 35, -35, 30 };
            double[] y3 = { 80, 0, 65, -15, 54, 67, 18, 50 };

            //	Generate three	bars	with	appropriate entries in	the legend
            BarItem myCurve = testee.AddBar( "Curve 1", y, null, Color.Red );
            BarItem myCurve1 = testee.AddBar( "Curve 2", y2, null, Color.Blue );
            BarItem myCurve2 = testee.AddBar( "Curve 3", y3, null, Color.Green );
            //	Draw the Y tics	between the labels instead of	at the labels
            testee.YAxis.MajorTic.IsBetweenLabels = true;
            testee.BarSettings.Type = BarType.Stack;

            //	Set the YAxis	labels
            testee.YAxis.Scale.TextLabels = labels;
            testee.YAxis.Scale.FontSpec.Size = 9F;
            //show	the zero	line
            testee.XAxis.MajorGrid.IsZeroLine = true;
            //show	XAxis the grid lines
            testee.XAxis.MajorGrid.IsVisible = true;
            //	Set the YAxis	to Text	type
            testee.YAxis.Type = AxisType.Text;
            testee.BarSettings.Base = BarBase.Y;

            testee.YAxis.Scale.IsReverse = false;
            testee.BarSettings.ClusterScaleWidth = 1;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.WindowState = FormWindowState.Maximized;
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is a horizontal stack bar graph having three bars per y-Axis point visible?  <Next Step: Re-orient the bar fill>" ) );

            myCurve.Bar.Fill = new Fill( Color.White, Color.Red, 90 );
            myCurve1.Bar.Fill = new Fill( Color.White, Color.Blue, 90 );
            myCurve2.Bar.Fill = new Fill( Color.White, Color.Green, 90 );
            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            TestUtils.DelaySeconds( 3000 );

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did the orientation of the fill shift from vertical to horizontal?" ) );
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:54,代码来源:ZGTest.cs

示例3: BarChart

        /// <summary>
        /// Bar chart.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="_options">GraphOptions.</param>
        /// <param name="binaryOutput">if set to <c>true</c> the image will output in the response stream.</param>
        /// <returns></returns>
        public static System.Drawing.Bitmap BarChart( string query, Dictionary<string, object> _options, bool binaryOutput )
        {
            ( "FUNCTION /w binaryStream barChart" ).Debug( 10 );
            /*
                * 0 = name
                * 1 = value
                * 2 = color1
                * 3 = color2
                * 4 = angle
                */
            GraphOptions options = null;
            JToken jtOpt = JToken.FromObject( _options );
            using( JTokenReader tr = new JTokenReader( jtOpt ) ) {
                JsonSerializer serializer = new JsonSerializer();
                options = ( GraphOptions )serializer.Deserialize( tr, typeof( GraphOptions ) );
            }
            System.Drawing.Bitmap image = null;
            GraphPane myPane = null;
            using(SqlConnection cn = Site.CreateConnection(true, true)) {
                cn.Open();
                try {
                    using(SqlCommand cmd = new SqlCommand(query, cn)) {
                        myPane = new GraphPane(new System.Drawing.Rectangle(0, 0, options.Width, options.Height), options.Title, "", "");
                        myPane.Title.Text = options.Title;
                        myPane.XAxis.Title.Text = options.XAxisTitle;
                        myPane.YAxis.Title.Text = options.YAxisTitle;
                        if(options.Orientation) {
                            myPane.YAxis.Type = AxisType.Ordinal;
                        } else {
                            myPane.XAxis.Type = AxisType.Ordinal;
                        }
                        float barLocation = 0;
                        using(SqlDataReader r = cmd.ExecuteReader()) {
                            if(r.HasRows) {
                                while(r.Read()) {
                                    PointPairList list = new PointPairList();
                                    if(options.Orientation) {
                                        list.Add(Convert.ToDouble(r.GetValue(1)), barLocation);
                                        BarItem myCurve = myPane.AddBar(r.GetString(0), list, System.Drawing.Color.FromName(r.GetString(2)));
                                        myCurve.Bar.Fill = new Fill(
                                            System.Drawing.Color.FromName(r.GetString(2)),
                                            System.Drawing.Color.FromName(r.GetString(3)),
                                            System.Drawing.Color.FromName(r.GetString(2)),
                                            (float)r.GetInt32(4)
                                        );
                                    } else {
                                        list.Add(barLocation, Convert.ToDouble(r.GetValue(1)));
                                        BarItem myCurve = myPane.AddBar(r.GetString(0), list, System.Drawing.Color.FromName(r.GetString(2)));
                                        myCurve.Bar.Fill = new Fill(
                                            System.Drawing.Color.FromName(r.GetString(2)),
                                            System.Drawing.Color.FromName(r.GetString(3)),
                                            (float)r.GetInt32(4)
                                        );

                                    }
                                    barLocation += options.BarSpacing;
                                }
                            }else{
                                if(image == null) {
                                    image = new Bitmap(700, 700);
                                }
                                image = WriteImageError(image, options.NoDataMessage, options.FontFamily, options.XAxisFontSize);
                                return image;
                            }
                        }
                        if(options.Orientation) {
                            myPane.YAxis.IsVisible = false;
                            //myPane.YAxis.Scale.Max=barLocation;
                            myPane.YAxis.Scale.Min = 0;
                            myPane.BarSettings.Base = BarBase.Y;
                        } else {
                            myPane.XAxis.IsVisible = false;
                            myPane.XAxis.Scale.Min = 0;
                            //myPane.XAxis.Scale.Max=barLocation-options.barSpacing;
                            myPane.BarSettings.Base = BarBase.X;
                        }
                        // Fill the chart background with a color gradient
                        myPane.Chart.Fill = new Fill(
                        System.Drawing.Color.FromName(options.Fill.StartColor),
                        System.Drawing.Color.FromName(options.Fill.EndColor), options.Fill.Angle);
                        myPane.AxisChange();

                        // Create TextObj's to provide labels for each bar
                        BarItem.CreateBarLabels(myPane, false, "f0");
                        image = myPane.GetImage(true);
                        using(MemoryStream ms = new MemoryStream()) {
                            image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                            if(HttpContext.Current != null) {
                                HttpContext.Current.Response.Clear();
                                HttpContext.Current.Response.ContentType = "image/png";
                                HttpContext.Current.Response.AddHeader("Expires", "0");/* RFC 2616 14.21 Content has already expired */
                                HttpContext.Current.Response.AddHeader("Cache-Control", "no-store");/* RFC 2616 14.9.2 Don't ever cache */
                                HttpContext.Current.Response.AddHeader("Pragma", "no-store");/* RFC 2616 14.32 Pragma - same as cache control */
//.........这里部分代码省略.........
开发者ID:CorbinDallas,项目名称:Rendition,代码行数:101,代码来源:Chart.cs

示例4: InitGraph

        private void InitGraph(string title, string xAxisTitle, string y1AxisTitle, string y2AxisTitle, SummaryDataSource[] dataSourceArray)
        {
            _graphPane = zed.GraphPane;
            _graphPane.Title.Text = title;

			_graphPane.XAxis.Title.Text = xAxisTitle;
			_graphPane.XAxis.MajorGrid.IsVisible = true;

			_graphPane.YAxis.Title.Text = y1AxisTitle;
			_graphPane.YAxis.MajorGrid.IsVisible = true;

			_graphPane.Y2Axis.Title.Text = y2AxisTitle;
			_graphPane.Y2Axis.MajorGrid.IsVisible = false;

            // Create point-pair lists and bind them to the graph control.
            int sourceCount = dataSourceArray.Length;
            _pointPlotArray = new PointPairList[sourceCount];
            for(int i=0; i<sourceCount; i++)
            {
                SummaryDataSource ds = dataSourceArray[i];
                _pointPlotArray[i] =new PointPairList();

                Color color = _plotColorArr[i % 3];
                BarItem barItem = _graphPane.AddBar(ds.Name, _pointPlotArray[i], color);
                barItem.Bar.Fill = new Fill(color);
                _graphPane.BarSettings.MinClusterGap = 0;

                barItem.IsY2Axis = (ds.YAxis == 1);
            }
        }
开发者ID:colgreen,项目名称:sharpneat,代码行数:30,代码来源:SummaryGraphForm.cs

示例5: ClusteredBarGraph

        public void ClusteredBarGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Clustered Bar Graph Test", "Label", "My	Y	Axis" );

            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard", "Kitty" };
            double[] y = { 100, 115, 75, -22, 98, 40, -10 };
            double[] y2 = { 90, 100, 95, 35, 0, 35, -35 };
            double[] y3 = { 80, 110, 65, -15, 54, 67, 18 };

            double[] y4 = { 120, 125, 100, 20, 105, 75, -40 };

            //	Generate three	bars	with	appropriate entries in	the legend
            CurveItem myCurve = testee.AddBar( "Curve	1", null, y, Color.Red );
            CurveItem myCurve1 = testee.AddBar( "Curve	2", null, y2, Color.Blue );
            CurveItem myCurve2 = testee.AddBar( "Curve	3", null, y3, Color.Green );
            //	Draw the X tics	between the labels instead of	at the labels
            testee.XAxis.MajorTic.IsBetweenLabels = true;

            //	Set the XAxis	labels
            testee.XAxis.Scale.TextLabels = labels;
            testee.XAxis.Scale.FontSpec.Size = 9F;
            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            testee.BarSettings.Base = BarBase.X;

            testee.XAxis.Scale.IsReverse = false;
            testee.BarSettings.ClusterScaleWidth = 1;

            //Add Labels to the curves

            //	Shift	the text items up by	5 user	scale units	above	the	bars
            const float shift = 5;

            for ( int i = 0; i < y.Length; i++ )
            {
                //	format	the label string to	have	1 decimal place
                string lab = y2[i].ToString( "F1" );
                //	create	the text item (assumes	the	x	axis is	ordinal or	text)
                //	for negative bars, the	label appears just	above	the zero	value
                TextObj text = new TextObj( lab, (float)( i + 1 ), (float)( y2[i] < 0 ? 0.0 : y2[i] ) + shift );
                //	tell	Zedgraph to use user	scale units	for locating	the	TextObj
                text.Location.CoordinateFrame = CoordType.AxisXYScale;
                //	Align the left-center	of the text to the	specified	point
                text.Location.AlignH = AlignH.Left;
                text.Location.AlignV = AlignV.Center;
                text.FontSpec.Border.IsVisible = false;
                //	rotate the	text 90 degrees
                text.FontSpec.Angle = 90;
                //	add the	TextObj to	the	list
                testee.GraphObjList.Add( text );
            }

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            //	Add one step to the	max	scale value	to leave	room for the labels
            testee.YAxis.Scale.Max += testee.YAxis.Scale.MajorStep;

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is a clustered bar graph having the proper number of bars per x-Axis point visible ?  <Next Step: Resize the chart>" ) );

            TestUtils.DelaySeconds( 3000 );

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did the graph resize ok with all x-Axis labels visible?" ) );
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:71,代码来源:ZGTest.cs

示例6: lbt_importall_Click

        /// <summary>
        /// 当前列表导出Excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lbt_importall_Click(object sender, EventArgs e)
        {
            string TimeRange="";
            if (ext_StartInputDt.SelectedDate != DateTime.MinValue && ext_EndInputDt.SelectedDate != DateTime.MinValue)
            {
                TimeRange = ext_StartInputDt.SelectedDate.ToShortDateString() + "至" + ext_EndInputDt.SelectedDate.ToShortDateString();
            }
            else if (ext_StartInputDt.SelectedDate != DateTime.MinValue && ext_EndInputDt.SelectedDate == DateTime.MinValue)
            {
                TimeRange = ext_StartInputDt.SelectedDate.ToShortDateString() + "至—";
            }
            else if (ext_StartInputDt.SelectedDate == DateTime.MinValue && ext_EndInputDt.SelectedDate != DateTime.MinValue)
            {
                TimeRange = "—至" + ext_EndInputDt.SelectedDate.ToShortDateString();
            }
            else
            {
                TimeRange = "";
            }
            DataSet ds = logic.complaint.outputExcel(strWhere());
            DataTable dtlist = ds.Tables[0], dtcompany = ds.Tables[1], dtcomplaint = ds.Tables[2], dtcategory = ds.Tables[3], dtdepartment = ds.Tables[4];
            dtlist.Columns["complaintdt"].ColumnName = "日期";
            dtlist.Columns["buyername"].ColumnName = "客户名称";
            dtlist.Columns["productname"].ColumnName = "投诉产品";
            dtlist.Columns["complaintname"].ColumnName = "投诉类别";
            dtlist.Columns["department"].ColumnName = "责任部门";
            dtlist.Columns["responsibler"].ColumnName = "责任人";
            dtlist.Columns["sellername"].ColumnName = "责任供应商";
            dtlist.Columns["levelname"].ColumnName = "严重级别";
            dtlist.Columns["result"].ColumnName = "处理结果";
            dtlist.Columns["inputname"].ColumnName = "录入人";
            dtlist.Columns["remarks"].ColumnName = "投诉问题详情";
            dtlist.Columns.Remove("buyerid");
            dtlist.Columns.Remove("sellerid");
            ExportFacade facade = new ExportFacade();
            HSSFWorkbook workbook = facade.InitializeWorkbook("杭州农副产品物流网络有限公司", logic.sysAdmin.AdminID.ToString(), "采购配送系统", "投诉管理");
            Sheet sheet1 = workbook.CreateSheet("投诉详细");
            facade.CreateRowHeader(workbook, sheet1, TimeRange + " 投诉列表", dtlist);
            facade.FillRowData(workbook, sheet1, 2, dtlist, null, null, null, null);
            Sheet sheet2 = workbook.CreateSheet("客户投诉");
            facade.CreateRowHeader(workbook, sheet2, TimeRange + " 客户投诉情况", dtcompany);
            facade.FillRowData(workbook, sheet2, 2, dtcompany, null, null, null, null);
            Sheet sheet3 = workbook.CreateSheet("投诉汇总");
            facade.CreateRowHeader(workbook, sheet3, TimeRange + " 投诉问题汇总", dtcomplaint);
            facade.FillRowData(workbook, sheet3, 2, dtcomplaint, null, null, null, null);
            #region 小类投诉情况
            GraphPane graphpane = new GraphPane();
            graphpane.Title.Text = "小类投诉情况";
            graphpane.Title.FontSpec.Size = 12f;
            graphpane.XAxis.Title.Text = "小类";
            graphpane.XAxis.Title.FontSpec.Size = 11f;
            graphpane.YAxis.Title.Text = ChangeStr("投诉数量");
            graphpane.YAxis.Title.FontSpec.Angle = 90;
            graphpane.YAxis.Title.FontSpec.Size = 11f;
            graphpane.XAxis.IsVisible = true;
            graphpane.YAxis.IsVisible = true;
            List<string> category=new List<string>();
            List<double> cnum = new List<double>();
            int maxcnum = 2;
            foreach (DataRow dr in dtcategory.Rows)
            {
                if(Convert.ToInt32( dr[1].ToString())>maxcnum)
                    maxcnum=Convert.ToInt32( dr[1].ToString());
                category.Add(ChangeStr( dr[0].ToString()));
                cnum.Add(Convert.ToDouble(dr[1].ToString()));
            }

            BarItem baritem = graphpane.AddBar(null,null,cnum.ToArray(), Color.Red);
            baritem.Bar.Fill = new Fill(Color.Red, Color.White, Color.Red);
            BarItem.CreateBarLabels(graphpane, false, "f0");
            graphpane.XAxis.Scale.TextLabels = category.ToArray();
            graphpane.XAxis.Scale.Max = category.ToArray().Length+1;
            graphpane.XAxis.Scale.MajorStep = 1;
            graphpane.XAxis.MinorTic.Size = 0;
            graphpane.XAxis.MajorTic.Size = 0;
            graphpane.XAxis.Cross = 0;
            graphpane.XAxis.Scale.FontSpec.Size = 10f;
            graphpane.XAxis.Scale.FontSpec.Family = "宋体";
            graphpane.XAxis.Type = AxisType.Text;
            graphpane.XAxis.MajorTic.IsOutside = false;
            graphpane.XAxis.MajorTic.IsOpposite = false;
            graphpane.YAxis.Scale.Max = maxcnum+2;
            graphpane.YAxis.MinorTic.Size = 0;
            graphpane.YAxis.MinorGrid.DashOff = 0;
            graphpane.YAxis.Scale.MajorStep = 1;
            graphpane.YAxis.MajorTic.IsOpposite = false;
            graphpane.YAxis.MajorTic.IsOutside = false;
            graphpane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 90F);
            graphpane.Fill = new Fill(Color.White, Color.FromArgb(250, 250, 255),45.0f);
            graphpane.Fill.IsScaled = true;
            MemoryStream ms = new MemoryStream();
            //zgc.GetImage().Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);
            Bitmap map = graphpane.GetImage(750,550,17);
            map.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            byte[] picbyte = ms.ToArray();
//.........这里部分代码省略.........
开发者ID:atian15,项目名称:peisong-expert,代码行数:101,代码来源:complaintList.aspx.cs

示例7: StkBarGraph

        public void StkBarGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Stack Bar	Graph	Test ", "Label", "My	Y	Axis" );

            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard", "Kitty" };
            double[] y = { 100, 115, 75, -22, 0, 40, -10 };
            double[] y2 = { 90, 100, -95, 35, 0, 35, -35 };
            double[] y3 = { 80, 110, 65, -15, 54, 67, -18 };

            double[] y4 = { 120, 125, 100, 20, 105, 75, -40 };

            //	Generate three	bars	with	appropriate entries in	the legend
            CurveItem myCurve = testee.AddBar( "Curve	1", null, y, Color.Red );
            CurveItem myCurve1 = testee.AddBar( "Curve	2", null, y2, Color.Blue );
            CurveItem myCurve2 = testee.AddBar( "Curve	3", null, y3, Color.Green );
            //	Draw the X tics	between the labels instead of	at the labels
            testee.XAxis.MajorTic.IsBetweenLabels = true;

            //	Set the XAxis	labels
            testee.XAxis.Scale.TextLabels = labels;
            testee.XAxis.Scale.FontSpec.Size = 9F;
            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            testee.BarSettings.Base = BarBase.X;
            //display as	stack bar
            testee.BarSettings.Type = BarType.Stack;
            //display horizontal grid	lines
            testee.YAxis.MajorGrid.IsVisible = true;

            testee.XAxis.Scale.IsReverse = false;
            testee.BarSettings.ClusterScaleWidth = 1;
            //turn	off pen width	scaling
            testee.IsPenWidthScaled = false;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is a stack bar graph having three bars per x-Axis point visible ?  <Next Step: Maximize the display>" ) );

            TestUtils.DelaySeconds( 3000 );

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did the graph resize ok with all x-Axis labels visible?  <Next Step: Add a curve>" ) );

            LineItem curve = new LineItem( "Curve A", null, y4, Color.Black, SymbolType.TriangleDown );
            testee.CurveList.Insert( 0, curve );
            curve.Line.Width = 1.5F;
            curve.Line.IsSmooth = true;
            curve.Line.SmoothTension = 0.6F;
            curve.Symbol.Fill = new Fill( Color.Yellow );
            curve.Symbol.Size = 8;

            form2.Refresh();

            TestUtils.DelaySeconds( 3000 );

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Was a new curve displayed on top of the bars?" ) );
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:63,代码来源:ZGTest.cs

示例8: membuat_histogram_emgu

        private void membuat_histogram_emgu(Image<Bgr,byte> gambar, GraphPane histogram, string RGB)
        {
            int[] nilai_pixel = new int[256];
            //int tmp, r, g, b;
            PointPairList data_pixel = new PointPairList();
            BarItem kurva;

            //load image
            //Image<Bgr, byte> image = new Image<Bgr, byte>("sample.png");

            //get the pixel from [row,col] = 24,24
            //Bgr pixel = image[24, 24];

            //get the b,g,r values
            //double b = pixel.Blue;
               // double g = pixel.Green;
            //double r = pixel.Red;
            int r, g, b, grey;
            Bgr pixel;

            if (RGB == "red") //jika red
            {
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {
                        pixel = gambar[j, i];
                        r = (int)pixel.Red;
                        nilai_pixel[r] += 1;
                        /*MessageBox.Show(r.ToString());
                        MessageBox.Show(nilai_pixel[r].ToString());*/
                    }
                }
                for (int i = 0; i < 256; i++)
                {
                    data_pixel.Add(i, nilai_pixel[i]);
                }
                kurva = histogram.AddBar("Nilai Pixel", data_pixel, Color.Red);
                kurva.Bar.Fill = new Fill(Color.Red);
                //histogram.AxisFill = new Fill(Color.Red);
            }
            else if (RGB == "green") //jika green
            {
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {
                        pixel = gambar[j, i];
                        g = (int)pixel.Green;
                        nilai_pixel[g] += 1;
                    }
                }
                for (int i = 0; i < 256; i++)
                {
                    data_pixel.Add(i, nilai_pixel[i]);
                }
                kurva = histogram.AddBar("Nilai Pixel", data_pixel, Color.Green);
                kurva.Bar.Fill = new Fill(Color.Green);
            }
            else if (RGB == "blue") //jika blue
            {
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {
                        pixel = gambar[j, i];
                        b = (int)pixel.Blue;
                        nilai_pixel[b] += 1;
                    }
                }
                for (int i = 0; i < 256; i++)
                {
                    data_pixel.Add(i, nilai_pixel[i]);
                }
                kurva = histogram.AddBar("Nilai Pixel", data_pixel, Color.Blue);
                kurva.Bar.Fill = new Fill(Color.Blue);
            }
            else if (RGB == "gabungan") //jika gabungan
            {
                int[,] n_p = new int[256, 3];
                int nilai_mak = 0;
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {

                        pixel = gambar[j, i];
                        r = (int)pixel.Red;
                        g = (int)pixel.Green;
                        b = (int)pixel.Blue;

                        n_p[r, 0] += 1;
                        n_p[g, 1] += 1;
                        n_p[b, 2] += 1;
                    }
                }
                for (int i = 0; i < 256; i++)
                {
                    /*if (nilai_mak < n_p[i, 0]) nilai_mak = n_p[i, 0]; //jika r lebih besar
                    else if (nilai_mak < n_p[i, 1]) nilai_mak = n_p[i, 1]; //jika g lebih besar
//.........这里部分代码省略.........
开发者ID:AICcoding,项目名称:OperasiPixel,代码行数:101,代码来源:Form1.cs

示例9: membuat_histogram_primitif

        private void membuat_histogram_primitif(Bitmap gambar, GraphPane histogram, string RGB)
        {
            int[] nilai_pixel = new int[256];
            int tmp, r, g, b;
            PointPairList data_pixel = new PointPairList();
            BarItem kurva;
            if (RGB == "red") //jika red
            {
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {
                        tmp = gambar.GetPixel(i, j).R;
                        nilai_pixel[tmp] += 1;
                    }
                }
                for (int i = 0; i < 256; i++)
                {
                    data_pixel.Add(i, nilai_pixel[i]);
                }
                kurva = histogram.AddBar("Nilai Pixel", data_pixel, Color.Red);
                kurva.Bar.Fill = new Fill(Color.Red);
                //histogram.AxisFill = new Fill(Color.Red);
            }
            else if (RGB == "green") //jika green
            {
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {
                        tmp = gambar.GetPixel(i, j).G;
                        nilai_pixel[tmp] += 1;
                    }
                }
                for (int i = 0; i < 256; i++)
                {
                    data_pixel.Add(i, nilai_pixel[i]);
                }
                kurva = histogram.AddBar("Nilai Pixel", data_pixel, Color.Green);
                kurva.Bar.Fill = new Fill(Color.Green);
            }
            else if (RGB == "blue") //jika blue
            {
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {
                        tmp = gambar.GetPixel(i, j).B;
                        nilai_pixel[tmp] += 1;
                    }
                }
                for (int i = 0; i < 256; i++)
                {
                    data_pixel.Add(i, nilai_pixel[i]);
                }
                kurva = histogram.AddBar("Nilai Pixel", data_pixel, Color.Blue);
                kurva.Bar.Fill = new Fill(Color.Blue);
            }
            else if (RGB == "gabungan") //jika gabungan
            {
                int[,] n_p = new int[256, 3];
                int nilai_mak = 0;
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {

                        r = gambar.GetPixel(i, j).R;
                        g = gambar.GetPixel(i, j).G;
                        b = gambar.GetPixel(i, j).B;

                        n_p[r, 0] += 1;
                        n_p[g, 1] += 1;
                        n_p[b, 2] += 1;
                    }
                }
                for (int i = 0; i < 256; i++)
                {
                    /*if (nilai_mak < n_p[i, 0]) nilai_mak = n_p[i, 0]; //jika r lebih besar
                    else if (nilai_mak < n_p[i, 1]) nilai_mak = n_p[i, 1]; //jika g lebih besar
                    else if (nilai_mak < n_p[i, 2]) nilai_mak = n_p[i, 2]; //jika b lebih besar

                    data_pixel.Add(i, nilai_mak);
                    nilai_mak = 0;*/

                    nilai_mak = nilai_mak + n_p[i, 0] + n_p[i, 1] + n_p[i, 2];
                    data_pixel.Add(i, nilai_mak);
                    nilai_mak = 0;
                }

                kurva = histogram.AddBar("Nilai Pixel", data_pixel, Color.Black);
                kurva.Bar.Fill = new Fill(Color.Black);
            }
            else if(RGB == "luminositi")
            {
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {
                        tmp = (int)((gambar.GetPixel(i, j).R * .3) + (gambar.GetPixel(i, j).G * .59) + (gambar.GetPixel(i, j).B * .11));
//.........这里部分代码省略.........
开发者ID:AICcoding,项目名称:OperasiPixel,代码行数:101,代码来源:Form1.cs

示例10: PlotSnow

        /// <summary>
        /// Plot the snow !!!!
        /// </summary>
        /// <param name="ts"></param>
        /// <param name="myPane"></param>
        private void PlotSnow(ITimeSeries ts, GraphPane myPane)
        {
            TimeInterval interval = new TimeInterval(ts.Start, ts.End);

            //Main creation of curve
            if ( interval.Length.TotalDays < 160 )
            {
                BarItem myCurve = myPane.AddBar("", ts, Color.Blue);
                myCurve.Bar.Border.Color = Color.Blue;
                myCurve.Bar.Border.IsVisible = true;
                myCurve.Bar.Fill.Type = FillType.Solid;
                myCurve.Bar.Fill.IsScaled = false;
            }
            else if (interval.Length.TotalDays < 200)
            {
                StickItem myCurve = myPane.AddStick("", ts, Color.Blue);
            }
            else if (interval.Length.TotalDays < 400)
            {
                BarItem myCurve = myPane.AddBar("", ts, Color.Blue);
                myCurve.Bar.Border.Color = Color.Blue;
                myCurve.Bar.Border.IsVisible = true;
                myCurve.Bar.Fill.Type = FillType.Solid;
                myCurve.Bar.Fill.IsScaled = false;
            }
            else
            {
                StickItem myCurve = myPane.AddStick("", ts, Color.Blue);
            }
            //else
            //{
            //    StickItem myCurve = myPane.AddStick("", ts, Color.Blue);
            //    //LineItem myCurve = myPane.AddCurve("", ts, Color.Blue, SymbolType.None);
            //    //myCurve.Line.Width = 0F;
            //    //myCurve.Line.Fill = new Fill(Color.Blue);
            //}
        }
开发者ID:jirikadlec2,项目名称:hydrodata,代码行数:42,代码来源:ChartEngine.cs

示例11: PlotPrecipHour

        /// <summary>
        /// Plot the hourly precipitation !!!!
        /// </summary>
        private void PlotPrecipHour(ITimeSeries ts, GraphPane myPane)
        {
            TimeInterval interval = new TimeInterval(ts.Start, ts.End);
            string varName = Resources.precip_label;

            //Main creation of curve
            if ( interval.Length.TotalDays <= 2 )
            {
                BarItem myCurve = myPane.AddBar(varName, ts, Color.Blue);
                myCurve.Bar.Border.Color = Color.Blue;
                myCurve.Bar.Border.IsVisible = true;
                myCurve.Bar.Fill.Type = FillType.Solid;
                myCurve.Bar.Fill.IsScaled = false;
            }
            else
            {
                StickItem myCurve = myPane.AddStick(varName, ts, Color.Blue);
            }

            //cumulative precipitation..
            ITimeSeries ts2 = ts.ShowCumulative();
            LineItem myCurve2 = myPane.AddCurve(Resources.precip_sum_label,
                ts2, Color.Red, SymbolType.None);
            myCurve2.IsY2Axis = true;
            myPane.AxisChange();
        }
开发者ID:jirikadlec2,项目名称:hydrodata,代码行数:29,代码来源:ChartEngine.cs

示例12: Form1_Load


//.........这里部分代码省略.........
                double distance = acceleration * time * time / 2.0;
                PerformanceData perfData = new PerformanceData( time, distance, velocity, acceleration );
                myList.Add( perfData );
            }

            myPane.AddCurve( "Distance", myList, Color.Blue );
            myPane.AddCurve( "Velocity", myList2, Color.Red );

            #endif

            #if false	// GradientByZ

            myPane = new GraphPane( new Rectangle( 10, 10, 10, 10 ),
                "Wacky Widget Company\nProduction Report",
                "Time, Days\n(Since Plant Construction Startup)",
                "Widget Production\n(units/hour)" );
            SetSize();

            string[] ystr = { "one", "two", "three", "four", "five" };

            double[] x = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            double[] y = { .1, .2, .3, .4, .5, .4, .3, .2, .1, .2 };
            //double[] y = { 20, 10, 50, 25, 35, 75, 90, 40, 33, 50 };
            double[] z = { 1, 2, 3, 4, 5, 5, 4, 3, 2, 1 };
            PointPairList list = new PointPairList( x, y, z );

            Color[] colors = { Color.Red, Color.Green, Color.Blue,
                                Color.Yellow, Color.Orange };
            Fill fill = new Fill( colors );
            fill.Type = FillType.GradientByZ;
            fill.RangeMin = 1;
            fill.RangeMax = 5;

            BarItem myBar = myPane.AddBar( "My Bar", list, Color.Tomato );
            myBar.Bar.Fill = fill;
            myPane.XAxis.Type = AxisType.Ordinal;
            //myPane.YAxis.Type = AxisType.Text;
            //myPane.YAxis.TextLabels = ystr;
            //myPane.ClusterScaleWidth = 1;

            //myPane.AxisChange( this.CreateGraphics() );

            #endif

            #if false	// GradientByZ dual bars
            myPane = new GraphPane( new RectangleF(0,0,300,400), "Title", "X Label", "Y Label" );

            double[] xx = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            double[] yy = { 1, 2, 3, 4, 5, 4, 3, 2, 1, 2 };
            double[] yy2 = { 4, 5, 7, 8, 1, 3, 5, 2, 4, 9 };
            double[] zz = { 1, 2, 3, 4, 5, 5, 4, 3, 2, 1 };
            double[] zz2 = { 5, 1, 4, 2, 3, 4, 2, 1, 5, 5 };
            PointPairList list = new PointPairList( xx, yy, zz );
            PointPairList list2 = new PointPairList( xx, yy2, zz2 );

            Color[] colors = { Color.Red, Color.Green, Color.Blue,
                                 Color.Yellow, Color.Orange };
            Fill fill = new Fill( colors );
            fill.Type = FillType.GradientByZ;
            fill.RangeMin = 1;
            fill.RangeMax = 5;

            BarItem myBar = myPane.AddBar( "My Bar", list, Color.Tomato );
            myBar.Bar.Fill = fill;
            BarItem myBar2 = myPane.AddBar( "My Bar 2", list2, Color.Tomato );
            myBar2.Bar.Fill = fill;
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:67,代码来源:Form1.cs

示例13: PctStkBarGraph

        public void PctStkBarGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Percent Stack Bar Test ", "Label", "My	Y	Axis" );

            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard", "Kitty" };
            double[] y = { 100, 115, 75, -22, 0, 40, -10 };
            double[] y2 = { 90, 100, -95, 35, 0, 35, -35 };
            double[] y3 = { 80, 110, 65, -15, 54, 67, -18 };

            //	Generate three	bars	with	appropriate entries in	the legend
            BarItem myCurve = testee.AddBar( "Curve	1", null, y, Color.Red );
            BarItem myCurve1 = testee.AddBar( "Curve	2", null, y2, Color.Blue );
            BarItem myCurve2 = testee.AddBar( "Curve	3", null, y3, Color.Green );
            //	Draw the X tics	between the labels instead of	at the labels
            testee.XAxis.MajorTic.IsBetweenLabels = true;

            //	Set the XAxis	labels
            testee.XAxis.Scale.TextLabels = labels;
            testee.XAxis.Scale.FontSpec.Size = 9F;
            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            testee.BarSettings.Base = BarBase.X;
            //display as	stack bar
            testee.BarSettings.Type = BarType.PercentStack;
            //display horizontal grid	lines
            testee.YAxis.MajorGrid.IsVisible = true;

            testee.XAxis.Scale.IsReverse = false;
            testee.BarSettings.ClusterScaleWidth = 1;
            //turn off	pen width scaling
            testee.IsPenWidthScaled = false;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is a stack bar graph having three bars per x-Axis point visible ?  <Next Step: Fill one bar segment with a Textured Brush>" ) );

            Bitmap bm = new Bitmap( @"C:\WINDOWS\FeatherTexture.bmp" );
            TextureBrush brush = new TextureBrush( bm );

            myCurve.Bar.Fill = new Fill( brush );
            form2.Refresh();

            TestUtils.DelaySeconds( 3000 );
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Was the red segment replaced with one having a bitmap fill?<Next: Disappearing segments" ) );

            for ( int iCurve = 0; iCurve < 2; iCurve++ )
            {
                PointPairList ppList = testee.CurveList[iCurve].Points as PointPairList;

                for ( int i = 0; i < testee.CurveList[iCurve].Points.Count; i++ )
                {
                    PointPair pt = ppList[i];
                    pt.Y = 0;
                    ppList[i] = pt;

                    form2.Refresh();

                    //	delay
                    TestUtils.DelaySeconds( 500 );
                }
            }
            TestUtils.DelaySeconds( 1000 );
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did the segments disappear uniformly while the total height stayed at +/-100%?" ) );
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:72,代码来源:ZGTest.cs

示例14: CreateGraph

        public void CreateGraph(ZedGraph.ZedGraphControl zgc)
        {
            zgc.MasterPane.PaneList.Clear();

            time1 = 0;
            time2 = 0;

            XScaleValue1 = Convert.ToInt16(XScale1.Value);
            XScaleValue2 = Convert.ToInt16(XScale2.Value);

            GraphPane myPane1 = new GraphPane();
            GraphPane myPane2 = new GraphPane();

            zgc.MasterPane.Add(myPane1);
            zgc.MasterPane.Add(myPane2);

            zgc.MasterPane.PaneList[0].Legend.IsVisible = false;
            zgc.MasterPane.PaneList[1].Legend.IsVisible = false;

            myPane1.Chart.Fill = new Fill(Color.Black);
            myPane2.Chart.Fill = new Fill(Color.Black);
            myPane1.Title.Text = "myPane1";
            myPane1.Title.FontSpec.Size = 12F;
            myPane2.Title.Text = "myPane2";
            myPane2.Title.FontSpec.Size = 12F;

            if (IsScrolling)
            {
                //zgc.IsAntiAlias = true;
            }
            list1.Add(0, 0);

            //Make a new curve
            BarItem RecentBar1 = myPane1.AddBar("RecentBar", RecentPoint1, Color.Red);
            RecentBar1.Bar.Fill = new Fill(Color.Red);

            RecentBar1.Bar.Border = new Border(Color.Red, 10.0F);
            BarItem RecentBar2 = myPane2.AddBar("RecentBar", RecentPoint2, Color.Red);
            RecentBar2.Bar.Fill = new Fill(Color.Red);
            RecentBar2.Bar.Border = new Border(Color.Red, 10.0F);

            BarItem curve = myPane1.AddBar("Average Counts", list1, Color.White);
            curve.Bar.Border = new Border(Color.White, 1.0F);
            //curve.Line.Fill = new Fill (Color.White);
              //  curve.Line.IsVisible = false;

            BarItem curve2 = myPane2.AddBar("Counts (Avg ten)", list2, Color.White);
            curve2.Bar.Border = new Border(Color.White, 1.0F);

            //Timer fort the X axis, defined later
            timer1.Interval = 1; //10 - buffer size increases due to build up but levels out at about 112 bytes.
            timer1.Enabled = true;
            timer1.Start();

            // Layout the GraphPanes using a default Pane Layout
            using (Graphics g = this.CreateGraphics())
            {
                zgc.MasterPane.SetLayout(g, PaneLayout.SingleRow);
            }

            //Function to set axes of graphpanes.
            SetXAxis1();
            SetXAxis2();
            if (AutoScale.Checked == false)
            {
                SetYAxis1();
                SetYAxis2();
            }

            //Save begging time for reference
            tickStart = Environment.TickCount;

            Console.WriteLine("Create Graph");

            zgc.Invalidate();
        }
开发者ID:seth-obi-msci,项目名称:CSharp,代码行数:76,代码来源:Form1.cs

示例15: SortedOverlayBarGraph

        public void SortedOverlayBarGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Sorted Overlay Bar Graph Test ", "Label", "My	Y	Axis" );

            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard", "Kitty" };
            double[] y = { 100, -115, 75, 22, 98, 40, 10 };
            double[] y2 = { 90, -100, 95, -35, 0, 35, 35 };
            double[] y3 = { 80, -110, 65, 15, 54, 67, 18 };

            //	Generate three	bars	with	appropriate entries in	the legend
            CurveItem myCurve = testee.AddBar( "Curve	1", null, y3, Color.Red );
            CurveItem myCurve1 = testee.AddBar( "Curve	2", null, y2, Color.Blue );
            CurveItem myCurve2 = testee.AddBar( "Curve	3", null, y, Color.Green );
            //	Draw the X tics	between the labels instead of	at the labels
            testee.XAxis.MajorTic.IsBetweenLabels = true;

            //	Set the XAxis	labels
            testee.XAxis.Scale.TextLabels = labels;
            testee.XAxis.Scale.FontSpec.Size = 9F;
            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            testee.BarSettings.Base = BarBase.X;
            //display as	overlay bars
            testee.BarSettings.Type = BarType.SortedOverlay;
            //display horizontal grid	lines
            testee.YAxis.MajorGrid.IsVisible = true;

            testee.XAxis.Scale.IsReverse = false;
            testee.BarSettings.ClusterScaleWidth = 1;

            //	Shift	the text items up by	5 user	scale units	above	the	bars
            const float shift = 5;

            string lab = "";
            TextObj text = null;
            for ( int x = 0; x < 3; x++ )
                for ( int i = 0; i < y.Length; i++ )
                {
                    //	format	the label string to	have	1 decimal place
                    switch ( x )
                    {
                        case 0:
                            lab = y[i].ToString();
                            text = new TextObj( lab, (float)( i + 1 ), (float)( y[i] < 0 ? y[i] + 2 * shift : y[i] ) - shift );
                            break;
                        case 1:
                            lab = y2[i].ToString();
                            text = new TextObj( lab, (float)( i + 1 ), (float)( y2[i] < 0 ? y2[i] + 2 * shift : y2[i] ) - shift );
                            break;
                        case 2:
                            lab = y3[i].ToString();
                            text = new TextObj( lab, (float)( i + 1 ), (float)( y3[i] < 0 ? y3[i] + 2 * shift : y3[i] ) - shift );
                            break;
                        default:
                            break;
                    }
                    text.FontSpec.Size = 4;
                    text.FontSpec.IsBold = true;
                    //	tell	Zedgraph to use user	scale units	for locating	the	TextObj
                    text.Location.CoordinateFrame = CoordType.AxisXYScale;
                    //	Align the left-center	of the text to the	specified	point
                    text.Location.AlignH = AlignH.Center;
                    text.Location.AlignV = AlignV.Center;
                    text.FontSpec.Border.IsVisible = false;
                    //	add the	TextObj to	the	list
                    testee.GraphObjList.Add( text );
                }

            form2.WindowState = FormWindowState.Maximized;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            //	Add one step to the	max	scale value	to leave	room for the labels
            testee.YAxis.Scale.Max += testee.YAxis.Scale.MajorStep;

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is a Sorted Overlay Stack Bar displayed with the segments in increasing value order as indicated by the embedded values? " ) );
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:85,代码来源:ZGTest.cs


注:本文中的ZedGraph.GraphPane.AddBar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。