
    eS                     P   d dl Z  e j        d            e j        d           d dlZd dlmZ d dlmZ	 d dl
mZ d dlmZ d dlmZmZ e j        j        Zde	j        _        e j        d             Ze j        d             Ze j        d	             Zd
 Zd Zd Zd Zd Zd Zd Z dS )    N
playwrightplotly)expect)Plotly)serve_component
wait_untilc                  f    t          j        ddgddgd          } t          | gddid	          }|S )
Nr            Test)xyuidwidthi^  datalayout)goScatterr   )traceplot_2ds     ?lib/python3.11/site-packages/panel/tests/ui/pane/test_plotly.pyplotly_2d_plotr      s@    J!QAq6v666Eug'3@@AAGN    c                      t          j        ddd          } t          j        ddd          }t          j        | |          \  }}t          j        |dz
  dz   |dz  z
            |dz  |dz  z   |dz  z
  t          j        |dz  |dz  z              z  z
  }t	          j        |	          }d
}t	          j        |dddt          dddd                    }t          |g|          }t          |dd          }	|	|fS )Ng      g      @d   r
   r   r         )zzPlotly 3D PlotFi  2   )tbrl)titleautosizer   heightmarginr   r   r(   )	nplinspacemeshgridexpr   SurfaceLayoutdictr   )
xxyyr   r   r    surfacer&   r   figplot_3ds
             r   plotly_3d_plotr7      s   	T3	$	$B	T3	$	$B;r2DAq
Q1}qAv%&&!q&16/AE*ARVaSTfWX\]W]oL^E_E_)__Aj1oooGEYbB"+++  F WIf
-
-
-CSC000GE>r   c            
          t          t          j                            ddd                              t          j                  ddddddddd	d
          } t          | dd          S )Nr      )      r   )sizeimage)r    typei,  <   )r%   r$   r#   r"   )r   r(   r)   r   r*   )r1   r+   randomrandintastypeuint8r   )fig_dicts    r   plotly_img_plotrE   1   s    ""1c
";;BB28LL
 

 AAA66
 

 
 
H (#b1111r   c                 z    t          | |          \  }}|                     d           d |D             g k    sJ d S )Ni  c                 F    g | ]}|j         d k    d|j        d         v|S errorfaviconurlr>   location.0msgs     r   
<listcomp>z1test_plotly_no_console_errors.<locals>.<listcomp>F   6    ```C38w#6#69CLY^L_;_;_C;_;_;_r   )r   wait_for_timeout)pager   msgs_s       r   test_plotly_no_console_errorsrW   A   sO    dN33GD!$``4```dfffffffr   c                 t   t          |            |                     d          }t          |                              d           |                     d          }|                     d          }t          |                              d           t          |                              d           |                     d          }t          |                              d           |                     d          }t          |                              d           t	          fd|            d S )N&.js-plotly-plot .plot-container.plotlyr
   zg.xaxislayer-abovezg.yaxislayer-above.modebar-containerz.hoverlayerc                  (     j         ddgddgdk    S )NgKzgWK?gKz?g/B@)zxaxis.rangezyaxis.range)viewportr   s   r   <lambda>z%test_plotly_2d_plot.<locals>.<lambda>^   s+    ~.,.?@*,=>3 3  r   )r   locatorr   to_have_countr   )rT   r   plotly_plotxaxisyaxismodebarhovers    `     r   test_plotly_2d_plotrf   J   s+   D.))) ,,GHHK
;%%a((( LL-..ELL-..E
5MM"""
5MM""" ll/00G
7OO!!!$$$LL''E
5MM"""         r   c                    |\  }}t          | |           |                     d          }t          |                              dd           t          |                              |d           |                     d          }t          |                              d           |                     d          }t          |                              d           |                     d	          }t          |                              d           |                     d
          }t          |                              d           d S )NrY   r
   i'  )timeoutT)use_inner_textz	.g-gtitlez;.js-plotly-plot .plot-container.plotly .gl-container #scenez	.colorbarrZ   )r   r_   r   r`   to_contain_text)	rT   r7   r6   r&   ra   
