summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorZsolt Kozaroczy <[email protected]>2021-04-26 22:32:49 +0200
committerGitHub <[email protected]>2021-04-26 22:32:49 +0200
commit8d55f0d2ad3c5e4f4c6e9be1cf1e7b065fc25e49 (patch)
treeb68b0e90908246a407c450cee146a066ab1ce0ec /examples
parent6e74fb8db66695649ad0726d88dbecea2dad1722 (diff)
downloadcaxlsx-8d55f0d2ad3c5e4f4c6e9be1cf1e7b065fc25e49.tar.gz
caxlsx-8d55f0d2ad3c5e4f4c6e9be1cf1e7b065fc25e49.zip
Add option to define a series color for the BarSeries (#81)
Diffstat (limited to 'examples')
-rw-r--r--examples/README.md1
-rw-r--r--examples/chart_series_color_example.md35
-rw-r--r--examples/images/chart_series_color_example.pngbin0 -> 43955 bytes
3 files changed, 36 insertions, 0 deletions
diff --git a/examples/README.md b/examples/README.md
index f1ab1d5b..eca725dc 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -48,6 +48,7 @@ Types:
Customizations:
* [Chart colors](chart_colors_example.md)
* [Hide gridlines](hide_gridlines_in_chart_example.md)
+* [Chart series color](chart_series_example.md)
### Columns
diff --git a/examples/chart_series_color_example.md b/examples/chart_series_color_example.md
new file mode 100644
index 00000000..35d1f49e
--- /dev/null
+++ b/examples/chart_series_color_example.md
@@ -0,0 +1,35 @@
+## Description
+
+You could change the colors of the series with providing a series_color. Do not confuse it with defining colors for each datapoint in the series.
+
+## 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']
+
+ sheet.add_row ['', 'Jan.', 'Feb', 'March']
+ sheet.add_row ['Year1', 10, 20, 30]
+ sheet.add_row ['Year2', 15, 25, 35]
+
+ sheet.add_chart(Axlsx::BarChart, start_at: 'A6', end_at: 'F20') do |chart|
+ chart.barDir = :col
+ chart.bg_color = 'FFFFFF'
+ # The first series will be red, but some bars will be overwritten to blue and green
+ chart.add_series data: sheet['B3:D3'], title: sheet['A3'], labels: sheet['B2:D2'], series_color: 'FF0000', colors: ['0000FF', '00FF00']
+ # The second series will be green
+ chart.add_series data: sheet['B4:D4'], title: sheet['A4'], labels: sheet['B2:D2'], series_color: '00FF00'
+ end
+end
+
+p.serialize 'chart_series_color_example.xlsx'
+```
+
+## Output
+
+![Output](images/chart_series_color_example.png "Output")
diff --git a/examples/images/chart_series_color_example.png b/examples/images/chart_series_color_example.png
new file mode 100644
index 00000000..177dc5c2
--- /dev/null
+++ b/examples/images/chart_series_color_example.png
Binary files differ