Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

290
Vistas
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 Respuestas
Responde la pregunta

0

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

about 4 years ago · Juan Pablo Isaza Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda