
    Le                     f    d dl mZ d dlZd dlmZ d dlmZ ddlm	Z	 ddl
mZ  G d d	e	          ZdS )
    )defaultdictN)FontProperties)Table   )ElementPlot)mpl_rc_contextc                   X    e Zd ZdZ ej        ddd          Z ej        dd          Z ej        d	d
          Z	 ej        dd          Z
 ej        dd          Z ej        d edd          id          ZddgZdZ fdZd Zd Zd Zedd            Zd Zd Z xZS ) 	TablePlotz
    A TablePlot can plot both TableViews and ViewMaps which display
    as either a single static table or as an animated table
    respectively.
    g?)g        g      ?zP
        The fraction of the plot that should be empty around the
        edges.)defaultboundsdoc   z\
        The floating point precision to use when printing float
        numeric data types.)r   r      z
        The maximum allowable string length of a value shown in any
        table cell. Any strings longer than this length will be
        truncated.   zQ
        The largest allowable font size for the text in each table
        cell.   zQ
        The maximum number of Table rows before the table is
        summarized.headingboldzDejaVu Sans)weightfamilyzB
        The font style used for heading labels used for emphasis.alphasketch_paramsFc                      t                      j        |fi | | j        s|                                 | _        d S d | _        d S N)super__init__dynamic_format_tablecell_widths)selftableparams	__class__s      >lib/python3.11/site-packages/holoviews/plotting/mpl/tabular.pyr   zTablePlot.__init__0   sT    ))&)))| 	$#1133D#D    c                     t          t                    }| j        D ]0}|                     |          }||                     ||           1|S r   )r   intkeys
_get_frame_update_cell_widths)r   r   keyelements       r#   r   zTablePlot._format_table7   sX    !#&&9 	; 	;Cooc**G$$Wk::::r$   c                    |j         | j        k    }| j        dz  }t          | j        |j         g          }t          |          D ]}|}t          |j                  D ]}|r	||k    rd}	n]|r||k    r|j         | j        z
  |z   }|                    ||          }	t          |	          | j        k    r|	d | j        dz
           dz   }	t          |	          dz   ||         k    rt          |	          dz   ||<   d S N   z...r   )rowsmax_rowsminrangecolspprint_celllenmax_value_len)
r   r+   r   	summarize	half_rowsr/   rowadjusted_rowcol	cell_texts
             r#   r)   zTablePlot._update_cell_widths@   s)   L4=0	M1$	DM7<011;; 	: 	:CLW\** 
: 
: M	!1!1 %II  LS9__(/t}(Ds(J ' 3 3L# F FI9~~(:::$-.E0B10D.E$Fu$L	y>>A%C(888'*9~~'9K$
:	: 	:r$   c                 
   |j         | j        k    }| j        dz  }|r	||k    rd}n]|r||k    r|j         | j        z
  |z   }|                    ||          }t          |          | j        k    r|d | j        dz
           dz   }|S r-   )r/   r0   r4   r5   r6   )r   r+   r9   r;   r7   r8   r<   s          r#   _cell_valuezTablePlot._cell_valueS   s    L4=0	M1$	 	E	))II ;S9__|dm3c9++C55I9~~ 222%&=(:1(<&=>uD	r$   Nc                 
   | j         d         }| j        j        }|                     ||          }|| j         d<   |                                 |                    |           |                     | j        d         |          S )Naxisartist)r+   )handleshmaplast_render_tableset_axis_off	add_table_finalize_axisr'   )r   rangesaxesr+   r    s        r#   initialize_plotzTablePlot.initialize_plot`   s     |F#).""7D11!&X 	u""49R='"BBBr$   c                    | j         r+t          t                    }|                     ||           n| j        }dd| j        z  z
  }t          || j        | j        ||g          }t          |                                          }||j	        z  }|j	        | j
        k    }| j
        dz  }	t          | j
        |j	        g          }
t          |
          D ]}|}t          |j                  D ]}|r||	k    r|j	        | j
        z
  |z   }|                     |||          }| j                            |                    ||          d           }||         t%          |          z  }|rt'          |          ni } |j        ||||f|dd| |                    | j                   |                    d           |S )Ng      ?r.   )bbox)fontpropertiescenter)textlocT)r   r   r&   r)   r   border	mpl_Tablesumvaluesr/   r0   r1   r2   r3   r>   
font_typesget	cell_typefloatdictadd_cellset_fontsizemax_font_sizeauto_set_font_size)r   r+   rK   r   size_factorr    total_widthheightr7   r8   r/   r9   r:   r;   
cell_valuecellfontwidthfont_kwargss                     r#   rF   zTablePlot._render_tablen   s   < 	+%c**K$$Wk::::*KQt{]*$dk4;&1;&@ A A A+,,..//w|+L4=0	M!O	DM7<011;; 
	. 
	.CLW\** . . Hy$+L4=$@3$FL!--gsC@@
?..w/@/@c/R/RTXYY#C(5+=+==?GOd(;;;;RsC .Zh . .!,. . . .. 	4-...  &&&r$   c                     |                      ||          }| j        d                                          |                    |           || j        d<   i S )NrA   )rF   rC   removerH   )r   r*   rK   r+   rJ   styler    s          r#   update_handleszTablePlot.update_handles   sS    ""7D11X%%'''u!&X	r$   r   )__name__
__module____qualname____doc__paramNumberrS   Integerfloat_precisionr6   r^   r0   Dictr   rW   
style_opts	_has_axesr   r   r)   r>   r   rL   rF   rj   __classcell__)r"   s   @r#   r
   r
      s         U\$z @   F $emA 4      O "EM" 3   M
 "EM" 3   M u}R .   H Yf#012 12 12 %39EF F FJ ?+J I$ $ $ $ $  : : :&   C C C ^C  >      r$   r
   )collectionsr   ro   matplotlib.font_managerr   matplotlib.tabler   rT   r+   r   plotr   r
    r$   r#   <module>r|      s    # # # # # #  2 2 2 2 2 2 / / / / / /                        G G G G G G G G G Gr$   