Chartlet简单易用的图表控件

本文介绍了一款轻量级图表插件的使用方法,包括添加、配置样式、绑定数据等步骤,适用于小型项目的快速图表展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.易用,占空间小,非常适合小型项目开发。

2.样式美观

用法:

1)添加到项目并且引用

2)设置需要的样式

3)绑定数据

View Code
复制代码
            //X坐标轴标识数组
            //Labels on X Axis
            ArrayList XTitle = new ArrayList();
            XTitle.Add("你");
            XTitle.Add("我");
            XTitle.Add("他");
            XTitle.Add("她");

            //图表数据(1组)
            //Chart Data
            ArrayList[] ChartData = new ArrayList[1];

            ChartData[0] = new ArrayList();
            ChartData[0].Add(50);
            ChartData[0].Add(20);
            ChartData[0].Add(20);
            ChartData[0].Add(10);


            Chartlet1.InitializeData(ChartData, XTitle, null);

            //注:饼图只使用ChartData中的第一组数据
            //Notes: Pie Chart only use the first group data of ChartData Array
--------------------------------------------------------------------------------------------------
 
  

首先,在使用之前需要将此插件添加到工具栏中,至于插件可以登录到http://www.chartlet.cn/网站下载最新版本。

添加过程:右键工具栏空白处--》选择项--》在.netframework选项卡下点击浏览--》找到下载后的Chartlet.dll文件--》打开---》确定

添加完成后在工具栏中便会出现 一项 “Chartlet” 的图标,这样添加过程完成了;

在使用时候Chartlet 可以像其他组件一样可以直接拖放,然后设置好属性和添加了数据后便可显示出各种图形,

在设定数据源时候一般有两种方法;

第一种也是最简单的一种,只要从数据库中查出数据源后将数据源绑定就可以

设置一个初始AppearanceStyle 图表样式有很多种 AT.Text = "Bar_2D_Aurora_FlatCrystal_NoGlow_NoBorder";

?
SqlConnection con = new SqlConnection( "server=;database=;uid=;pwd=" );
con.Open();
SqlDataAdapter da = new SqlDataAdapter(sqlcz, con);
SqlCommandBuilder builder = new SqlCommandBuilder(da);
DataSet ds = new DataSet();
da.Fill(ds, "table" );
Chartlet1.ChartTitle.Text = "111" ;
Chartlet1.XLabels.UnitText = "222" ;
Chartlet1.YLabels.UnitText = "%" ;
Chartlet1.BindChartData(ds);
con.Close();

还有一种方式就是采用数组形式将其赋值,就以每组三个数据为例,首先初始化

ArrayList XLabel = new ArrayList();//x轴 ArrayList[] DataArray = null;

DataArray = new ArrayList[] { new ArrayList(), new ArrayList(), new ArrayList() };//定义一个数组,里面的每个数组分别是一组柱状图中的每个柱子数据

ArrayList ColorGuider = new ArrayList();//每种颜色代表的意义

Chartlet1.ChartTitle.Text = strDefaultYear + "年" + strDefaultMonth + "月" + Drpdepartment.Items[Drpdepartment.SelectedIndex].Text + "指标统计"; //图表标题 Chartlet1.XLabels.UnitText = ""; Chartlet1.YLabels.UnitText = ""; Chartlet1.InitializeData(DataArray, XLabel, ColorGuider); string yangshi = this.AT.Text; string styleimg; switch (yangshi) //选择图表的样式 { case "二维柱状图":

styleimg = "Bar_2D_Breeze_NoCrystal_Glow_NoBorder"; Chartlet1.AppearanceStyle = (FanG.Chartlet.AppearanceStyles)System.Enum.Parse(typeof(FanG.Chartlet.AppearanceStyles), styleimg, true);

break; case "三维柱状图": styleimg = "Bar_3D_Aurora_FlatCrystal_NoGlow_NoBorder "; Chartlet1.AppearanceStyle = (FanG.Chartlet.AppearanceStyles)System.Enum.Parse(typeof(FanG.Chartlet.AppearanceStyles), styleimg, true);

break; case "二维线图": styleimg = "Line_2D_Aurora_ThinSquare_NoGlow_NoBorder"; Chartlet1.AppearanceStyle = (FanG.Chartlet.AppearanceStyles)System.Enum.Parse(typeof(FanG.Chartlet.AppearanceStyles), styleimg, true);

