@@ -201,8 +201,6 @@ def collect_agent_data(
201201
202202 return final_data
203203
204-
205-
206204 def draw_agents (
207205 self , arguments , chart_width : int = 450 , chart_height : int = 350 , ** kwargs
208206 ):
@@ -219,7 +217,8 @@ def draw_agents(
219217 "size" : arguments ["size" ][i ],
220218 "shape" : arguments ["shape" ][i ],
221219 "opacity" : arguments ["opacity" ][i ],
222- "strokeWidth" : arguments ["strokeWidth" ][i ] / 10 , # Scale for continuous domain
220+ "strokeWidth" : arguments ["strokeWidth" ][i ]
221+ / 10 , # Scale for continuous domain
223222 "original_color" : arguments ["color" ][i ],
224223 }
225224 # Add tooltip data if available
@@ -230,7 +229,11 @@ def draw_agents(
230229 # Determine fill and stroke colors
231230 if arguments ["filled" ][i ]:
232231 record ["viz_fill_color" ] = arguments ["color" ][i ]
233- record ["viz_stroke_color" ] = arguments ["stroke" ][i ] if isinstance (arguments ["stroke" ][i ], str ) else None
232+ record ["viz_stroke_color" ] = (
233+ arguments ["stroke" ][i ]
234+ if isinstance (arguments ["stroke" ][i ], str )
235+ else None
236+ )
234237 else :
235238 record ["viz_fill_color" ] = None
236239 record ["viz_stroke_color" ] = arguments ["color" ][i ]
@@ -240,19 +243,18 @@ def draw_agents(
240243 df = pd .DataFrame (records )
241244
242245 # Ensure all columns that should be numeric are, handling potential Nones
243- numeric_cols = ['x' , 'y' , ' size' , ' opacity' , ' strokeWidth' , ' original_color' ]
246+ numeric_cols = ["x" , "y" , " size" , " opacity" , " strokeWidth" , " original_color" ]
244247 for col in numeric_cols :
245248 if col in df .columns :
246- df [col ] = pd .to_numeric (df [col ], errors = 'coerce' )
247-
249+ df [col ] = pd .to_numeric (df [col ], errors = "coerce" )
248250
249251 # Get tooltip keys from the first valid record
250252 tooltip_list = ["x" , "y" ]
251253 # This is the corrected line:
252254 if any (t is not None for t in arguments ["tooltip" ]):
253- first_valid_tooltip = next ((t for t in arguments ["tooltip" ] if t ), None )
254- if first_valid_tooltip :
255- tooltip_list .extend (first_valid_tooltip .keys ())
255+ first_valid_tooltip = next ((t for t in arguments ["tooltip" ] if t ), None )
256+ if first_valid_tooltip :
257+ tooltip_list .extend (first_valid_tooltip .keys ())
256258
257259 # Extract additional parameters from kwargs
258260 title = kwargs .pop ("title" , "" )
@@ -316,10 +318,16 @@ def draw_agents(
316318 ),
317319 title = "Shape" ,
318320 ),
319- opacity = alt .Opacity ("opacity:Q" , title = "Opacity" , scale = alt .Scale (domain = [0 , 1 ], range = [0 , 1 ])),
321+ opacity = alt .Opacity (
322+ "opacity:Q" ,
323+ title = "Opacity" ,
324+ scale = alt .Scale (domain = [0 , 1 ], range = [0 , 1 ]),
325+ ),
320326 fill = fill_encoding ,
321327 stroke = alt .Stroke ("viz_stroke_color:N" , scale = None ),
322- strokeWidth = alt .StrokeWidth ("strokeWidth:Q" , scale = alt .Scale (domain = [0 , 1 ])),
328+ strokeWidth = alt .StrokeWidth (
329+ "strokeWidth:Q" , scale = alt .Scale (domain = [0 , 1 ])
330+ ),
323331 tooltip = tooltip_list ,
324332 )
325333 .properties (title = title , width = chart_width , height = chart_height )
@@ -431,4 +439,4 @@ def draw_propertylayer(
431439 main_charts .append (current_chart )
432440
433441 base = alt .layer (* main_charts ).resolve_scale (color = "independent" )
434- return base
442+ return base
0 commit comments