2

I am working on creating a couple of charts and I cannot figure out why there is so much empty space on the left and right side of the chart. I have a Winforms Chart, ChartArea, and Series and there is always a good inch to the left and right side of the chart that seems like wasted space. What setting do I need to change to reduce the size of this empty space? I have included a screenshot of the chart with empty space with this post as well as the code that I use to create it. Thanks in advance.

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;
            }
        }
Grasshopper
  • 4,717
  • 9
  • 36
  • 62

1 Answers1

3

Try playing with the InnerPlotPosition settings:

chart1.ChartAreas[0].InnerPlotPosition.X = 0;
Steve Wellens
  • 20,506
  • 2
  • 28
  • 69