victory icon indicating copy to clipboard operation
victory copied to clipboard

VictoryBar animation doesn't work for named x and y axis

Open CakeBrewery opened this issue 9 years ago • 1 comments

VictoryBar components with custom axis names don't animate.

Animation doesn't work in the following code. I added animate={{duration: 500}} to the "Getting Started with Victory" example, which names the y axis as "earnings"

const data = [
  {quarter: 1, earnings: 13000},
  {quarter: 2, earnings: 16500},
  {quarter: 3, earnings: 14250},
  {quarter: 4, earnings: 19000}
];

class App extends React.Component {
  render() {
    return (
      <VictoryChart
        // adding the material theme provided with Victory
        theme={VictoryTheme.material}
        domainPadding={20}
        animate={{duration: 500}}
      >
        <VictoryAxis
          tickValues={["Quarter 1", "Quarter 2", "Quarter 3", "Quarter 4"]}
        />
        <VictoryAxis
          dependentAxis
          tickFormat={(x) => (`$${x / 1000}k`)}
        />
        <VictoryBar
          data={data}
          x="quarter"
          y="earnings"
        />
      </VictoryChart>
    )
  }
}

Removing the "earnings" name off the y axis fixes the issue and the animation works again.

const data = [
  {quarter: 1, y: 13000},
  {quarter: 2, y: 16500},
  {quarter: 3, y: 14250},
  {quarter: 4, y: 19000}
];

class App extends React.Component {
  render() {
    return (
      <VictoryChart
        // adding the material theme provided with Victory
        theme={VictoryTheme.material}
        domainPadding={20}
        animate={{duration: 500}}>
      >
        <VictoryAxis
          tickValues={["Quarter 1", "Quarter 2", "Quarter 3", "Quarter 4"]}
        />
        <VictoryAxis
          dependentAxis
          tickFormat={(x) => (`$${x / 1000}k`)}
        />
        <VictoryBar
          data={data}
          x="quarter"
        />
      </VictoryChart>
    )
  }
}

CakeBrewery avatar Dec 07 '16 06:12 CakeBrewery

@CakeBrewery and @Zerim thanks for catching this! I'll publish the fix as a patch tonight.

boygirl avatar Dec 08 '16 00:12 boygirl