Chart的用法

chuyige 2010-05-17 09:51:19
我已在VS2008里安装了Chart控件。但是不会用,请给我一份具体用法好吗?谢谢。
...全文
267 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhulong1111 2010-05-17
  • 打赏
  • 举报
回复
str = @"select shi,count(shi) as num from sdzjbxx group by shi ";
DataTable dt = CheckSys.DAO.NHibernate.SqlHelper.ExecuteDataset(CheckSys.DAO.NHibernate.SqlHelper.ConnectionString, CommandType.Text, str).Tables[0];
//ShowChart();
ShowData show = new ShowData();
show.Title = "广东省各市电站统计";
show.XTitle = "地区";
show.YTitle = "电站个数(宗)";
show.PicHight = 400;
show.PicWidth = 700;
show.SeriesName = "电站统计";
show.PhaysicalImagePath = "../ChartImg";
show.DataSource = dt;
show.CreateColumn(this.Chart1);





public class ShowData
{

#region 属性
private string _phaysicalimagepath;//图片存放路径
private string _title; //图片标题
private string _xtitle;//图片x座标名称
private string _ytitle;//图片y座标名称
private string _seriesname;//图例名称
private int _picwidth;//图片宽度
private int _pichight;//图片高度
private DataTable _dt;//图片数据源

/**/
/// <summary>
/// 图片存放路径
/// </summary>
public string PhaysicalImagePath
{
set { _phaysicalimagepath = value; }
get { return _phaysicalimagepath; }
}
/**/
/// <summary>
/// 图片标题
/// </summary>
public string Title
{
set { _title = value; }
get { return _title; }
}
/**/
/// <summary>
/// 图片标题
/// </summary>
public string XTitle
{
set { _xtitle = value; }
get { return _xtitle; }
}
/**/
/// <summary>
/// 图片标题
/// </summary>
public string YTitle
{
set { _ytitle = value; }
get { return _ytitle; }
}

/**/
/// <summary>
/// 图例名称
/// </summary>
public string SeriesName
{
set { _seriesname = value; }
get { return _seriesname; }
}
/**/
/// <summary>
/// 图片宽度
/// </summary>
public int PicWidth
{
set { _picwidth = value; }
get { return _picwidth; }
}
/**/
/// <summary>
/// 图片高度
/// </summary>
public int PicHight
{
set { _pichight = value; }
get { return _pichight; }
}
/**/
/// <summary>
/// 图片数据源
/// </summary>
public DataTable DataSource
{
set { _dt = value; }
get { return _dt; }
}
#endregion

#region 构造函数
public ShowData()
{
//
// TODO: 在此处添加构造函数逻辑
//
}

public ShowData(string PhaysicalImagePath, string Title, string XTitle, string YTitle, string SeriesName)
{
_phaysicalimagepath = PhaysicalImagePath;
_title = Title;
_xtitle = XTitle;
_ytitle = YTitle;
_seriesname = SeriesName;
}
#endregion

#region 输出柱形图
/**/
/// <summary>
/// 柱形图
/// </summary>
/// <returns></returns>
public void CreateColumn(dotnetCHARTING.Chart chart)
{
chart.Title = this._title;
chart.XAxis.Label.Text = this._xtitle;
chart.YAxis.Label.Text = this._ytitle;
chart.TempDirectory = this._phaysicalimagepath;
chart.Width = this._picwidth;
chart.Height = this._pichight;
chart.Type = ChartType.Combo;
chart.Series.Type = SeriesType.Cylinder;
chart.Series.Name = this._seriesname;
chart.Series.Data = this._dt;
chart.SeriesCollection.Add();
chart.DefaultSeries.DefaultElement.ShowValue = true;
chart.ShadingEffect = true;
chart.Use3D = true;
//chart.TitleBox.Position = TitleBoxPosition.FullWithLegend;
//chart.TitleBox.Position = TitleBoxPosition.FullWithLegend;


chart.SeriesCollection[0].DefaultElement.Color = Color.Blue;
chart.SeriesCollection[0].DefaultElement.Color = Color.FromArgb(49, 255, 49);

chart.Series.DefaultElement.ShowValue = true;
}

#endregion


wlccie 2010-05-17
  • 打赏
  • 举报
回复
挺难...
since_net_lyc 2010-05-17
  • 打赏
  • 举报
回复
http://www.51aspx.com/CV/MSChartControlsSamples/
koukoujiayi 2010-05-17
  • 打赏
  • 举报
回复
下载MSChart的配套的Demo----WebSamples,
其中例子非常详尽,无须视频教程,
也可能不太难吧,好像没看到过有此类的视频!!
chuyige 2010-05-17
  • 打赏
  • 举报
回复
我想要视频教程。

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