Asp.Net(C#)中如何画图表(饼图、折线、柱状图)

     我们经常在项目中遇到,许多的数据为了真观的体现给用户,不得不引和饼图,趋势图,等等柱状图来开形象的来呈现数据,如果在不使用第三方控件的情况下,我们都知道路在winform程序中是非常容易实现的,如是webform的实现就有点麻烦。本程序是在webform上放Image控件,加上.ashx一般处理文件实现的,原理为将Image的rsc属性转到xxxxx.ashx文件处,xxxxx.ashx文件反加一张已经画好的图片,在调用xxxxx.ashx文件时可以传递参数,如用户信息,根据用户ID生成各用户相将要使用的图:

(1)饼图:

bintu.ashx文件的内容如下:

using System;
using System.Collections;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;

namespace WebApplication3
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "
http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class getSourceImage : IHttpHandler
    {
        private long TotalSalary;
        public void ProcessRequest(HttpContext context)
        {
            const int PieHeight = 500;
            const int PIeWidth = 520;

            Bitmap objBitmap = new Bitmap(PIeWidth, PieHeight);
            Graphics objGraphics = Graphics.FromImage(objBitmap);
            objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
            objGraphics.FillRectangle(new SolidBrush(Color.YellowGreen), 0, 0, PIeWidth, PieHeight);
            int iLoop2;
            // 定义位置与椭圆的大小。
            int x = 20;
            int y = 20;
            int width = 300;
            int height = 150;
            Rectangle DepartmentLegend;
            int DepartmentLegend_Y = 40;

                // 初始化起点的角度与每块饼的扫过角度。
            int startAngle = 0;
            int sweepAngle = 45;

          

  • 0
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值