Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/xlsxwriter/chart_radar.py: 17%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

36 statements  

1############################################################################### 

2# 

3# ChartRadar - A class for writing the Excel XLSX Radar charts. 

4# 

5# SPDX-License-Identifier: BSD-2-Clause 

6# 

7# Copyright (c) 2013-2025, John McNamara, jmcnamara@cpan.org 

8# 

9 

10from . import chart 

11 

12 

13class ChartRadar(chart.Chart): 

14 """ 

15 A class for writing the Excel XLSX Radar charts. 

16 

17 

18 """ 

19 

20 ########################################################################### 

21 # 

22 # Public API. 

23 # 

24 ########################################################################### 

25 

26 def __init__(self, options=None): 

27 """ 

28 Constructor. 

29 

30 """ 

31 super().__init__() 

32 

33 if options is None: 

34 options = {} 

35 

36 self.subtype = options.get("subtype") 

37 

38 if not self.subtype: 

39 self.subtype = "marker" 

40 self.default_marker = {"type": "none"} 

41 

42 # Override and reset the default axis values. 

43 self.x_axis["defaults"]["major_gridlines"] = {"visible": 1} 

44 self.set_x_axis({}) 

45 

46 # Set the available data label positions for this chart type. 

47 self.label_position_default = "center" 

48 self.label_positions = {"center": "ctr"} 

49 

50 # Hardcode major_tick_mark for now until there is an accessor. 

51 self.y_axis["major_tick_mark"] = "cross" 

52 

53 ########################################################################### 

54 # 

55 # Private API. 

56 # 

57 ########################################################################### 

58 

59 def _write_chart_type(self, args): 

60 # Write the c:radarChart element. 

61 self._write_radar_chart(args) 

62 

63 ########################################################################### 

64 # 

65 # XML methods. 

66 # 

67 ########################################################################### 

68 

69 def _write_radar_chart(self, args): 

70 # Write the <c:radarChart> element. 

71 

72 if args["primary_axes"]: 

73 series = self._get_primary_axes_series() 

74 else: 

75 series = self._get_secondary_axes_series() 

76 

77 if not series: 

78 return 

79 

80 self._xml_start_tag("c:radarChart") 

81 

82 # Write the c:radarStyle element. 

83 self._write_radar_style() 

84 

85 # Write the series elements. 

86 for data in series: 

87 self._write_ser(data) 

88 

89 # Write the c:axId elements 

90 self._write_axis_ids(args) 

91 

92 self._xml_end_tag("c:radarChart") 

93 

94 def _write_radar_style(self): 

95 # Write the <c:radarStyle> element. 

96 val = "marker" 

97 

98 if self.subtype == "filled": 

99 val = "filled" 

100 

101 attributes = [("val", val)] 

102 

103 self._xml_empty_tag("c:radarStyle", attributes)