plot_titleplot	color_barrd   s	            r   test_plotly_3d_plotrn   d   s+   #NGUD'""" ,,GHHK
;%%a%888
;''d'CCCk**J
:$$Q''' <<UVVD
4LLq!!![))I
9##A&&&ll/00G
7OO!!!$$$$$r   c                    g j                             fdd           t          |            |                     d          }t	          |                              d           |                    d                              d          }|                    d           t          fd	|            |                     d
          }|                    d           t          fd|            d S )Nc                 8                         | j                  S N)appendnew)e
hover_datas    r   r^   z(test_plotly_hover_data.<locals>.<lambda>~   s    ):):15)A)A r   ru   rY   r
   zg.points path.pointr   Tforcec                      dddddddgi v S Npointsr   r   curveNumber
pointIndexpointNumberr   r    ru   s   r   r^   z(test_plotly_hover_data.<locals>.<lambda>   s5    
 
  
 r   z5.js-plotly-plot .plot-container.plotly g.scatterlayerc                       j         d u S rq   r   r]   s   r   r^   z(test_plotly_hover_data.<locals>.<lambda>   s    ~0D8 r   )	paramwatchr   r_   r   r`   nthre   r   )rT   r   ra   pointrl   ru   s    `   @r   test_plotly_hover_datar   |   s   JAAAA<PPPD.))),,GHHK
;%%a(((  566::1==E	KKdK        <<OPPDJJTJ8888$?????r   c                 8   t          |            |                     d          }t          |                              d           |                     d                              d          }|                    d           t          fd|            d S )NrY   r
   z1.js-plotly-plot .plot-container.plotly path.pointr   Trv   c                  ,     j         dddddddgik    S ry   )
click_datar]   s   r   r^   z(test_plotly_click_data.<locals>.<lambda>   s5    ~0
 
 5  r   )r   r_   r   r`   r   clickr   )rT   r   ra   r   s    `  r   test_plotly_click_datar      s    D.))),,GHHK
;%%a((( LLLMMQQRSTTE	KKdK         r   c                    t          |            |                     d          }t          |                              d           |                     d                                           |                     d                                          }| j                            |d         dz   |d         dz              | j                                         | j                            |d         |d         z   |d         |d         z   d	
           | j        	                                 t          fd|            j        }|J d|v sJ |d         ddddddgk    sJ d|v sJ d|d         v sJ d|d         v sJ d S )NrY   r
   z a.modebar-btn[data-val="select"]r   r   r   r   r(   r   )stepsc                       j         d uS rq   )selected_datar]   s   r   r^   z)test_plotly_select_data.<locals>.<lambda>   s    ~34? r   rz   r   r   r{   range)r   r_   r   r`   r   bounding_boxmousemovedownupr   r   )rT   r   ra   bboxselecteds    `   r   test_plotly_select_datar      s   D.))),,GHHK
;%%a(((LL344::<<<<<@AANNPPDJOODIcM49S=111JOOJOODId7m+T#YtH~-EQOOOOJMMOOO????FFF+HxH# # "     h(7#####(7#######r   c                 <   t          |           \  }}|                     d          }t          |                              d           d |D             g k    sJ |                    d          }|                    d           t          fd|            d S )NrY   r
   c                 F    g | ]}|j         d k    d|j        d         v|S rH   rL   rN   s     r   rQ   z(test_plotly_img_plot.<locals>.<listcomp>   rR   r   r=   Trv   c                  *     j         ddddddgik    S )Nrz   r      r   rgb)r|   r   r   
colormodelr   )rE   s   r   r^   z&test_plotly_img_plot.<locals>.<lambda>   s'    1hQRY[bcsxAyAy@z5{{ r   )r   r_   r   r`   re   r   )rT   rE   rU   rV   ra   r   s    `    r   test_plotly_img_plotr      s    dO44GD! ,,GHHK
;%%a(((``4```dfffff ((E	KKdK{{{{  ~B  C  C  C  C  Cr   )!pytestimportorskipnumpyr+   plotly.graph_objs
graph_objsr   	plotly.ioiopioplaywright.sync_apir   
panel.paner   panel.tests.utilr   r   markui
pytestmark	templatesdefaultfixturer   r7   rE   rW   rf   rn   r   r   r   r   r   r   r   <module>r      s     L ! ! !  H                    & & & & & &       8 8 8 8 8 8 8 8[^
      , 2 2 2g g g  4% % %0@ @ @<  *$ $ $BC C C C Cr   