ASP.NET Charting

编程入门 行业动态 更新时间:2024-10-12 16:24:51
ASP.NET Charting - 将图表作为二进制数据返回时,MapAreas为null(ASP.NET Charting - MapAreas null when returning chart as binary data)

我的目标 :返回坐标和形状,以便我可以将自己的自定义悬停文本滚动到.NET Charting图像。 如果我使用ASP.NET控件(它同时呈现图像标记和HTML <map>标记,那么这就没有问题了;但是,我在MVC世界中,所以我将图表作为二进制图像返回。这是要点:

public virtual FileStreamResult Chart() { //Set up chart Chart Chart1 = new Chart(); Chart1.RenderType = RenderType.ImageTag; Chart1.ChartAreas.Add(new ChartArea("First")); //Add some lovely data Series s = new Series(); s.Name = "Tasks"; s.Points.AddXY("Task 1", 5, 8); s.ChartArea = "First"; s.ChartType = SeriesChartType.RangeBar; //Add a tooltip - This **should** make the MapAreas collection populate. s.ToolTip = "Hello World"; Chart1.Series.Add(s); if (Chart1.MapAreas.Count == 0) CryRiver(); //Always executed. :*( //Output image as FileStreamResult //... }

问题:无论我做什么,我都无法让MapAreas集合包含任何内容。 我相信这是因为在图像实际呈现之前,坐标不会被填充。

在将图像渲染为二进制文件时,如何获取图表数据的地图区域坐标?

谢谢!

My objective: return coordinates and shapes so that I can roll my own custom hover text to a .NET Charting image. This would be no problem if I were using the ASP.NET control (which renders both an image tag and an HTML <map> tag; however, I'm in the MVC world so I'm returning the chart as a binary image. Here's the gist:

public virtual FileStreamResult Chart() { //Set up chart Chart Chart1 = new Chart(); Chart1.RenderType = RenderType.ImageTag; Chart1.ChartAreas.Add(new ChartArea("First")); //Add some lovely data Series s = new Series(); s.Name = "Tasks"; s.Points.AddXY("Task 1", 5, 8); s.ChartArea = "First"; s.ChartType = SeriesChartType.RangeBar; //Add a tooltip - This **should** make the MapAreas collection populate. s.ToolTip = "Hello World"; Chart1.Series.Add(s); if (Chart1.MapAreas.Count == 0) CryRiver(); //Always executed. :*( //Output image as FileStreamResult //... }

The Problem: No matter what I do, I cannot get the MapAreas collection to contain anything. I believe this to be because the coordinates don't get populated until the image actually renders.

How do I get at the coordinates of the map areas for the charted data when rendering an image as binary?

Thanks!

最满意答案

找到答案; 不确定它是否是最好的。

一个人必须调用Chart1.RenderControl(); 在Chart1.MapAreas填充之前。

Found an answer; not sure if it's the best one.

One must call Chart1.RenderControl(); before the Chart1.MapAreas gets populated.

更多推荐

本文发布于:2023-07-15 05:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1110767.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ASP   NET   Charting

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!