本文所要将的是在“配餐系统”开发中 立体饼状图效果的实现,直接贴出代码和附上示例,相信需要的朋友可以很容易使用!项目中的效果图,如下:

  实现 应用的是 System.Drawing.PieChart.PieChartControl 控件, PieChartHelper类如下:

代码
using System;
using System.Collections;
using System.Drawing;
using System.Text;

///<summary>
/// 立体饼状图操作类
///</summary>
publicclass PieChartHelper
{
///<summary>
/// 饼状图初始化设置
///</summary>
///<param name="pieChart"></param>
publicstaticvoid Init_PieChart(System.Drawing.PieChart.PieChartControl pieChart)
{
pieChart.EdgeColorType
= System.Drawing.PieChart.EdgeColorType.Contrast;
pieChart.EdgeLineWidth
=1;//设置饼块的边框线的宽度
//饼状图(上下左右)距离边框(PieChart控件的边框)都为5
pieChart.LeftMargin = 5f;
pieChart.RightMargin
= 5f;
pieChart.TopMargin
= 5f;
pieChart.BottomMargin
= 5f;
pieChart.FitChart
=true;
pieChart.SliceRelativeHeight
=0.15f;//设置饼块的厚(高)度
pieChart.InitialAngle =30;
pieChart.ShadowStyle
= System.Drawing.PieChart.ShadowStyle.GradualShadow;
pieChart.BackColor
= System.Drawing.Color.Transparent;
}

///<summary>
/// 设置饼状图各项对应的值
///</summary>
///<param name="pieChart"></param>
///<param name="valArray"></param>
publicstaticvoid SetPieChartControl_Values(System.Drawing.PieChart.PieChartControl pieChart, decimal[] valArray)
{
pieChart.Values
= valArray;
}

///<summary>
/// 设置饼状图各项对应的颜色
///</summary>
///<param name="pieChart"></param>
///<param name="colArray"></param>
publicstaticvoid SetPieChartControl_Colors(System.Drawing.PieChart.PieChartControl pieChart, Color[] colArray)
{
ArrayList colors
=new ArrayList();
foreach (Color col in colArray)
{
colors.Add(Color.FromArgb(
125, col));
}
pieChart.Colors
= (Color[])colors.ToArray(typeof(Color)); ;
}

///<summary>
/// 设置饼状图各项对应的文本
///</summary>
///<param name="pieChart"></param>
///<param name="textArray"></param>
publicstaticvoid SetPieChartControl_Texts(System.Drawing.PieChart.PieChartControl pieChart, string[] textArray)
{
pieChart.Texts
= textArray;
}

///<summary>
/// 设置饼状图各项对应的文本提示
///</summary>
///<param name="pieChart"></param>
///<param name="tipArray"></param>
publicstaticvoid SetPieChartControl_ToolTips(System.Drawing.PieChart.PieChartControl pieChart, string[] tipArray)
{
pieChart.ToolTips
= tipArray;
}
}

 

源码示例下载

posted on 2011-01-29 22:30  know-more  阅读(5850)  评论(14编辑  收藏  举报

湖北诚万兴科技-专业微信小程序开发!

微信小程序开发一物一码红包系统开发iPhone序列号查询