• <bdo id='1sWcG'></bdo><ul id='1sWcG'></ul>

    <small id='1sWcG'></small><noframes id='1sWcG'>

  1. <i id='1sWcG'><tr id='1sWcG'><dt id='1sWcG'><q id='1sWcG'><span id='1sWcG'><b id='1sWcG'><form id='1sWcG'><ins id='1sWcG'></ins><ul id='1sWcG'></ul><sub id='1sWcG'></sub></form><legend id='1sWcG'></legend><bdo id='1sWcG'><pre id='1sWcG'><center id='1sWcG'></center></pre></bdo></b><th id='1sWcG'></th></span></q></dt></tr></i><div id='1sWcG'><tfoot id='1sWcG'></tfoot><dl id='1sWcG'><fieldset id='1sWcG'></fieldset></dl></div>

    1. <legend id='1sWcG'><style id='1sWcG'><dir id='1sWcG'><q id='1sWcG'></q></dir></style></legend>
      <tfoot id='1sWcG'></tfoot>

      如何使用 Dash plotly 添加/创建自定义加载器?

      时间:2023-09-28
      <i id='rBsVX'><tr id='rBsVX'><dt id='rBsVX'><q id='rBsVX'><span id='rBsVX'><b id='rBsVX'><form id='rBsVX'><ins id='rBsVX'></ins><ul id='rBsVX'></ul><sub id='rBsVX'></sub></form><legend id='rBsVX'></legend><bdo id='rBsVX'><pre id='rBsVX'><center id='rBsVX'></center></pre></bdo></b><th id='rBsVX'></th></span></q></dt></tr></i><div id='rBsVX'><tfoot id='rBsVX'></tfoot><dl id='rBsVX'><fieldset id='rBsVX'></fieldset></dl></div>
        <tbody id='rBsVX'></tbody>
      <legend id='rBsVX'><style id='rBsVX'><dir id='rBsVX'><q id='rBsVX'></q></dir></style></legend>

        1. <tfoot id='rBsVX'></tfoot>

          • <small id='rBsVX'></small><noframes id='rBsVX'>

              <bdo id='rBsVX'></bdo><ul id='rBsVX'></ul>
              • 本文介绍了如何使用 Dash plotly 添加/创建自定义加载器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想将我的 gif 传递给加载器组件,而不是使用默认数字.有人知道怎么做吗?

                I want to pass my gif to the loader component instead of using the default figures. Does anybody know how to do that?

                这是我的代码:

                dcc.Loading(
                    id="loading-1",
                    type="default",
                    children=html.Div(id="loading-output-1"),
                )
                

                我正在尝试完成这样的事情:

                and I am trying to accomplish something like this :

                dcc.Loading(
                    id="loading-1",
                    type="assets/dashboard_loader.gif",
                    children=html.Div(id="loading-output-1"),
                )
                

                有人可以指导我吗?

                推荐答案

                type 属性指定微调器的外观,但仅限于 dash 核心组件提供的一组值:

                The type property specifies what the spinner looks like, but is limited to a set of values dash core components provides:

                type(一个值等于:'graph','cube','circle','dot','default';默认'default'):确定哪个微调器显示'graph','之一的属性立方体"、圆"、点"或默认".

                type (a value equal to: 'graph', 'cube', 'circle', 'dot', 'default'; default 'default'): Property that determines which spinner to show one of 'graph', 'cube', 'circle', 'dot', or 'default'.

                所以你的方法目前是不可能的,但有一个解决方法.

                So your approach is currently not possible, but there is a workaround.

                默认微调器的 html 结构如下所示:

                The html structure of the default spinner looks something like this:

                <div class="dash-spinner dash-default-spinner">
                  <div class="dash-default-spinner-rect1"></div>
                  <div class="dash-default-spinner-rect2"></div>
                  <div class="dash-default-spinner-rect3"></div>
                  <div class="dash-default-spinner-rect4"></div>
                  <div class="dash-default-spinner-rect5"></div>
                </div>
                

                .dash-spinner 中的每个矩形 div 都用于默认类型的动画.我们不关心这些矩形或 .dash-spinner 内部的任何东西,因为我们只想要 gif 动画.

                Each of these rectangle divs inside .dash-spinner are used for the default type animation. We don't care about these rectangles or anything that's inside of .dash-spinner, because we only want the gif animation.

                所以我们可以在这里做的是隐藏所有 .dash-spinner 子元素并为 .dash-spinner 添加动画背景.

                So what we could do here is to hide all .dash-spinner children and add an animated background to .dash-spinner.

                我们可以用 css 做到这一点

                We can do so with css

                .dash-spinner {
                  background-image: url("http://i.stack.imgur.com/SBv4T.gif");
                  background-size: contain;
                  background-repeat: no-repeat;
                }
                
                .dash-spinner * {
                  display: none !important;
                }
                

                如需包含 css,请参阅文档此处.

                For including css see the documentation here.

                基于文档此处中给出的示例的最小且可重复的示例:

                Minimal and reproducible example based on the example given in the documentation here:

                from dash import Dash
                import time
                import dash_core_components as dcc
                import dash_html_components as html
                from dash.dependencies import Input, Output
                
                
                app = Dash(__name__)
                app.layout = html.Div(
                    children=[
                        html.H3("Edit text input to see loading state"),
                        dcc.Input(id="loading-input-1", value="Input triggers local spinner"),
                        dcc.Loading(
                            id="loading-1", type="default", children=html.Div(id="loading-output-1")
                        ),
                    ],
                )
                
                
                @app.callback(
                    Output("loading-output-1", "children"),
                    Input("loading-input-1", "value"),
                    prevent_initial_call=True,
                )
                def input_triggers_spinner(value):
                    time.sleep(2)
                    return value
                
                
                if __name__ == "__main__":
                    app.run_server()
                


                Gif 取自此相关答案此处.

                这篇关于如何使用 Dash plotly 添加/创建自定义加载器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何设置绘图的背景颜色和网格线的颜色? 下一篇:如何摆脱 Choropleth 的白色背景?

                相关文章

                  <bdo id='fhlaT'></bdo><ul id='fhlaT'></ul>

                    <legend id='fhlaT'><style id='fhlaT'><dir id='fhlaT'><q id='fhlaT'></q></dir></style></legend>
                  1. <tfoot id='fhlaT'></tfoot>
                  2. <i id='fhlaT'><tr id='fhlaT'><dt id='fhlaT'><q id='fhlaT'><span id='fhlaT'><b id='fhlaT'><form id='fhlaT'><ins id='fhlaT'></ins><ul id='fhlaT'></ul><sub id='fhlaT'></sub></form><legend id='fhlaT'></legend><bdo id='fhlaT'><pre id='fhlaT'><center id='fhlaT'></center></pre></bdo></b><th id='fhlaT'></th></span></q></dt></tr></i><div id='fhlaT'><tfoot id='fhlaT'></tfoot><dl id='fhlaT'><fieldset id='fhlaT'></fieldset></dl></div>

                  3. <small id='fhlaT'></small><noframes id='fhlaT'>