Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Winforms 如何使用MS图表设置和显示饼图标题_Winforms_Visual Studio 2010_C# 4.0_Mschart - Fatal编程技术网

Winforms 如何使用MS图表设置和显示饼图标题

Winforms 如何使用MS图表设置和显示饼图标题,winforms,visual-studio-2010,c#-4.0,mschart,Winforms,Visual Studio 2010,C# 4.0,Mschart,我试图在饼图的顶部显示标题 chartArea1.AxisX.Title = "Product1"; chartArea1.AxisX.TitleFont = new Font("Arial Bold", 15, FontStyle.Bold); chartArea1.AxisX.TitleAlignment = StringAlignment.Center; 我尝试将标题添加到图表的标题集合,然后将标题分配到图表区域。但它不起作用 我还可以做些什么来

我试图在饼图的顶部显示标题

chartArea1.AxisX.Title = "Product1";                 
chartArea1.AxisX.TitleFont = new Font("Arial Bold", 15, FontStyle.Bold);    
chartArea1.AxisX.TitleAlignment = StringAlignment.Center;
我尝试将标题添加到图表的标题集合,然后将标题分配到图表区域。但它不起作用


我还可以做些什么来在饼图顶部显示标题?

类似于以下内容的操作应该可以:

Chart1.Titles.Clear()
Dim newTitle As New Title("Title Here", Docking.Top, New Font("Verdana", 12), Color.Black)
Chart1.Titles.Add(newTitle)
编辑:

为了将不同的标题应用于不同的图表区域,您需要设置标题的
docketToChartArea
属性。例如,如果我有一个包含两个图表区域的图表,则可以这样添加标题:

    Title Area1Title = new Title("Title1", Docking.Top, new Font("Verdana", 12), Color.Black);
    Title Area2Title = new Title("Title2", Docking.Top, new Font("Verdana", 12), Color.Black);
    Area1Title.DockedToChartArea = Chart1.ChartAreas[0].Name;
    Area2Title.DockedToChartArea = Chart1.ChartAreas[1].Name;
    Chart1.Titles.Add(Area1Title);
    Chart1.Titles.Add(Area2Title);

类似于以下的方法应该可以工作:

Chart1.Titles.Clear()
Dim newTitle As New Title("Title Here", Docking.Top, New Font("Verdana", 12), Color.Black)
Chart1.Titles.Add(newTitle)
编辑:

为了将不同的标题应用于不同的图表区域,您需要设置标题的
docketToChartArea
属性。例如,如果我有一个包含两个图表区域的图表,则可以这样添加标题:

    Title Area1Title = new Title("Title1", Docking.Top, new Font("Verdana", 12), Color.Black);
    Title Area2Title = new Title("Title2", Docking.Top, new Font("Verdana", 12), Color.Black);
    Area1Title.DockedToChartArea = Chart1.ChartAreas[0].Name;
    Area2Title.DockedToChartArea = Chart1.ChartAreas[1].Name;
    Chart1.Titles.Add(Area1Title);
    Chart1.Titles.Add(Area2Title);

您应该尝试使用
标题。将
方法添加到图表对象中,而不是像下面这样添加到chartArea中

yourChart.Titles.Clear();   // Unnecessary if you have already clear
Title yourTitle = new Title("Title", Docking.Top, new Font("Verdana", 12), Color.Black);
yourChart.Titles.Add(yourTitle);

您应该尝试使用
标题。将
方法添加到图表对象中,而不是像下面这样添加到chartArea中

yourChart.Titles.Clear();   // Unnecessary if you have already clear
Title yourTitle = new Title("Title", Docking.Top, new Font("Verdana", 12), Color.Black);
yourChart.Titles.Add(yourTitle);

这是以完全定制的方式添加标题的另一种方式

Title testTitle = new Title();
testTitle.text = "Total";
testTitle.Font = new Font(FontFamily.GenericSansSerif, 14F, FontStyle.Bold);
testTitle.IsDockedInsideChartArea = true;
testTitle.Docking = Docking.Left;
testTitle.TextOrientation = TextOrientation.Rotated270;
testTitle.DockedToChartArea = TrunkChart.ChartAreas[0].Name;
TestChart.Title.Add(testTitle);

干杯

这是以完全定制的方式添加标题的另一种方式

Title testTitle = new Title();
testTitle.text = "Total";
testTitle.Font = new Font(FontFamily.GenericSansSerif, 14F, FontStyle.Bold);
testTitle.IsDockedInsideChartArea = true;
testTitle.Docking = Docking.Left;
testTitle.TextOrientation = TextOrientation.Rotated270;
testTitle.DockedToChartArea = TrunkChart.ChartAreas[0].Name;
TestChart.Title.Add(testTitle);

干杯

谢谢你翻译我的VB代码。下次留下评论,我可以做一个快速编辑。将我的答案复制/粘贴为你自己的答案似乎很粗鲁。@ChrisZeh好的。那更好。如果我是你,我不会介意的。但我和你一样道歉。我不能投票支持你们,因为这个问题加上了c,所以这就像是给未来上的一课:)但我很抱歉,因为你们介意。请现在翻译,我将删除我的答案,并投票给你:)没问题,萨米,你的答案是优越的,这对我来说是一个教训,我应该尽可能清楚和正确。下一次你可能会考虑增加你的回答:“扩展克里斯所说的……”,这将有助于克服困难的感觉:-好吧,兄弟。在这种情况下,我通常不会错过参考,你们可以检查我的答案:)我将避免以后再这样做。谢谢你的态度。谢谢你翻译我的VB代码。下次留下评论,我可以做一个快速编辑。将我的答案复制/粘贴为你自己的答案似乎很粗鲁。@ChrisZeh好的。那更好。如果我是你,我不会介意的。但我和你一样道歉。我不能投票支持你们,因为这个问题加上了c,所以这就像是给未来上的一课:)但我很抱歉,因为你们介意。请现在翻译,我将删除我的答案,并投票给你:)没问题,萨米,你的答案是优越的,这对我来说是一个教训,我应该尽可能清楚和正确。下一次你可能会考虑增加你的回答:“扩展克里斯所说的……”,这将有助于克服困难的感觉:-好吧,兄弟。在这种情况下,我通常不会错过参考,你们可以检查我的答案:)我将避免以后再这样做。谢谢你的态度,谢谢。现在我得到了冠军。还有一件事,我的图表中有两个饼图(Chartarea)。我想把标题分别分配给图表区。谢谢。现在我得到了冠军。还有一件事,我的图表中有两个饼图(Chartarea)。我想分别为图表区域指定标题。