break; case "三维线图": styleimg = "Line_3D_Aurora_GlassCrystalRound_NoGlow_NoBorder "; Chartlet1.AppearanceStyle = (FanG.Chartlet.AppearanceStyles)System.Enum.Parse(typeof(FanG.Chartlet.AppearanceStyles), styleimg, true);

break; case "二维饼图": styleimg = "Pie_2D_Breeze_NoCrystal_NoGlow_NoBorder"; Chartlet1.AppearanceStyle = (FanG.Chartlet.AppearanceStyles)System.Enum.Parse(typeof(FanG.Chartlet.AppearanceStyles), styleimg, true);

break; case "三维饼图": styleimg = "Pie_3D_Aurora_NoCrystal_NoGlow_NoBorder"; Chartlet1.AppearanceStyle = (FanG.Chartlet.AppearanceStyles)System.Enum.Parse(typeof(FanG.Chartlet.AppearanceStyles), styleimg, true);

break; case "二维栈图": styleimg = "Stack_2D_Aurora_FlatCrystal_NoGlow_NoBorder"; Chartlet1.AppearanceStyle = (FanG.Chartlet.AppearanceStyles)System.Enum.Parse(typeof(FanG.Chartlet.AppearanceStyles), styleimg, true);

break; case "三维栈图": styleimg = "Stack_3D_Breeze_NoCrystal_NoGlow_NoBorder"; Chartlet1.AppearanceStyle = (FanG.Chartlet.AppearanceStyles)System.Enum.Parse(typeof(FanG.Chartlet.AppearanceStyles), styleimg, true); break; case "二维横图": styleimg = "HBar_2D_Aurora_NoCrystal_NoGlow_NoBorder"; Chartlet1.AppearanceStyle = (FanG.Chartlet.AppearanceStyles)System.Enum.Parse(typeof(FanG.Chartlet.AppearanceStyles), styleimg, true); break; }

一个不错的画图控件, 基本属性 ———————————————— ID System.String ShowCopyright System.Boolean InflateWidth System.Int32 InflateHeight System.Int32 ShowErrorInfo System.Boolean Colorful System.Boolean AutoBarWidth System.Boolean Alpha3D System.Byte Depth3D System.Int32 Dimension FanG.Chartlet.ChartDimensions RootPath System.String ImageFolder System.String ChartType FanG.Chartlet.ChartTypes GroupSize System.Int32 MaxValueY System.Double MinValueY System.Double RoundRectangle System.Boolean RoundRadius System.Int32 LineConnectionType FanG.Chartlet.LineConnectionTypes LineConnectionRadius System.Int32 AppearanceStyle FanG.Chartlet.AppearanceStyles 复合属性 ———————————————— ChartTitle FanG.TextAttributes Text System.String Show System.Boolean Font System.Drawing.Font ForeColor System.Drawing.Color BackColor System.Drawing.Color Fill FanG.Painting ColorStyle FanG.Chartlet+ColorStyles ShiftStep System.Int32 TextureStyle System.Drawing.Drawing2D.HatchStyle Color1 System.Drawing.Color Color2 System.Drawing.Color Color3 System.Drawing.Color TextureEnable System.Boolean Stroke FanG.StokeStyle Width System.Int32 ColorStyle FanG.Chartlet+ColorStyles ShiftStep System.Int32 TextureStyle System.Drawing.Drawing2D.HatchStyle Color1 System.Drawing.Color Color2 System.Drawing.Color Color3 System.Drawing.Color TextureEnable System.Boolean Crystal FanG.CrystalAttributes Enable System.Boolean CoverFull System.Boolean Contraction System.Int32 Direction FanG.Chartlet.Direction Shadow FanG.ShadowAttributes Enable System.Boolean Radius System.Int32 Distance System.Int32 Color System.Drawing.Color Alpha System.Byte Angle System.Single Hollow System.Boolean ColorGuider FanG.Attributes Show System.Boolean Font System.Drawing.Font ForeColor System.Drawing.Color BackColor System.Drawing.Color Tips FanG.Attributes Show System.Boolean Font System.Drawing.Font ForeColor System.Drawing.Color BackColor System.Drawing.Color YLabels FanG.LabelsAttributes UnitText System.String UnitFont System.Drawing.Font Show System.Boolean Font System.Drawing.Font ForeColor System.Drawing.Color BackColor System.Drawing.Color XLabels FanG.XLabelsAttributes SampleSize System.Int32 RotateAngle System.Single UnitText System.String UnitFont System.Drawing.Font Show System.Boolean Font System.Drawing.Font ForeColor System.Drawing.Color BackColor System.Drawing.Color ———————————————— End of document
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值