+L i;ddlZddlZddlZddlZddlZddlmZ ddlmZe Z Gdde Z e Z[ dZddZy#e $r ddl mZY/wxYw) N)reduce)gcdceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z ifd Zed Zej"dZdZdZdZdZy)TemplatesConfigzO Singleton object containing the current figure templates (aka themes) cji|_gd}|D]}t|j|<d|_d|_y)N) ggplot2seaborn simple_whiteplotly plotly_white plotly_dark presentationxgridoffygridoffgridonnone) _templatesLazy _validator_default)selfdefault_templates template_names Z/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/plotly/io/_templates.py__init__zTemplatesConfig.__init__s@  / 2M-1DOOM * 2 c,t|jSN)lenrrs r__len__zTemplatesConfig.__len__6s4??##rc||jvSr)r)ritems r __contains__zTemplatesConfig.__contains__9st&&rc,t|jSr)iterrr s r__iter__zTemplatesConfig.__iter__<sDOO$$rct|tr|jd}n|g}g}|D]}|j|}|turddlm}|dk(r|ig}||j|<nwtjjdd|dz}tjd |jd }tj|} || d }||j|<|j|j||j |S) N+rTemplater) data_scatter package_data templatesz.jsonr zutf-8F) _validate) isinstancestrsplitrrplotly.graph_objs.layoutr+ospathjoinpkgutilget_datadecodejsonloadsappendmerge_templates) rr#template_namesr.rtemplater+r5 template_str template_dicts r __getitem__zTemplatesConfig.__getitem__?s dC !ZZ_N"VN + =M}5H4= F*'bT:H5=DOOM277<<& ]W5LD$+#3#3Hd#C#J#J7#SL$(JJ|$>> import plotly.io as pio >>> list(pio.templates) Returns ------- str )rr s rdefaultzTemplatesConfig.defaults$}}rc4|j|||_yr)r/r)rrEs rr[zTemplatesConfig.defaults u rcjdjt|j|jS)NzuTemplates configuration ----------------------- Default template: {default} Available templates: {available} )r[ available)formatreprr[_available_templates_strr s r__repr__zTemplatesConfig.__repr__s/  F4 %1N1N1PFQ  Rrc zdjtjtt |ddd}|S)ze Return nicely wrapped string representation of all available template names  Gz z )widthinitial_indentsubsequent_indent)r6textwrapwrapr`list)rr^s rraz(TemplatesConfig._available_templates_strs; II MMT$Z &")   rcL|rt|j|Sddlm}|S)a Merge a collection of templates into a single combined template. Templates are process from left to right so if multiple templates specify the same propery, the right-most template will take precedence. Parameters ---------- args: list of Template Zero or more template objects (or dicts with compatible properties) Returns ------- template: A combined template object Examples -------- >>> pio.templates.merge_templates( ... go.layout.Template(layout={'font': {'size': 20}}), ... go.layout.Template(data={'scatter': [{'mode': 'markers'}]}), ... go.layout.Template(layout={'font': {'family': 'Courier'}})) layout.Template({ 'data': {'scatter': [{'mode': 'markers', 'type': 'scatter'}]}, 'layout': {'font': {'family': 'Courier', 'size': 20}} }) rr*)r_merge_2_templatesr3r+)rargsr+s rr=zTemplatesConfig.merge_templatess%: $1148 8 9: rc|j|}|j|}|jD]}|j|}|j|}|s$|s't|t|ztt|t|z}||t|zz|j|<||t|zz|j|<|j ||S)a Helper function for merge_templates that merges exactly two templates Parameters ---------- template1: Template template2: Template Returns ------- Template: merged template )r/datarrrY) r template1 template2resultother trace_type result_traces other_traceslcms rrmz"TemplatesConfig._merge_2_templatess *y)!++ SJ"KK 3M ::j1L &,'(3}-s>> $  #9 :w $\ 2 8I%J"bgg%J "%J$0crZ1G$H !! O%{{ 5D{{&<<%;%A%A&++%N &7 &C -fk4H&,&6&6&8 -fk4H)00=.55fkkB#/FK)&2GN' O*"3L ##8G+  sFF F)(F)cddlm}ddlm}t ||s||}|s t }n t |}|j dtj|}t|j|jjj|i}t|jD]}|j|jd}t|jjj|j}t!||kr.|j#|j%t!||kr.||} t|| |||jjj|j<|dz||j<d} |jjjD]x} |jjj| } | Dcgc]}|j'd| ik(} }t)| r$d |jjj| <wd } z| sd |jj_ |Scc}w) a" Return a copy of a figure where all styling properties have been moved into the figure's template. The template property of the resulting figure may then be used to set the default styling of other figures. Parameters ---------- fig Figure object or dict representing a figure skip A collection of names of properties to skip when moving properties to the template. Defaults to ('title', 'text') so that the text of figure titles, axis titles, and annotations does not become part of the template Examples -------- Imports >>> import plotly.graph_objs as go >>> import plotly.io as pio Construct a figure with large courier text >>> fig = go.Figure(layout={'title': 'Figure Title', ... 'font': {'size': 20, 'family': 'Courier'}, ... 'template':"none"}) >>> fig # doctest: +NORMALIZE_WHITESPACE Figure({ 'data': [], 'layout': {'font': {'family': 'Courier', 'size': 20}, 'template': '...', 'title': {'text': 'Figure Title'}} }) Convert to a figure with a template. Note how the 'font' properties have been moved into the template property. >>> templated_fig = pio.to_templated(fig) >>> templated_fig.layout.template layout.Template({ 'layout': {'font': {'family': 'Courier', 'size': 20}} }) >>> templated_fig Figure({ 'data': [], 'layout': {'template': '...', 'title': {'text': 'Figure Title'}} }) Next create a new figure with this template >>> fig2 = go.Figure(layout={ ... 'title': 'Figure 2 Title', ... 'template': templated_fig.layout.template}) >>> fig2.layout.template layout.Template({ 'layout': {'font': {'family': 'Courier', 'size': 20}} }) The default font in fig2 will now be size 20 Courier. Next, register as a named template... >>> pio.templates['large_courier'] = templated_fig.layout.template and specify this template by name when constructing a figure. >>> go.Figure(layout={ ... 'title': 'Figure 3 Title', ... 'template': 'large_courier'}) # doctest: +ELLIPSIS Figure(...) Finally, set this as the default template to be applied to all new figures >>> pio.templates.default = 'large_courier' >>> fig = go.Figure(layout={'title': 'Figure 4 Title'}) >>> fig.layout.template layout.Template({ 'layout': {'font': {'family': 'Courier', 'size': 20}} }) Returns ------- go.Figure r) BaseFigure)Figureuid)rFtypeNT)plotly.basedatatypesrplotly.graph_objsrr0raddcopydeepcopyrrKr?rkrpgetrrr<rto_plotly_jsonall)figrrr templated_figtrace_type_indexestracetemplate_indextemplate_tracestemplate_trace any_non_emptyrutracesis_emptys r to_templatedrYsn0( c: &Sk u4y HHUOMM#&Mm22;;BB m(()<+// A>}33<<AA%**MN/"n4  " "5??#4 5/"n4 )8 e^$?:I %%**5::6*8!);5::&'<,M#**3388! %%..33J?PVWuE((*vz.BBWW x==AM ) ) . .z : M ! -1 %%* XsI ))titletext)rir7rr4r: functoolsrmathr ImportError fractionsobjectrrr.rrrrrrsf x rfrn    CLS] sA AA