简体   繁体   English

Mschart添加自定义文本框

[英]Mschart Add custom Textbox

Is it possible to add a custom textbox to a mschart? 是否可以将自定义文本框添加到mschart? Example I have a graph, the axislabels, the legend to the right. 示例I有一个图表,轴标签,右边的图例。 I want to add a custom text(box) to the chartarea with a textbox with an explaning text about the graph. 我想在图表区域添加一个自定义文本(框),文本框带有关于图形的解释文本。 The reason is because its so easy to save an image of the chart so I want the explanation to be integrated in the picture. 原因是因为它很容易保存图表的图像所以我希望将解释集成到图片中。

Regards //JH 问候// JH

    Chart = CreateChartTemplate();
    Title area1Title = new Title(chartTitle, Docking.Top, new Font("Verdana", 12), Color.Black);
    area1Title.IsDockedInsideChartArea = false;
    area1Title.Docking = Docking.Top;
    Chart.Titles.Add(area1Title);

You can use this to set a title on top of the graph outside of the plotted area, you can also change options if you would like it inside chart area. 您可以使用此选项在绘制区域之外的图形顶部设置标题,如果您希望在图表区域内使用它,也可以更改选项。

area1Title.DockedToChartArea

this will allow you to specify an area of the chart to fix it to. 这将允许您指定图表的区域以将其修复。 ie top left right etc. 即左上角等

As suggested by @rockyashkumar, you could use chart title to explain the figure. 正如@rockyashkumar所建议的那样,你可以用图表标题来解释这个数字。

You can do that using chart.Titles property, either through visual studio designer or programmatically eg: 您可以使用chart.Titles属性,通过visual studio designer或以编程方式执行此操作,例如:

var title = this.chart1.Titles.Add("The title text");
// set other properties of the title (if necessary)
title.Alignment = ContentAlignment.MiddleCenter;
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM