diff options
| author | Zsolt Kozaroczy <[email protected]> | 2021-07-24 00:31:54 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-07-24 00:31:54 +0200 |
| commit | 158942c16b249a269e77633dd261b87787d191af (patch) | |
| tree | bca8bcd68530a6f67115080e4295303960963a12 /examples | |
| parent | 187461e2a653e53c34171cc894e10c3dcfced04d (diff) | |
| download | caxlsx-158942c16b249a269e77633dd261b87787d191af.tar.gz caxlsx-158942c16b249a269e77633dd261b87787d191af.zip | |
Add overlap to bar charts (#107)
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/README.md | 1 | ||||
| -rw-r--r-- | examples/images/stacked_bar_chart_example.png | bin | 0 -> 28959 bytes | |||
| -rw-r--r-- | examples/stacked_bar_chart_example.md | 35 |
3 files changed, 36 insertions, 0 deletions
diff --git a/examples/README.md b/examples/README.md index eca725dc..5f53199e 100644 --- a/examples/README.md +++ b/examples/README.md @@ -44,6 +44,7 @@ Types: * [Line chart (3D)](3d_line_chart_example.md) * [Pie chart (3D)](3d_pie_chart_example.md) * [Scatter chart](scatter_chart_example.md) +* [Stacked bar chart](stacked_bar_chart_example.md) Customizations: * [Chart colors](chart_colors_example.md) diff --git a/examples/images/stacked_bar_chart_example.png b/examples/images/stacked_bar_chart_example.png Binary files differnew file mode 100644 index 00000000..da046983 --- /dev/null +++ b/examples/images/stacked_bar_chart_example.png diff --git a/examples/stacked_bar_chart_example.md b/examples/stacked_bar_chart_example.md new file mode 100644 index 00000000..3fbd2425 --- /dev/null +++ b/examples/stacked_bar_chart_example.md @@ -0,0 +1,35 @@ +## Description + +Stacked bar chart example + +## Code + +```ruby +require 'axlsx' + +p = Axlsx::Package.new +wb = p.workbook + +wb.add_worksheet(name: 'Bar Chart') do |sheet| + sheet.add_row ['A Simple Bar Chart', 'X', 'Y'] + + sheet.add_row ['A', 3, 4] + sheet.add_row ['B', 10, 6] + sheet.add_row ['C', 7, 2] + + sheet.add_chart(Axlsx::BarChart, start_at: 'A6', end_at: 'F20') do |chart| + chart.add_series data: sheet['B2:B4'], labels: sheet['A2:A4'], title: sheet['B1'] + chart.add_series data: sheet['C2:C4'], labels: sheet['A2:A4'], title: sheet['C1'] + + chart.bar_dir = :col + chart.overlap = 100 + chart.grouping = :percentStacked + end +end + +p.serialize 'stacked_bar_chart_example.xlsx' +``` + +## Output + + |
