Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
How to limit only one active slice per pie chart on amCharts5?

I am trying to replicate the pie chart behaviour from this v4 tutorial on amCharts v5 with no luck:

https://www.amcharts.com/docs/v4/tutorials/one-pulled-slice-per-pie-chart/

The v4 code does not work on v5 (nor getting error). I have debugged it and it loops through the slices, but there is no more "isActive" property, and have not found any other similar property or method to get or set the slice state.

I have already searched in offical docs but found nothing. Seems v5 is lacking some v4 features... anyone accomplished to limit only 1 selected slice per chart?

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

From official amCharts tutorial "One pulled slice per pie series":

... so whenever a slice is pulled out, it becomes "active" (it's "active" setting is set to true). And vice versa, setting it to false will make the slice pop back into its place.

Also, when a slice (or any other object for that matter) is clicked/tapped, it generates a "click" event. If there's an event handler defined, it is executed.

Let's use these two bits of code to implement our task:

series.slices.template.events.on("click", function(ev) {
  series.slices.each(function(slice) {
    if (slice != ev.target && slice.get("active")) {
      slice.set("active", false);
    }
  })
});

CodePen example: https://codepen.io/team/amcharts/pen/dyZzQLJ

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!