A class for writing the Excel XLSX Bar charts.
| 14 | |
| 15 | |
| 16 | class ChartBar(chart.Chart): |
| 17 | """ |
| 18 | A class for writing the Excel XLSX Bar charts. |
| 19 | |
| 20 | |
| 21 | """ |
| 22 | |
| 23 | ########################################################################### |
| 24 | # |
| 25 | # Public API. |
| 26 | # |
| 27 | ########################################################################### |
| 28 | |
| 29 | def __init__(self, options: Optional[Dict[str, Any]] = None) -> None: |
| 30 | """ |
| 31 | Constructor. |
| 32 | |
| 33 | """ |
| 34 | super().__init__() |
| 35 | |
| 36 | if options is None: |
| 37 | options = {} |
| 38 | |
| 39 | self.subtype = options.get("subtype") |
| 40 | |
| 41 | if not self.subtype: |
| 42 | self.subtype = "clustered" |
| 43 | |
| 44 | self.cat_axis_position = "l" |
| 45 | self.val_axis_position = "b" |
| 46 | self.horiz_val_axis = 0 |
| 47 | self.horiz_cat_axis = 1 |
| 48 | self.show_crosses = False |
| 49 | |
| 50 | # Override and reset the default axis values. |
| 51 | self.x_axis["defaults"]["major_gridlines"] = {"visible": 1} |
| 52 | self.y_axis["defaults"]["major_gridlines"] = {"visible": 0} |
| 53 | |
| 54 | if self.subtype == "percent_stacked": |
| 55 | self.x_axis["defaults"]["num_format"] = "0%" |
| 56 | |
| 57 | # Set the available data label positions for this chart type. |
| 58 | self.label_position_default = "outside_end" |
| 59 | self.label_positions = { |
| 60 | "center": "ctr", |
| 61 | "inside_base": "inBase", |
| 62 | "inside_end": "inEnd", |
| 63 | "outside_end": "outEnd", |
| 64 | } |
| 65 | |
| 66 | self.set_x_axis({}) |
| 67 | self.set_y_axis({}) |
| 68 | |
| 69 | def combine(self, chart: Optional[chart.Chart] = None) -> None: |
| 70 | # pylint: disable=redefined-outer-name |
| 71 | """ |
| 72 | Create a combination chart with a secondary chart. |
| 73 |
no outgoing calls
no test coverage detected
searching dependent graphs…