rr-highcharter

Multiple series radar plot with highcharter


I am trying to create a radar plot with multiple series. Unfortunately I don't manage to make the polar = TRUE argument work. Here is my attempt so far :

library(dplyr)
library(highcharter)

df <- data.frame(Series = rep(paste0("Serie", 1:4), 2),
                 Product = c(rep("Product1", 4), rep("Product2", 4)),
                 Value = c(5.8, 6.3, 8.1, 2.3, 4.4, 4.6, 7.7, 6.6))

df %>% 
  hchart(type = "line", polar = TRUE, 
         hcaes(y = Value, group = Product), pointPlacement = "on") %>%
  hc_xAxis(categories = df %>% pull(Series) %>% unique()) %>% 
  hc_yAxis(gridLineInterpolation = "polygon",
           lineWidth = 0,
           min = 0)


Solution

  • I am creating the polar chart first and then add each series in a for-loop.

    hc <- highchart() %>%
      hc_chart(polar = TRUE, type = "line") %>%
      hc_xAxis(categories = unique(df$Series),
               tickmarkPlacement = "on",
               lineWidth = 0) %>%
      hc_yAxis(gridLineInterpolation = "polygon",
               lineWidth = 0,
               min = 0) %>%
      hc_plotOptions(line = list(pointPlacement = "on"))
    
    for(product in unique(df$Product)) {
      product_data <- df %>% filter(Product == product)
      hc <- hc %>% hc_add_series(
        name = product,
        data = product_data$Value,
        type = "line"
      )
    }
    
    hc
    

    Created on 2025-07-21 with reprex v2.1.1