没有合适的资源?快使用搜索试试~ 我知道了~
图表分析代码编辑器修改
需积分: 9 2 下载量 37 浏览量
2008-10-28
10:32:26
上传
评论
收藏 7KB TXT 举报
温馨提示
试读
8页
图表分析也不愿意整理了,你看看有没有用。他是从数据库里读出信息,然后根据读出的信息化一个饼图。 其中问题以及票数和该问题对应的显示颜色都在数据库中
资源推荐
资源详情
资源评论
我这里有一个饼图和直方图的程序,希望对你有用!
using System;
using System.IO;
using System.Data;
using System.Drawing;
using System.Drawing.Text;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace Insight_cs.WebCharts
{
public class PieChart
{
public PieChart()
{
}
public void Render(string title, string subTitle, int width, int height, DataSet chartData, Stream target)
{
const int SIDE_LENGTH = 400;
const int PIE_DIAMETER = 200;
DataTable dt = chartData.Tables[0];
//calculate total amount of units in the pie, based on the data passed in
float sumData = 0;
foreach(DataRow dr in dt.Rows)
{
sumData += Convert.ToSingle(dr[1]);
using System;
using System.IO;
using System.Data;
using System.Drawing;
using System.Drawing.Text;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace Insight_cs.WebCharts
{
public class PieChart
{
public PieChart()
{
}
public void Render(string title, string subTitle, int width, int height, DataSet chartData, Stream target)
{
const int SIDE_LENGTH = 400;
const int PIE_DIAMETER = 200;
DataTable dt = chartData.Tables[0];
//calculate total amount of units in the pie, based on the data passed in
float sumData = 0;
foreach(DataRow dr in dt.Rows)
{
sumData += Convert.ToSingle(dr[1]);
}
//create a new image
Bitmap bm = new Bitmap(width,height);
Graphics g = Graphics.FromImage(bm);
//set image attributes
g.ScaleTransform((Convert.ToSingle(width))/SIDE_LENGTH,(Convert.ToSingle(height))/SIDE_LENGTH);
g.SmoothingMode = SmoothingMode.Default;
g.TextRenderingHint = TextRenderingHint.AntiAlias;
//draw canvas and border
g.Clear(Color.White);
g.DrawRectangle(Pens.Black,0,0,SIDE_LENGTH-1,SIDE_LENGTH-1);
//draw title
g.DrawString(title,new Font("Tahoma",24),Brushes.Black,new PointF(5,5));
//draw sub-title
g.DrawString(subTitle,new Font("Tahoma",14),Brushes.Black,new PointF(7,35));
//draw the pie
float curAngle = 0;
float totalAngle = 0;
for(int i=0;i<dt.Rows.Count;i++)
{
curAngle = Convert.ToSingle(dt.Rows[i][1]) / sumData * 360;
g.FillPie(new SolidBrush(ChartUtil.GetChartItemColor(i)),100,65,PIE_DIAMETER,PIE_DIAMETER,totalAngle,curAngle);
g.DrawPie(Pens.Black,100,65,PIE_DIAMETER,PIE_DIAMETER,totalAngle,curAngle);
//create a new image
Bitmap bm = new Bitmap(width,height);
Graphics g = Graphics.FromImage(bm);
//set image attributes
g.ScaleTransform((Convert.ToSingle(width))/SIDE_LENGTH,(Convert.ToSingle(height))/SIDE_LENGTH);
g.SmoothingMode = SmoothingMode.Default;
g.TextRenderingHint = TextRenderingHint.AntiAlias;
//draw canvas and border
g.Clear(Color.White);
g.DrawRectangle(Pens.Black,0,0,SIDE_LENGTH-1,SIDE_LENGTH-1);
//draw title
g.DrawString(title,new Font("Tahoma",24),Brushes.Black,new PointF(5,5));
//draw sub-title
g.DrawString(subTitle,new Font("Tahoma",14),Brushes.Black,new PointF(7,35));
//draw the pie
float curAngle = 0;
float totalAngle = 0;
for(int i=0;i<dt.Rows.Count;i++)
{
curAngle = Convert.ToSingle(dt.Rows[i][1]) / sumData * 360;
g.FillPie(new SolidBrush(ChartUtil.GetChartItemColor(i)),100,65,PIE_DIAMETER,PIE_DIAMETER,totalAngle,curAngle);
g.DrawPie(Pens.Black,100,65,PIE_DIAMETER,PIE_DIAMETER,totalAngle,curAngle);
剩余7页未读,继续阅读
资源评论
zhangyinan1
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功