MCPcopy
hub / github.com/jmcnamara/XlsxWriter / _get_labels_properties

Method _get_labels_properties

xlsxwriter/chart.py:1193–1318  ·  view source on GitHub ↗
(self, labels)

Source from the content-addressed store, hash-verified

1191 return gridline
1192
1193 def _get_labels_properties(self, labels):
1194 # Convert user labels properties to the structure required internally.
1195
1196 if not labels:
1197 return None
1198
1199 # Copy the user defined properties since they will be modified.
1200 labels = copy.deepcopy(labels)
1201
1202 # Map user defined label positions to Excel positions.
1203 position = labels.get("position")
1204
1205 if position:
1206 if position in self.label_positions:
1207 if position == self.label_position_default:
1208 labels["position"] = None
1209 else:
1210 labels["position"] = self.label_positions[position]
1211 else:
1212 warn(f"Unsupported label position '{position}' for this chart type")
1213 return None
1214
1215 # Map the user defined label separator to the Excel separator.
1216 separator = labels.get("separator")
1217 separators = {
1218 ",": ", ",
1219 ";": "; ",
1220 ".": ". ",
1221 "\n": "\n",
1222 " ": " ",
1223 }
1224
1225 if separator:
1226 if separator in separators:
1227 labels["separator"] = separators[separator]
1228 else:
1229 warn("Unsupported label separator")
1230 return None
1231
1232 # Set the font properties if present.
1233 labels["font"] = self._convert_font_args(labels.get("font"))
1234
1235 # Set the line properties for the labels.
1236 line = Shape._get_line_properties(labels)
1237
1238 # Set the fill properties for the labels.
1239 fill = Shape._get_fill_properties(labels.get("fill"))
1240
1241 # Set the pattern fill properties for the labels.
1242 pattern = Shape._get_pattern_properties(labels.get("pattern"))
1243
1244 # Set the gradient fill properties for the labels.
1245 gradient = Shape._get_gradient_properties(labels.get("gradient"))
1246
1247 # Pattern fill overrides solid fill.
1248 if pattern:
1249 self.fill = None
1250

Callers 1

add_seriesMethod · 0.95

Calls 7

_convert_font_argsMethod · 0.95
_get_data_idMethod · 0.95
getMethod · 0.80
_get_line_propertiesMethod · 0.80
_get_fill_propertiesMethod · 0.80

Tested by

no test coverage detected