windows 如何向 ASP.NET 3.5 图表控件添加图例?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4280904/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I add a legend to an ASP.NET 3.5 chart control?
提问by Greg McNulty
Is there a way to add a legend to the chart it creates? I have created a line chart and by default it has created different colors for the different y - axis data. I would like a legend on the side the displays what data goes with which line color.
有没有办法向它创建的图表添加图例?我创建了一个折线图,默认情况下它为不同的 y 轴数据创建了不同的颜色。我想要一个侧面的图例,显示哪些数据与哪种线条颜色对应。
Thank You.
谢谢你。
回答by Phil.Wheeler
Your chart control can create a legend using the data series names simply by adding the following line:
您的图表控件只需添加以下行即可使用数据系列名称创建图例:
chart.Legends.Add(new Legend("Default") { Docking = Docking.Right});