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

291
Views
How can i change the color of a tile which was clicked of a treemap in highcharts using react

I am using Tree map chart from High-chart library, but I am facing an issue with the changing the color of the active tile or the tile which was clicked, I tried from my end by updating the color of the current which was clicked, but it didn't work as it was updating the tile which was clicked and I don't want that I want the colors to change only when i click on a sports tile and after clicking on other sport it(the previous sport) should go back to its actual color

<iframe src="https://codesandbox.io/embed/busy-thompson-7fsijn?fontsize=14&hidenavigation=1&theme=dark"
     style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;"
     title="busy-thompson-7fsijn"
     allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking"
     sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
   ></iframe>

Below is the link to my code, I hope you guys could help me with this thanks in advance

https://codesandbox.io/embed/busy-thompson-7fsijn?fontsize=14&hidenavigation=1&theme=dark

https://codesandbox.io/s/busy-thompson-7fsijn?file=/src/App.js

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

0

set a class name in title and give a style to change the colour

about 4 years ago · Juan Pablo Isaza Report

0

First of all, to avoid unnecessary chart redraw memoize your options or keep them in a state. To change color of the clicked point and restore the original one, you can save the current color on a series and use point.update method to change/restore. For example:

click: function(event) {
  const point = event.point;
  const prevClickedPoint = point.series.clickedPoint;

  if (prevClickedPoint) {
    prevClickedPoint.update({ color: prevClickedPoint.orgColor }, false);
  }

  point.orgColor = point.color;
  point.series.clickedPoint = point;

  point.update({ color: "red" }, false);
  point.series.chart.redraw();

  if (point.node.childrenTotal === 0) {
    var category = point.node.name;

    setSports(category);
  }
}

Live demo: https://codesandbox.io/s/stupefied-wave-ibtc2-ibtc2r?file=/src/App.js

API Reference: https://api.highcharts.com/class-reference/Highcharts.Point#update

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!