Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

How to make the first (default) view of the graph consider only its own trace (dataset) and not show a compound view of all button traces?

$
0
0

@mirceau wrote:

I have successfully implemented various (update) buttons that showcase different data-sets (traces) on a graph.

The thing is, that the first (default) view, showcases all traces at once on the graph. And as the user clicks on a button, then the filtration starts and the graph gets updated with only the trace that it is connected to that button.

That is great, all I need is that the first default view should not plot all traces, just it’s own trace.

One can image that the first default view no with all the traces plotted at once, looks pretty busy and cluttered. Which I am trying to avoid.

Question: How can I make the code not compound all the traces at first (default) state. But only add the traces upon button click?

This is my code:

  #figure layout and annotational functions on graph canvas
        layout=Layout(
            autosize=True,
            margin=go.layout.Margin(l=0, r=35, t=0, b=0),
            showlegend=False,
            mapbox=dict(
                accesstoken=mapbox_access_token,
                center=dict(lat=latInitial, lon=lonInitial),
                style="dark",
                bearing=bearing,
                zoom=zoom,
            ),
            updatemenus=[
                dict(
                    direction="left",
                    pad={"r": 0, "t": 0, "b": 0, "l": 0},
                    showactive=False,
                    type="buttons",
                    x=0.20,
                    y=0.02,
                    xanchor="left",
                    yanchor="bottom",
                    bgcolor="#323130",
                    borderwidth=1,
                    bordercolor="#6d6d6d",
                    font=dict(color="#FFFFFF"),
                    ################################################
                    #--------------- Graph Buttons ----------------#
                    ################################################
                    buttons=list(
                        [
                            #defaultView Button
                            dict(
                                label="Default View",
                                method="update",
                                args=[{"visible": [True, False, False, False, True, True]},
                                {"title": "Red View",
                                "annotations": []}]),

                            #redView Poisson Button
                            dict(
                                label="Poisson View",
                                method="update",
                                args=[{"visible": [False, True, False, False, True, True]},
                                ]),

                            #redView Camps Button
                            dict(
                                label="Context View",
                                method="update",
                                args=[{"visible": [False, False, True, False, True, True]},
                                ]),

                            #redView Both Button
                            dict(
                                label="Poisson+Context View",
                                method="update",
                                args=[{"visible": [False, False, False, True, True, True]},
                                ]),

                            #reset zoom
                            dict(
                                label="Reset Zoom",
                                args=[
                                    {
                                        "mapbox.zoom": 10.5,
                                        "mapbox.center.lon": "26.106700",
                                        "mapbox.center.lat": "-14.873619",
                                        "mapbox.bearing": 0,
                                        "mapbox.style": "dark",
                                    }
                                ],
                                method="relayout",
                            ),
                        ]
                    ),
                )
            ],
        ),

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6271

Latest Images

Trending Articles



Latest Images