@@ -338,9 +338,22 @@ def set_title(self, options: Optional[Dict[str, Any]] = None) -> None:
338338 self .title .data_id = data_id
339339
340340 # Set the font properties if present.
341- self .title .font = self ._convert_font_args (options .get ("name_font" ))
341+ if options .get ("font" ):
342+ self .title .font = self ._convert_font_args (options .get ("font" ))
343+ else :
344+ # For backward/axis compatibility.
345+ self .title .font = self ._convert_font_args (options .get ("name_font" ))
346+
347+ # Set the line properties.
348+ self .title .line = Shape ._get_line_properties (options )
349+
350+ # Set the fill properties.
351+ self .title .fill = Shape ._get_fill_properties (options .get ("fill" ))
342352
343- # Set the axis name layout.
353+ # Set the gradient properties.
354+ self .title .gradient = Shape ._get_gradient_properties (options .get ("gradient" ))
355+
356+ # Set the layout.
344357 self .title .layout = self ._get_layout_properties (options .get ("layout" ), True )
345358
346359 # Set the title overlay option.
@@ -2901,10 +2914,11 @@ def _write_title(self, title: ChartTitle, is_horizontal: bool = False) -> None:
29012914 self ._write_title_rich (title , is_horizontal )
29022915 elif title .has_formula ():
29032916 self ._write_title_formula (title , is_horizontal )
2917+ elif title .has_formatting ():
2918+ self ._write_title_format_only (title )
29042919
29052920 def _write_title_rich (self , title : ChartTitle , is_horizontal : bool = False ) -> None :
29062921 # Write the <c:title> element for a rich string.
2907-
29082922 self ._xml_start_tag ("c:title" )
29092923
29102924 # Write the c:tx element.
@@ -2917,13 +2931,15 @@ def _write_title_rich(self, title: ChartTitle, is_horizontal: bool = False) -> N
29172931 if title .overlay :
29182932 self ._write_overlay ()
29192933
2934+ # Write the c:spPr element.
2935+ self ._write_sp_pr (title .get_formatting ())
2936+
29202937 self ._xml_end_tag ("c:title" )
29212938
29222939 def _write_title_formula (
29232940 self , title : ChartTitle , is_horizontal : bool = False
29242941 ) -> None :
29252942 # Write the <c:title> element for a rich string.
2926-
29272943 self ._xml_start_tag ("c:title" )
29282944
29292945 # Write the c:tx element.
@@ -2936,11 +2952,30 @@ def _write_title_formula(
29362952 if title .overlay :
29372953 self ._write_overlay ()
29382954
2955+ # Write the c:spPr element.
2956+ self ._write_sp_pr (title .get_formatting ())
2957+
29392958 # Write the c:txPr element.
29402959 self ._write_tx_pr (title .font , is_horizontal )
29412960
29422961 self ._xml_end_tag ("c:title" )
29432962
2963+ def _write_title_format_only (self , title : ChartTitle ) -> None :
2964+ # Write the <c:title> element title with formatting and default name.
2965+ self ._xml_start_tag ("c:title" )
2966+
2967+ # Write the c:layout element.
2968+ self ._write_layout (title .layout , "text" )
2969+
2970+ # Write the c:overlay element.
2971+ if title .overlay :
2972+ self ._write_overlay ()
2973+
2974+ # Write the c:spPr element.
2975+ self ._write_sp_pr (title .get_formatting ())
2976+
2977+ self ._xml_end_tag ("c:title" )
2978+
29442979 def _write_tx_rich (self , title , is_horizontal , font ) -> None :
29452980 # Write the <c:tx> element.
29462981
@@ -3195,34 +3230,33 @@ def _write_symbol(self, val) -> None:
31953230
31963231 self ._xml_empty_tag ("c:symbol" , attributes )
31973232
3198- def _write_sp_pr (self , series ) -> None :
3233+ def _write_sp_pr (self , chart_format : dict ) -> None :
31993234 # Write the <c:spPr> element.
3200-
3201- if not self ._has_formatting (series ):
3235+ if not self ._has_formatting (chart_format ):
32023236 return
32033237
32043238 self ._xml_start_tag ("c:spPr" )
32053239
32063240 # Write the fill elements for solid charts such as pie and bar.
3207- if series .get ("fill" ) and series ["fill" ]["defined" ]:
3208- if "none" in series ["fill" ]:
3241+ if chart_format .get ("fill" ) and chart_format ["fill" ]["defined" ]:
3242+ if "none" in chart_format ["fill" ]:
32093243 # Write the a:noFill element.
32103244 self ._write_a_no_fill ()
32113245 else :
32123246 # Write the a:solidFill element.
3213- self ._write_a_solid_fill (series ["fill" ])
3247+ self ._write_a_solid_fill (chart_format ["fill" ])
32143248
3215- if series .get ("pattern" ):
3249+ if chart_format .get ("pattern" ):
32163250 # Write the a:gradFill element.
3217- self ._write_a_patt_fill (series ["pattern" ])
3251+ self ._write_a_patt_fill (chart_format ["pattern" ])
32183252
3219- if series .get ("gradient" ):
3253+ if chart_format .get ("gradient" ):
32203254 # Write the a:gradFill element.
3221- self ._write_a_grad_fill (series ["gradient" ])
3255+ self ._write_a_grad_fill (chart_format ["gradient" ])
32223256
32233257 # Write the a:ln element.
3224- if series .get ("line" ) and series ["line" ]["defined" ]:
3225- self ._write_a_ln (series ["line" ])
3258+ if chart_format .get ("line" ) and chart_format ["line" ]["defined" ]:
3259+ self ._write_a_ln (chart_format ["line" ])
32263260
32273261 self ._xml_end_tag ("c:spPr" )
32283262
0 commit comments