UltraChart画柱状图上面显示数值

今天弄这个NetAdvantage画图表的东西,没有接触过,现在要下载图片,还要在柱状图的上面显示数值,纠结了一下午,搞定了。

这里只说下载图片和柱状图最上方加数值的问题

1、柱状图上显示数值

//第一种方法
this.UltraChartSScore.Data.ZeroAligned = true;
this.UltraChartSScore.DataSource = dt.DefaultView;
this.UltraChartSScore.DataBind();
ChartTextAppearance text = new ChartTextAppearance();
text.Column = -2;
text.Row = -2;
text.PositionFromRadius = 50;
text.VerticalAlign = System.Drawing.StringAlignment.Far;
text.ItemFormatString = "<DATA_VALUE:00.00>";
text.Visible = true;
UltraChartSScore.ColumnChart.ChartText.Add(text);
this.UltraChartSScore.TitleTop.Text = "主项S得分对比柱状图";
//第二种方法(一个一个的添加)
for (int i = 0; i < dt.Rows.Count; i++)
{
    for (int j = 0; j < 4; j++)
    {
        ChartTextAppearance text = new ChartTextAppearance();
        text.Row = i;
        text.Column = j;
        text.VerticalAlign = System.Drawing.StringAlignment.Far;
        text.ItemFormatString = "<DATA_VALUE:00.00>";
        text.Visible = true;
        chart.ColumnChart.ChartText.Add(text);
    }
}

 2、导出图片

//一定要先绑定UltraChart,如果先绑定,然后有点击图片导出,没有用的
string fulPath="xxxx";
this.UltraChartTScore.SaveTo(fulPath, System.Drawing.Imaging.ImageFormat.Jpeg);//这个是保存为图片的方法
System.IO.FileInfo file = new System.IO.FileInfo(strFileFullPath);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + strFileName);
Response.ContentType = "application/x-msdownload";
Response.WriteFile(strFileFullPath);
Response.Flush();
file.Delete();
Response.End();

 

posted @   kevin_h_wang  阅读(3635)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示