Bar Chart

The bar chart is a fundamental plot type, used for both column and bar charts by specifying the bar direction. It is also used for the clustered, stacked, and stacked 100% varieties by specifying grouping and overlap.

Gap Width

A gap appears between the bar or clustered bars for each category on a bar chart. The default width for this gap is 150% of the bar width. It can be set between 0 and 500% of the bar width. In the MS API this is set using the property ChartGroup.GapWidth.

Proposed protocol:

>>> assert isinstance(bar_plot, BarPlot)
>>> bar_plot.gap_width
150
>>> bar_plot.gap_width = 300
>>> bar_plot.gap_width
300
>>> bar_plot.gap_width = 700
ValueError: gap width must be in range 0-500 (percent)

Overlap

In a bar chart having two or more series, the bars for each category are clustered together for ready comparison. By default, these bars are directly adjacent to each other, visually “touching”.

The bars can be made to overlap each other or have a space between them using the overlap property. Its values range between -100 and 100, representing the percentage of the bar width by which to overlap adjacent bars. A setting of -100 creates a gap of a full bar width and a setting of 100 causes all the bars in a category to be superimposed. The default value is 0.

Proposed protocol:

>>> bar_plot = chart.plots[0]
>>> assert isinstance(bar_plot, BarPlot)
>>> bar_plot.overlap
0
>>> bar_plot.overlap = -50
>>> bar_plot.overlap
-50
>>> bar_plot.overlap = 200
ValueError: overlap must be in range -100..100 (percent)

XML specimens

Minimal working XML for a single-series column plot. Note this does not reference values in a spreadsheet.:

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<c:chartSpace xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"
              xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
              xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
  <c:chart>
    <c:plotArea>
      <c:barChart>
        <c:barDir val="col"/>
        <c:grouping val="clustered"/>
        <c:ser>
          <c:idx val="0"/>
          <c:order val="0"/>
          <c:cat>
            <c:strLit>
              <c:ptCount val="1"/>
              <c:pt idx="0">
                <c:v>Foo</c:v>
              </c:pt>
            </c:strLit>
          </c:cat>
          <c:val>
            <c:numLit>
              <c:ptCount val="1"/>
              <c:pt idx="0">
                <c:v>4.3</c:v>
              </c:pt>
            </c:numLit>
          </c:val>
        </c:ser>
        <c:dLbls>
          <c:showLegendKey val="0"/>
          <c:showVal val="0"/>
          <c:showCatName val="0"/>
          <c:showSerName val="0"/>
          <c:showPercent val="0"/>
          <c:showBubbleSize val="0"/>
        </c:dLbls>
        <c:gapWidth val="300"/>
        <c:overlap val="-20"/>
        <c:axId val="-2068027336"/>
        <c:axId val="-2113994440"/>
      </c:barChart>
      <c:catAx>
        <c:axId val="-2068027336"/>
        <c:scaling/>
        <c:delete val="0"/>
        <c:axPos val="b"/>
        <c:crossAx val="-2113994440"/>
      </c:catAx>
      <c:valAx>
        <c:axId val="-2113994440"/>
        <c:scaling/>
        <c:delete val="0"/>
        <c:axPos val="l"/>
        <c:crossAx val="-2068027336"/>
      </c:valAx>
    </c:plotArea>
  </c:chart>
</c:chartSpace>