Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different scales for different variables in polar charts #810

Open
a13cas12ve opened this issue Feb 23, 2024 · 1 comment
Open

Different scales for different variables in polar charts #810

a13cas12ve opened this issue Feb 23, 2024 · 1 comment

Comments

@a13cas12ve
Copy link

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
Copy link

robertogilsaura commented Feb 25, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants