Skip to content

Update animations w/ react-plotly #101

Open
@BG687

Description

@BG687

I would like to animate my stacked area chart when the data updates (so the transition from the old data to the new data is smooth). Right now, when the data updates the chart just instantly changes to reflect the new data.

I don't see an animate function on the Plotly react component or its prototype. What is the best way to go about animating these charts? Is this possible?

Thanks

Activity

nicolaskruchten

nicolaskruchten commented on Sep 12, 2018

@nicolaskruchten
Contributor

This isn't currently possible within react-plotly.js but we're working on adding support for it in the underlying plotly.js library: plotly/plotly.js#1849

GrahamWilsdon

GrahamWilsdon commented on Feb 8, 2019

@GrahamWilsdon

@nicolaskruchten any update on this?

dmt0

dmt0 commented on Feb 8, 2019

@dmt0
Contributor

@GrahamWilsdon Some transitions are possible now, see the info in the PR that closed the mentioned issue: plotly/plotly.js#3217 (comment)

billyhunt

billyhunt commented on Aug 28, 2019

@billyhunt

Are bar chart animations available? I was having trouble getting one to work.

I am doing something like

const HistogramComponent: FunctionComponent<{
  timeAggregation: any
  unitOfTime: any
}> = () => {

  const determineTickFormat = (interval: UnitOfTime) => {
    let tickFormat = '%y/%m'

    switch (interval) {
      case 'daily':
        tickFormat = '%d/%m/%Y'
        break
      case 'weekly':
        tickFormat = '%m/%Y'
        break
      case 'monthly':
        tickFormat = '%b %Y'
        break
      case 'yearly':
      default:
        tickFormat = '%Y'
        break
    }
    return tickFormat
  }

  let data: Partial<PlotData>[]
  let layout = {}

  const transition = {
    duration: 2000,
    easing: 'cubic-in-out'
  }

  const layout = {
    autosize: true,
    transition,
    margin: {
      l: 30,
      r: 30,
      b: 30,
      t: 15
    },
    font: {
      family: 'Heebo, Overpass, sans-serif',
      color: theme.fgGrey
    },
    xaxis: {
      ticklen: 5,
      tickwidth: 1,
      tickcolor: theme.fgGreyLight,
      ticks: 'outside',
      lineWidth: 1,
      fixedrange: true // disables zooming on x axis
    },
    yaxis: {
      lineWidth: 1,
      zerolinecolor: theme.fgGreyLight,
      fixedrange: true // disables zooming on y axis
    }
  }

  return (
    <StyledPlot
      data={data}
      layout={layout}
      useResizeHandler={true}
      config={config}
    />
  )
}

nicolaskruchten

nicolaskruchten commented on Aug 28, 2019

@nicolaskruchten
Contributor

No, bar chart animations are not merged yet... coming soon!

CarlosAmaral

CarlosAmaral commented on Jun 11, 2020

@CarlosAmaral

@nicolaskruchten Do we already have Bar chart animations?

nicolaskruchten

nicolaskruchten commented on Jun 11, 2020

@nicolaskruchten
Contributor

Bar chart transitions are supported in recent versions of Plotly.js, yes.

CarlosAmaral

CarlosAmaral commented on Jun 11, 2020

@CarlosAmaral

@nicholas-esterer I used the same code as @billyhunt. Didn't work. Do you have an example that you can share? Thank you!

nicolaskruchten

nicolaskruchten commented on Jun 11, 2020

@nicolaskruchten
Contributor

@CarlosAmaral which version of plotly.js are you using? Try 1.54.2 :)

CarlosAmaral

CarlosAmaral commented on Jun 12, 2020

@CarlosAmaral

@nicholas-esterer I did that. Same outcome. No animation.

nicolaskruchten

nicolaskruchten commented on Jun 12, 2020

@nicolaskruchten
Contributor

Can you provide a full running example in a codepen or something for me to help you debug?

qidian99

qidian99 commented on Jun 15, 2020

@qidian99

Is there any example of animating the scatter plot?

CarlosAmaral

CarlosAmaral commented on Jun 15, 2020

@CarlosAmaral
nicolaskruchten

nicolaskruchten commented on Jun 15, 2020

@nicolaskruchten
Contributor

@CarlosAmaral thanks! What part of this is meant to be animated?

CarlosAmaral

CarlosAmaral commented on Jun 15, 2020

@CarlosAmaral

Thank you, @nicolaskruchten. Good question, the bars going up for example?

11 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @tony@nicolaskruchten@joan780@dmt0@AlexBlack2202

        Issue actions

          Update animations w/ react-plotly · Issue #101 · plotly/react-plotly.js