
    g@                     l    d dl Z d dlZd dlZddlmZ ddlmZ  G d de      Z G d d	e      Z	dd
Z
dZy)    N   )Renderer   )Exporterc                   2    e Zd Zd Zd ZddZddZ	 ddZy)	VegaRendererc                     || _         t        |d   |d   z        | _        t        |d   |d   z        | _        g | _        g | _        g | _        g | _        y )Nfigwidthdpi	figheight)propsintr
   r   datascalesaxesmarks)selffigr   s      t/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/plotly/matplotlylib/mplexporter/renderers/vega_renderer.pyopen_figurezVegaRenderer.open_figure	   sY    
E*-e<=U;/%,>?		
    c                     t        | j                        dkD  rt        j                  d       t	        ddd      t	        ddd      g| _        t	        d|d   dd	
      t	        d|d   dd
      g| _        y )Nr   zmultiple axes not yet supportedx
   )typescaleticksyxlimlinearwidth)namedomainr   rangeylimheight)lenr   warningswarndictr   )r   axr   s      r   	open_axeszVegaRenderer.open_axes   s}    tyy>AMM;<cB/cB/
	
 V}	 V}	
r   Nc                    |dk7  rt        j                  d       dj                  t        | j                        dz         }| j                  j                  ||D cg c]  }t        |d   |d          c}d       | j                  j                  dd|id	d
diddddddd
|d   id
|d   id
|d   idid       y c c}w )Nr   .Only data coordinates supported. Skipping thistable{0:03d}r   r   r   r   r"   valueslineentervaluemonotoner   data.xr   fieldr   data.ycoloralpha	linewidth)interpolater   r   strokestrokeOpacitystrokeWidthr   from
propertiesr(   r)   formatr'   r   appendr*   r   r   r   coordinatesstylelabelmplobjdatanameds           r   	draw_linezVegaRenderer.draw_line(   s    & MMJK!((TYY!);< 			)M1$11*>)MN	
 	

*(/'<'*X>'*X>#*E'N";*15>)B(/{1C'D		
 *Ns   C
c                    |dk7  rt        j                  d       dj                  t        | j                        dz         }| j                  j                  ||D cg c]  }t        |d   |d          c}d       | j                  j                  dd|id	d
diddddddd
|d   id
|d   id
|d   id
|d   id
|d   idid       y c c}w )Nr   r.   r/   r   r   r0   r1   symbolr4   r5   r6   r   r7   r8   r   r:   	facecolorr<   	edgecolor	edgewidth)r>   r   r   fillfillOpacityr?   r@   rA   rB   rE   rH   s           r   draw_markerszVegaRenderer.draw_markersB   s    & MMJK!((TYY!);< 			)M1$11*>)MN	
 	

 *(/'<'*X>'*X>!(%*< =(/w'@#*E+,>"?*15>)B(/{1C'D		
 *Ns   C
c                 d    |dk(  r|| j                   d   d<   y |dk(  r|| j                   d   d<   y y )Nxlabelr   titleylabelr   )r   )r   textpositionrI   rJ   	text_typerL   s          r   	draw_textzVegaRenderer.draw_text^   s=      $(DIIaL!("$(DIIaL! #r   N)NN)__name__
__module____qualname__r   r,   rO   rW   r_    r   r   r   r      s"    
,
4
: JN)r   r   c                       e Zd Zd Zd Zd Zy)VegaHTMLc                     t        |j                  |j                  |j                  |j                  |j
                  |j                        | _        y )N)r!   r&   r   r   r   r   )r*   r
   r   r   r   r   r   specification)r   renderers     r   __init__zVegaHTML.__init__h   s=    !##%%??..
r   c                     t        j                  dd      }d|z  }|dz  }|t        t        j                  | j
                        |fz  z  }|dz  }|S )z*Build the HTML representation for IPython.r   i   z<div id="vis%d"></div>z	<script>
z
</script>
)randomrandintVEGA_TEMPLATEjsondumpsrh   )r   idhtmls      r   rr   zVegaHTML.htmlr   sX    ^^Au%'",D,>,>!? DDDr   c                 "    | j                         S r`   )rr   )r   s    r   _repr_html_zVegaHTML._repr_html_{   s    yy{r   N)ra   rb   rc   rj   rr   rt   rd   r   r   rf   rf   g   s    
r   rf   c                     t               }t        |      j                  |        t        |      }|r|S |j	                         S )zConvert a matplotlib figure to vega dictionary

    if notebook=True, then return an object which will display in a notebook
    otherwise, return an HTML string.
    )r   r   runrf   rr   )r   notebookri   	vega_htmls       r   fig_to_vegary      s>     ~HX3"I~~r   a:  
( function() {
  var _do_plot = function() {
    if ( (typeof vg == 'undefined') && (typeof IPython != 'undefined')) {
      $([IPython.events]).on("vega_loaded.vincent", _do_plot);
      return;
    }
    vg.parse.spec(%s, function(chart) {
      chart({el: "#vis%d"}).update();
    });
  };
  _do_plot();
})();
)F)r(   ro   rl   baser   exporterr   r   objectrf   ry   rn   rd   r   r   <module>r}      s;        \)8 \)~v 0 r   