程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> 基本教程篇--第五節BarChartSampleDemo.cs介紹(2)

基本教程篇--第五節BarChartSampleDemo.cs介紹(2)

編輯:關於C語言

代碼如下:

using System;

using System.Drawing;

using System.Collections;

using ZedGraph;

namespace ZedGraph.Demo

{

     ///<summary>

     /// Summary description for SimpleDemo.

     ///</summary>

     public class BarChartSampleDemo : DemoBase

     {

           public BarChartSampleDemo() : base( "Code Project Bar Chart Sample",

                "Bar Chart Sample", DemoType.Tutorial )

           {

                GraphPane myPane = base.GraPHPane;

                // Set the titles and axis labels

                myPane.Title = "My Test Bar Graph";

                myPane.XAxis.Title = "Label";

                myPane.YAxis.Title = "My Y Axis";

                // Make up some random data points

                string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard" };

                double[] y = { 100, 115, 75, 22, 98, 40 };

                double[] y2 = { 90, 100, 95, 35, 80, 35 };

                double[] y3 = { 80, 110, 65, 15, 54, 67 };

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

                // Generate a red bar with "Curve 1" in the legend

                BarItem myBar = myPane.AddBar( "Curve 1", null, y, Color.Red );

                myBar.Bar.Fill = new Fill( Color.Red, Color.White, Color.Red );

                // Generate a blue bar with "Curve 2" in the legend

                myBar = myPane.AddBar( "Curve 2", null, y2, Color.Blue );

                myBar.Bar.Fill = new Fill( Color.Blue, Color.White, Color.Blue );

                // Generate a green bar with "Curve 3" in the legend

                myBar = myPane.AddBar( "Curve 3", null, y3, Color.Green );

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

                // Generate a black line with "Curve 4" in the legend

                LineItem myCurve = myPane.AddCurve( "Curve 4",

                     null, y4, Color.Black, SymbolType.Circle );

                myCurve.Line.Fill = new Fill( Color.White, Color.LightSkyBlue, -45F );

                // Fix up the curve attributes a little

                myCurve.Symbol.Size = 8.0F;

                myCurve.Symbol.Fill = new Fill( Color.White );

                myCurve.Line.Width = 2.0F;

                // Draw the X tics between the labels instead of at the labels

                myPane.XAxis.IsTicsBetweenLabels = true;

                // Set the XAxis labels

                myPane.XAxis.TextLabels = labels;

                // Set the XAxis to Text type

                myPane.XAxis.Type = AxisType.Text;

                // Fill the axis area with a gradIEnt

                myPane.AxisFill = new Fill( Color.White,

                     Color.FromArgb( 255, 255, 166), 90F );

                // Fill the pane area with a solid color

                myPane.PaneFill = new Fill( Color.FromArgb( 250, 250, 255) );

                base.ZedGraphControl.AxisChange();

           }

     }

}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved