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

Is it possible to change the series type in XYChart in amcharts5? From LineSeries to ColumnSeries? #1829

Open
nikichak opened this issue Jan 18, 2025 · 6 comments
Labels

Comments

@nikichak
Copy link

nikichak commented Jan 18, 2025

InitialIy when I'm instantiating the chart I have LineSeries created and added to the chart. I have external menu from which the user can select the Series type.
Let's say they've selected ColumnSeries. What I should do is to remove old LineSeries, to instantiate the new ColumnSeries and to add them to the chart.

However when I try this.amChart.series.clear(), the old series are removed and when I instantiate the ColumnSeries and add them to the chart they are not rendered. When I try to add initially ColumnSeries instead of LineSeries they are working correctly.

Is it even possible to replace the series in an XYChart? If so, could you please provide an example?

Thanks!

@workingbuddy10
Copy link

Yes @nikichak , You can switch to the column series from line series. You just have to set the properties of valueAxis and dateAxis properly.
There is a doc related to series switcher, you only have to modify things according to the column series.
https://www.amcharts.com/docs/v5/charts/stock/toolbar/series-type-control/

If, Still facing issue then can you post a codepen link?

@martynasma
Copy link
Collaborator

There's no way to change type of the series on an existing series object.

You would need to:

  1. Dispose the old series.
  2. Create new series.
  3. Add data to new series.
  4. Add new series to the chart.series

@nikichak
Copy link
Author

@martynasma thanks for your suggestion.
I'm doing exactly the same but the new series are not rendered.

Could you give hints on what to watch while debugging?
I see the series are added to the chart when I log the object. I see the data is present in each series. Still they are not rendered.

Thanks.

@martynasma
Copy link
Collaborator

One thing that comes to mind: are you setting xAxis and yAxis on the new series?

@nikichak
Copy link
Author

Yes I am, they are also present when I log the amcharts.series list.

@martynasma
Copy link
Collaborator

In that case we'll need a demo. The process should just work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants