ZedGraph 横向的状柱状图 (Histogram Bar)

   

 private void OnRenderGraph(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 = "Horizontal Bar Graph";
        myPane.XAxis.Title.Text = "Performance Factor";
        myPane.YAxis.Title.Text = "Grouping";

        // Enter some random data values
        double[] y = { 100, 100, 75, 22, 98, 40, 10 };
        double[] y2 = { 90, 100, 95, 35, 80, 35, 35 };
        double[] y3 = { 80, 100, 65, 15, 54, 67, 18 };

        // Generate a bar with "Curve 1" in the legend
        BarItem myCurve = myPane.AddBar("Curve 1", y, null, Color.Red);
        // Fill the bar with a red-white-red gradient
        myCurve.Bar.Fill = new Fill(Color.Red, Color.White, Color.Red, 90F);

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

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

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

        // Set the XAxis to an ordinal type
        myPane.YAxis.Type = AxisType.Ordinal;
        myPane.XAxis.Scale.Max = 100;
        // draw the X axis zero line
        myPane.XAxis.MajorGrid.IsZeroLine = true;

        //This is the part that makes the bars horizontal
        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);
       
        //Create a label for each bar in the
        BarItem.CreateBarLabels(myPane, false, "0");

    }

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值