WinForm图表控件-柱状图扩展

一.扩展说明

  好久没有写Blog了,索性将以前做的柱状图做了下立体效果的扩展,贴出来做为自己懒惰的一种提示。

二.设计时效果

三.运行时效果

四.部分源代码

 private void DrawSolidHistogram(Graphics g)
        {
            Rectangle rect = this.GetClientRect();

            //绘制主标题
            StringFormat sf = new StringFormat();
            sf.Alignment = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;

            using (Font f = new Font("宋体", 12, FontStyle.Bold))
            {
                using (SolidBrush b = new SolidBrush(Color.Black))
                {
                    using (StringFormat sf1 = new StringFormat())
                    {
                        sf1.Alignment = StringAlignment.Center;
                        g.DrawString(_caption, f, b, new Rectangle(rect.Left, rect.Top + 5, rect.Width, _captionHeight), sf1);
                    }
                }
            }
            绘制网格点
            //if (_isShowGridPoint)
            //{
            //    Rectangle rectgrid = rect;
            //    rectgrid.Inflate(0, -_captionHeight);
            //    ControlPaint.DrawGrid(g, rectgrid, new Size(20, 20), Color.Gray);
            //}
            //绘制X轴,Y轴
            using (Pen p = new Pen(Color.Black),p1 = new Pen(Color.LightGray ))
            {
                //x轴
                g.DrawLine(p, _xAxisLeft, rect.Bottom, _xAxisLeft + rect.Width, rect.Bottom);
                //x轴扭曲
                g.DrawLine(p1, _xAxisLeft, rect.Bottom, _xAxisLeft + _xContort, rect.Bottom - _yContort);
                g.DrawLine(p1, _xAxisLeft + rect.Width, rect.Bottom, _xAxisLeft + rect.Width + _xContort, rect.Bottom - _yContort);
                g.DrawLine(p1, _xAxisLeft + _xContort, rect.Bottom - _yContort, _xAxisLeft + rect.Width + _xContort, rect.Bottom - _yContort);
                
                //y轴
                g.DrawLine(p, _xAxisLeft
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值