我正在使用 C# 中的图表控件开发几个条形图,其中一个包含一系列 ~2300 个数据点。为了能够正确显示每个数据点的自定义标签,我将图表的高度扩展为 10000。但是,它现在为图表生成了相当大的页眉和页脚,如下所示:
但是,当我将图表设置为恢复正常高度 500 时,标题大小又恢复为更合理。如何手动调整标题大小?
这是我的图表属性代码:
Chart chart = new Chart();
chart.Width = 1000;
chart.Height = 10000;
chart.BackColor = Color.FromArgb(211, 223, 240);
chart.BorderlineDashStyle = ChartDashStyle.Solid;
chart.BackGradientStyle = GradientStyle.TopBottom;
chart.BorderlineWidth = 1;
chart.Palette = ChartColorPalette.Bright;
chart.BorderlineColor = Color.FromArgb(26, 59, 105);
chart.RenderType = RenderType.BinaryStreaming;
chart.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
chart.AntiAliasing = AntiAliasingStyles.All;
chart.TextAntiAliasingQuality = TextAntiAliasingQuality.Normal;
chart.Titles.Add("Hit Rate");
chart.IsSoftShadows = true;
chart.ChartAreas.Add("Left");
chart.ChartAreas["Left"].AxisX.Title = "Market Area";
chart.ChartAreas["Left"].AxisY.Title = "Hit Percentage";
更新:我已将此添加到我的代码中...
chart.ChartAreas["Left"].InnerPlotPosition.X = 5;
chart.ChartAreas["Left"].InnerPlotPosition.Y = 0f;
这在一定程度上有所帮助。此外,我发现导致问题的不是标题本身的大小。标题的高度其实很正常。相反,它是分配给实际绘图区域上方图表的所有空白空间。