@@ -156,6 +156,8 @@ def execute(self, context: bpy.types.Context):
156156 if self .axis_type == AxisType .CATEGORICAL :
157157 self ._setup_categorical_axis (obj , mod )
158158
159+ self ._add_labels_if_available (obj , mod )
160+
159161 modifier_utils .add_used_materials_to_object (mod , obj )
160162 return {"FINISHED" }
161163
@@ -180,12 +182,35 @@ def _setup_categorical_axis(
180182 assert is_chart (obj )
181183 data_from_obj = data .get_chart_data_info (obj )
182184 if data_from_obj is None :
183- logger .error ("No data found on the chart {obj.name}" )
185+ logger .error (f "No data found on the chart { obj .name } " )
184186 return
185187
186188 modifier_utils .set_input (mod , "Tick Count" , len (data_from_obj ["categories" ]))
187189 modifier_utils .set_input (mod , "Labels" , "," .join (data_from_obj ["categories" ]))
188190
191+ def _add_labels_if_available (
192+ self , obj : bpy .types .Object , mod : bpy .types .NodesModifier
193+ ) -> None :
194+ assert is_chart (obj )
195+ data_from_obj = data .get_chart_data_info (obj )
196+ if data_from_obj is None :
197+ logger .error (f"No data found on the chart { obj .name } " )
198+ return
199+
200+ axis_labels = data_from_obj ["axis_labels" ]
201+ if len (axis_labels ) == 0 :
202+ return
203+ if self .axis == "X" and len (axis_labels ) > 0 :
204+ modifier_utils .set_input (mod , "Axis Label Text" , axis_labels [0 ])
205+
206+ if self .axis == "Y" and len (axis_labels ) > 1 :
207+ modifier_utils .set_input (mod , "Axis Label Text" , axis_labels [1 ])
208+
209+ if self .axis == "Z" and len (axis_labels ) == 2 :
210+ modifier_utils .set_input (mod , "Axis Label Text" , axis_labels [1 ])
211+ elif len (axis_labels ) == 3 :
212+ modifier_utils .set_input (mod , "Axis Label Text" , axis_labels [2 ])
213+
189214
190215@data_vis_logging .logged_operator
191216class DV_AddDataLabels (bpy .types .Operator ):
@@ -204,27 +229,3 @@ def execute(self, context: bpy.types.Context):
204229 mod .node_group = library .load_above_data_labels ()
205230 modifier_utils .add_used_materials_to_object (mod , obj )
206231 return {"FINISHED" }
207-
208-
209- # TODO: Create a object that's in the middle of the axis and parented to the chart object
210- @data_vis_logging .logged_operator
211- class DV_AddAxisLabel (bpy .types .Operator ):
212- bl_idname = "data_vis.add_axis_label"
213- bl_label = "Add Axis Label"
214- bl_options = {"REGISTER" , "UNDO" }
215-
216- # Adds a axis label to the selected chart
217- def execute (self , context ):
218- return {"FINISHED" }
219-
220-
221- # TODO: Add heading to the chart
222- @data_vis_logging .logged_operator
223- class DV_AddHeading (bpy .types .Operator ):
224- # Adds a heading to the selected chart
225- bl_idname = "data_vis.add_heading"
226- bl_label = "Add Heading"
227- bl_options = {"REGISTER" , "UNDO" }
228-
229- def execute (self , context ):
230- return {"FINISHED" }
0 commit comments