gpt4 book ai didi

c# - 为什么 MSChart 不填满整个图表区域?

转载 作者:太空宇宙 更新时间:2023-11-03 11:14:46 27 4
gpt4 key购买 nike

我正在制作几个图表,但我不明白为什么图表的左右两侧有这么多空白区域。我有一个 Winforms 图表、ChartArea 和系列,图表的左侧和右侧总是有一英寸,看起来像是浪费空间。我需要更改什么设置以减小此空白空间的大小?我在这篇文章中包含了带有空白区域的图表截图以及我用来创建它的代码。提前致谢。

enter image description here

        if (listBoxCharts.SelectedItems.Count == 1)
{
switch (listBoxCharts.SelectedItem.ToString().Trim())
{
case "Incomplete Work Orders By Status":
ChartArea chartArea = new ChartArea();
Series series = new Series();
Title title = new Title();

chartArea.Area3DStyle.Enable3D = true;
chartArea.Area3DStyle.LightStyle = LightStyle.Realistic;
chartArea.Area3DStyle.Rotation = 10;
chartArea.Area3DStyle.WallWidth = 3;
chartArea.BorderColor = Color.Transparent;
chartArea.Name = "IncompleteWorkOrdersByStatus_ChartArea";

// Fix this hack
ChartContainer.ChartAreas.Clear();
this.ChartContainer.ChartAreas.Add(chartArea);
this.ChartContainer.Dock = DockStyle.Fill;
this.ChartContainer.Location = new Point(2, 21);
this.ChartContainer.Name = "Charts";
this.ChartContainer.PaletteCustomColors = new Color[] { Color.LemonChiffon };

series.ChartArea = "IncompleteWorkOrdersByStatus_ChartArea";
series.ChartType = SeriesChartType.StackedColumn;
series.CustomProperties = "DrawingStyle=Cylinder";
series.EmptyPointStyle.BorderDashStyle = ChartDashStyle.NotSet;
series.IsXValueIndexed = true;
series.Name = "IncompleteWorkOrdersByStatus_Series";

List<WorkOrder> incompleteWorkOrders = woDao.getIncompleteWorkOrders();

var uniqueStatuses = (
from statuses in incompleteWorkOrders
select statuses.fkOrderStatus).Distinct().ToList();

int xVal = 1;
foreach (var status in uniqueStatuses)
{
var count = (
from wo in incompleteWorkOrders
where wo.fkOrderStatus == status
select wo).Count();

DataPoint dPoint = new DataPoint(xVal, count);
if (status == null)
{
dPoint.AxisLabel = "No Status";
}
else
{
dPoint.AxisLabel = status.codedesc;
}

dPoint.ToolTip = count + " " + dPoint.AxisLabel;

series.Points.Add(dPoint);

xVal++;
}

this.ChartContainer.Series.Clear();
this.ChartContainer.Series.Add(series);

title.DockedToChartArea = "IncompleteWorkOrdersByStatus_ChartArea";
title.IsDockedInsideChartArea = false;
title.Name = "IncompleteWorkOrdersByStatus_Title";
title.Text = "Incomplete Work Orders By Status";

this.ChartContainer.Titles.Clear();
this.ChartContainer.Titles.Add(title);
break;

default:
break;
}
}

最佳答案

尝试使用 InnerPlotPosition 设置:

chart1.ChartAreas[0].InnerPlotPosition.X = 0;

关于c# - 为什么 MSChart 不填满整个图表区域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12984852/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com