用OWC绘图时,如何添加各点的数值标签。

aspxcss 2007-07-29 09:07:00
以下代码在绘图时,可以绘制出各个节点,如何给各节点添加上数值标签。


用OWC绘图的代码为:




//存放月
string[] MonNum = new string[7];
//存放数据
string[] MonCount = new string[7];
//为数组赋值
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
MonNum[i] = ds.Tables[0].Rows[i][0].ToString();
MonCount[i] = ds.Tables[0].Rows[i][1].ToString();
}
//为x轴指定特定字符串,以便显示数据
string strXdata = String.Empty;
foreach (string strData in MonNum)
{
strXdata += strData + "\t";
}
string strYdata = String.Empty;
//为y轴指定特定的字符串,以便与x轴相对应
foreach (string strValue in MonCount)
{
strYdata += strValue + "\t";
}

//创建ChartSpace对象来放置图表
ChartSpace laySpace = new ChartSpaceClass();

//在ChartSpace对象中添加图表
ChChart InsertChart = laySpace.Charts.Add(0);

//指定绘制图表的类型。类型可以通过OWC.ChartChartTypeEnum枚举值得到
InsertChart.Type = ChartChartTypeEnum.chChartTypeLine;//折线图
//InsertChart.Type = ChartChartTypeEnum.chChartTypeArea;//面积图
//InsertChart.Type = ChartChartTypeEnum.chChartTypeBarClustered;//条形图
//InsertChart.Type = ChartChartTypeEnum.chChartTypeColumnClustered;//柱形图




//指定图表是否需要图例标注
InsertChart.HasLegend = false;



InsertChart.HasTitle = true;//为图表添加标题
InsertChart.Title.Caption = "2007年1-7月寿阳申报率变动情况";//标题名称

//为x,y轴添加图示说明
InsertChart.Axes[0].HasTitle = true;
InsertChart.Axes[0].Title.Caption = "月份";//月份
InsertChart.Axes[1].HasTitle = true;
InsertChart.Axes[1].Title.Caption = "比率";


//添加一个series系列
InsertChart.SeriesCollection.Add(0);

//给定series系列的名字
InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimSeriesNames, +(int)ChartSpecialDataSourcesEnum.chDataLiteral, strSeriesName);


//给定分类
InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimCategories, +(int)ChartSpecialDataSourcesEnum.chDataLiteral, strXdata);

//给定值
InsertChart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strYdata);
//输出文件.
string strAbsolutePath = (Server.MapPath(".")) + "\\ShowData.gif";
laySpace.ExportPicture(strAbsolutePath, "GIF", 700, 300);

//创建GIF文件的相对路径.
string strRelativePath = "./ShowData.gif";

//把图片添加到placeholder中,并在页面上显示
string strImageTag = "<IMG SRC='" + strRelativePath + "'/>";
this.PlaceHolder1.Controls.Add(new LiteralControl(strImageTag));
...全文
247 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
aspxcss 2007-07-31
  • 打赏
  • 举报
回复
高手,现身吧.
aspxcss 2007-07-31
  • 打赏
  • 举报
回复
着急呀。请高手指点一下。
huacha 2007-07-30
  • 打赏
  • 举报
回复
wsChart4.6可以做到
aspxcss 2007-07-30
  • 打赏
  • 举报
回复
顶一下.着急呀.
aspxcss 2007-07-30
  • 打赏
  • 举报
回复
试了一下也没弄好.我已经把我的代码贴在上面了.
应该加在代码的哪个位置上呀?
aspxcss 2007-07-30
  • 打赏
  • 举报
回复
应该可以实现吧.
我想应该是把某一个属性设为true即可,但是就是找不到啊.
请高手指点.
kofkyo 2007-07-30
  • 打赏
  • 举报
回复
set dl=oChart.SeriesCollection(j-1).DataLabelsCollection.add
dl.Hasvalue=true
kofkyo 2007-07-30
  • 打赏
  • 举报
回复
设置某一些列数据的 hasvalue,应该没有记错吧
晚上回家才有以前的代码
yuelailiu 2007-07-29
  • 打赏
  • 举报
回复
收藏,估计无法实现。ajax?
honey52570 2007-07-29
  • 打赏
  • 举报
回复
不会

帮顶

62,046

社区成员

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

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

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

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