我的目标 :返回坐标和形状,以便我可以将自己的自定义悬停文本滚动到.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.
更多推荐
发布评论