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

194
Views
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
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!