Dash high range of x axis (Python)











up vote
0
down vote

favorite












Chart in dash shows long range of X-axis. And it doesn't autorange automatically.



app.layout = html.Div(
[
dcc.Graph(id='live-graph', animate=True),
dcc.Interval(
id='graph-update',
interval=100
),
]
)

@app.callback(Output('live-graph', 'figure'),
events=[Event('graph-update', 'interval')])
def update_graph_scatter():
df = market_collection['coinbase']['BTC-USD']

data = plotly.graph_objs.Scatter(
x=list(df.index),
y=list(df.price),
name='Scatter',
mode='lines+markers'
)
return {'data': [data], 'layout': go.Layout(xaxis=dict(range=[min(df.index),
max(df.index)]),
yaxis=dict(range=[min(df.price),
max(df.price)]),)}


big range



Every 100ms it refreshes and graph starts from 2000's year for some time, that is not more than 10ms. After that it starts from df.index[0] until next refresh. Next picture shows it.



enter image description here



Even after refresh, it doesn't autoscale.



Head of df:




index | price | volume



2018-11-17 15:05:19.142000+00:00 | 5492.15 | 0.008877



2018-11-17 15:05:32.872000+00:00 | 5491.66 | 0.040914



2018-11-17 15:05:33.710000+00:00 | 5491.63 | 0.005437



2018-11-17 15:05:36.745000+00:00 | 5491.64 | 0.003354



2018-11-17 15:05:38.810000+00:00 | 5491.64 | 0.005075











share|improve this question




























    up vote
    0
    down vote

    favorite












    Chart in dash shows long range of X-axis. And it doesn't autorange automatically.



    app.layout = html.Div(
    [
    dcc.Graph(id='live-graph', animate=True),
    dcc.Interval(
    id='graph-update',
    interval=100
    ),
    ]
    )

    @app.callback(Output('live-graph', 'figure'),
    events=[Event('graph-update', 'interval')])
    def update_graph_scatter():
    df = market_collection['coinbase']['BTC-USD']

    data = plotly.graph_objs.Scatter(
    x=list(df.index),
    y=list(df.price),
    name='Scatter',
    mode='lines+markers'
    )
    return {'data': [data], 'layout': go.Layout(xaxis=dict(range=[min(df.index),
    max(df.index)]),
    yaxis=dict(range=[min(df.price),
    max(df.price)]),)}


    big range



    Every 100ms it refreshes and graph starts from 2000's year for some time, that is not more than 10ms. After that it starts from df.index[0] until next refresh. Next picture shows it.



    enter image description here



    Even after refresh, it doesn't autoscale.



    Head of df:




    index | price | volume



    2018-11-17 15:05:19.142000+00:00 | 5492.15 | 0.008877



    2018-11-17 15:05:32.872000+00:00 | 5491.66 | 0.040914



    2018-11-17 15:05:33.710000+00:00 | 5491.63 | 0.005437



    2018-11-17 15:05:36.745000+00:00 | 5491.64 | 0.003354



    2018-11-17 15:05:38.810000+00:00 | 5491.64 | 0.005075











    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Chart in dash shows long range of X-axis. And it doesn't autorange automatically.



      app.layout = html.Div(
      [
      dcc.Graph(id='live-graph', animate=True),
      dcc.Interval(
      id='graph-update',
      interval=100
      ),
      ]
      )

      @app.callback(Output('live-graph', 'figure'),
      events=[Event('graph-update', 'interval')])
      def update_graph_scatter():
      df = market_collection['coinbase']['BTC-USD']

      data = plotly.graph_objs.Scatter(
      x=list(df.index),
      y=list(df.price),
      name='Scatter',
      mode='lines+markers'
      )
      return {'data': [data], 'layout': go.Layout(xaxis=dict(range=[min(df.index),
      max(df.index)]),
      yaxis=dict(range=[min(df.price),
      max(df.price)]),)}


      big range



      Every 100ms it refreshes and graph starts from 2000's year for some time, that is not more than 10ms. After that it starts from df.index[0] until next refresh. Next picture shows it.



      enter image description here



      Even after refresh, it doesn't autoscale.



      Head of df:




      index | price | volume



      2018-11-17 15:05:19.142000+00:00 | 5492.15 | 0.008877



      2018-11-17 15:05:32.872000+00:00 | 5491.66 | 0.040914



      2018-11-17 15:05:33.710000+00:00 | 5491.63 | 0.005437



      2018-11-17 15:05:36.745000+00:00 | 5491.64 | 0.003354



      2018-11-17 15:05:38.810000+00:00 | 5491.64 | 0.005075











      share|improve this question















      Chart in dash shows long range of X-axis. And it doesn't autorange automatically.



      app.layout = html.Div(
      [
      dcc.Graph(id='live-graph', animate=True),
      dcc.Interval(
      id='graph-update',
      interval=100
      ),
      ]
      )

      @app.callback(Output('live-graph', 'figure'),
      events=[Event('graph-update', 'interval')])
      def update_graph_scatter():
      df = market_collection['coinbase']['BTC-USD']

      data = plotly.graph_objs.Scatter(
      x=list(df.index),
      y=list(df.price),
      name='Scatter',
      mode='lines+markers'
      )
      return {'data': [data], 'layout': go.Layout(xaxis=dict(range=[min(df.index),
      max(df.index)]),
      yaxis=dict(range=[min(df.price),
      max(df.price)]),)}


      big range



      Every 100ms it refreshes and graph starts from 2000's year for some time, that is not more than 10ms. After that it starts from df.index[0] until next refresh. Next picture shows it.



      enter image description here



      Even after refresh, it doesn't autoscale.



      Head of df:




      index | price | volume



      2018-11-17 15:05:19.142000+00:00 | 5492.15 | 0.008877



      2018-11-17 15:05:32.872000+00:00 | 5491.66 | 0.040914



      2018-11-17 15:05:33.710000+00:00 | 5491.63 | 0.005437



      2018-11-17 15:05:36.745000+00:00 | 5491.64 | 0.003354



      2018-11-17 15:05:38.810000+00:00 | 5491.64 | 0.005075








      python plotly dash






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 17 at 15:14

























      asked Nov 17 at 14:57









      Nurislom Turaev

      355




      355





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53352390%2fdash-high-range-of-x-axis-python%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53352390%2fdash-high-range-of-x-axis-python%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          Origin of the phrase “under your belt”?