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

193
Vistas
Display both the series legend and a colorAxis legend with dataClasses using highcharts in R

I'm wondering if it's possible to display both the series legend and a colorAxis legend using dataClasses in the same plot in highcharts.

Edit: I previously included a question. Which I now believe to be irrelevant to mine. Past question

I'm currently creating a highcharts heatmap using data classes and a line series that over lays on top. Initially, I had one line series so it wasn't an issue to have it always be displaying, since it's not included in the legend. But I've been tasked with including more lines series and now need the above functionality.

It appears to me that enabling dataClasses in the colorAxis removes the option to show a series legend. Since the plot shows both the colorAxis and series legend when removing dataClasses.

Below is a snippet of my code. I've copied over the events load callback function from the question above.

I'm using the R package/version highcharter_0.9.4 which is based on HighchartsJS 9.3.1

hchart(census, "heatmap", hcaes(x = "times", y = "bed_labels", value = "pat_state"), name="occupied") %>%
      hc_subtitle(text = paste0(display.name," <br> ", unique(daily.string))) %>%
      hc_tooltip(formatter = fn_tltp, shared=FALSE) %>%
      hc_colorAxis(dataClasses = color_axis) %>%
      hc_chart(marginRight = 80,
               events = list(
                 load = htmlwidgets::JS("function() {
                           console.log(this.colorAxis[0])
                           console.log(this.colorAxis[0].axisParent) # undefined
                           
                           var chart = this,
                               colorAxis = chart.colorAxis[0].axisParent.element,
                               mainSVG = chart.container.children[0],
                               xPos = chart.plotLeft + chart.plotWidth + 10,
                               yPos = chart.plotTop;
  
                            mainSVG.appendChild(colorAxis);
  
                            colorAxis.setAttribute(
                              'transform','translate(' + xPos + ', ' + yPos + ')'
                            )
                           }"))) %>%
      hc_yAxis_multiples(
        list(title = list(text = "Bed"),categories=p$x$hc_opts$yAxis$categories, gridLineWidth = 0),
        list(title = list(text = "Waiting Room"), opposite = TRUE)) %>%
      hc_add_series(waiting_census_daily,hcaes(x=x,y=y),name="waiting",color="black",yAxis=1,type="line",
                    marker = list(radius = 2, lineColor = "#000", fillColor = "#000"))

I can attempt to create a reprex but I really just want to know, if axisParent still exists and if not, what object I may be able to use instead.

about 4 years ago · Juan Pablo Isaza
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