2

いくつかのグラフの作成に取り組んでいますが、グラフの左側と右側に空白が多い理由がわかりません。私は Winforms Chart、ChartArea、および Series を持っていますが、常にチャートの左右に十分なスペースがあり、無駄なスペースのように見えます。この空きスペースのサイズを縮小するには、どの設定を変更する必要がありますか? この投稿には、チャートの作成に使用するコードと、空のスペースを含むチャートのスクリーンショットを含めました。前もって感謝します。

ここに画像の説明を入力

        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;
            }
        }
4

1 に答える 1

3

InnerPlotPosition 設定で遊んでみてください。

chart1.ChartAreas[0].InnerPlotPosition.X = 0;
于 2012-10-20T04:17:56.590 に答える