Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xAxis categories don't update after first render in line chart #94

Closed
mkantz84 opened this issue Oct 7, 2019 · 5 comments
Closed

xAxis categories don't update after first render in line chart #94

mkantz84 opened this issue Oct 7, 2019 · 5 comments

Comments

@mkantz84
Copy link

mkantz84 commented Oct 7, 2019

Hi,
After updating the chart, everything is updating except the xAxis categories.
Tried changing tickPlacement to 'between', but it hasn't helped.
Any help would be appreciated..

versions:
"react-apexcharts": "^1.3.3"
"apexcharts": "^3.8.6"

@junedchhipa
Copy link
Contributor

Can you please post a codesandbox demo to reproduce the issue?

@sebastianpikand
Copy link

@junedchhipa

Try this. Works with "bar" but not "line"...


import React, { Component } from 'react';
import Chart from 'react-apexcharts';

export default class TotalSessions extends Component {
constructor(props) {
super(props);

this.state = {
  options: {
    xaxis: {
      categories: ['w', 'w', 'w']
    }
  },
  series: [{ data: [4, 6, 6] }]
};

this.toggle = () => {
  let newCategories = ['a', 'b', 'c'];
  let series = [{ data: [1, 2, 3] }];

  // Method 1 – DOES NOT WORK
  this.setState({
    ...this.state,
    series,
    options: {
      ...this.state.options,
      xaxis: {
        ...this.state.options.xaxis,
        categories: ['X1', 'X2', 'X3']
      }
    }
  });

  // Method 2 – DOES NOT WORK
  // this.setState({
  //   series,
  //   options: {
  //     ...this.state.options,
  //     xaxis: {
  //       ...this.state.options.xaxis,
  //       categories: newCategories
  //     }
  //   }
  // });
};

}

render() {
return (


<button onClick={() => this.toggle()}>test


);
}
}

@maxferro71
Copy link

Hi,
I've the same problem
I changed tickPlacement to 'between' but nothing, xaxis categories are not updated

if it help;
chartContext.opts.xaxis.categories contains the old value
while length of chartContext.opts.xaxis.categories is correct

any idea?

@jpb-lourenco
Copy link

#117 worked for me

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants