jbkunst / highcharter

R wrapper for highcharts
http://jkunst.com/highcharter/
Other
717 stars 147 forks source link

Different scales for different variables in polar charts #810

Open a13cas12ve opened 4 months ago

a13cas12ve commented 4 months ago

I am trying to create polar charts to make comparisons between individuals but I find the problem is that I can't compare different variables with different ranges as some of them have such a small range that I'm unable to see differences between series.

After thorough research, I haven't found any way to affect variable scales in the chart. Here's the code in question:

library(highcharter)

# Datos de ejemplo
jugadores <- c("Jugador1", "Jugador2", "Jugador3", "Jugador4")
KD <- c(1.5, 0.8, 1.2, 1.9) # Rango 0-2
elo <- c(2500, 3000, 4000, 1500) # Rango 0-5000
HS <- c(80, 90, 60, 70) # Rango 0-100

# Crear un dataframe con los datos
datos <- data.frame(jugadores, KD, elo, HS)

hc <- highchart() %>%
  hc_chart(polar = TRUE, type = "line") %>%
  hc_title(text = "Gráfico Polar con Escalas Variables") %>%
  hc_xAxis(categories = colnames(datos)[-1]) %>%
  hc_add_series(
    name = 'Jugador 1',
    data = as.numeric(datos[datos$jugadores == 'Jugador1', -1])
  ) %>%
  hc_add_series(
    name = 'Jugador 2',
    data = as.numeric(datos[datos$jugadores == 'Jugador2', -1])
  ) %>%
  hc_add_series(
    name = 'Jugador 3',
    data = as.numeric(datos[datos$jugadores == 'Jugador3', -1])
  ) %>%
  hc_add_series(
    name = 'Jugador 4',
    data = as.numeric(datos[datos$jugadores == 'Jugador4', -1])
  )

# Mostrar el gráfico
hc
robertogilsaura commented 4 months ago
Hola @a13cas12ve aunque no sea la solución perfecta, te puede funcionar. 
Estandariza los datos, y representa los datos estandarizados y mantén los dataLabels  y el tooltip la referencia a los datos originales.  Sólo tendrás en el dataframe 3 variables más, pero deberás ajustar dataLabels y tooltip en el gráfico.
------------------
Hello @a13cas12ve, although it is not the perfect solution, it can work for you.

Standardize the data, and represent the standardized data and keep the dataLabels and the tooltip the reference to the original data. You will only have 3 more variables in the dataframe, but you will have to adjust dataLabels and tooltip in the graph.