diff options
Diffstat (limited to 'examples/chart_series_color_example.md')
| -rw-r--r-- | examples/chart_series_color_example.md | 35 |
1 files changed, 35 insertions, 0 deletions
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 + + |
