• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

176
Views
¿Cómo conectar las líneas del gráfico de radar Plotly JS?

He estado trazando gráficos de radar en html usando Plotly js y tengo algunos problemas.

 <!doctype html> <html lang="en-US"> <head> <meta charset="UTF-8"> <script src="https://cdn.plot.ly/plotly-2.8.3.min.js"></script> <style> #radar { position: absolute; } </style> </head> <body> <div id="radar"></div> <script> WS = document.getElementById('radar') Plotly.newPlot( WS, [{ type: 'scatterpolar', r: [35,20,20,20,30], theta: ["A", "B", "C", "D", "E"], fill: "none", name: "Band 1", line: { color: "red" } },{ type: 'scatterpolar', r: [25,12,12,15,35], theta: ["A", "B", "C", "D", "E"], fill: "toself", name: "Band 2", line: { color: "blue" } }], { polar: { radialaxis: { showticklabels: false, range: [0, 40] } }, margin: {t:0} } ) </script> </body> </html>

Mi principal preocupación es poder conectar la línea final entre la Variable E y A. En los ejemplos que proporciona Plotly, este parece ser el comportamiento predeterminado, pero no puedo averiguar si he agregado una opción que deshabilita esto o si la versión de distribución de Plotly que estoy usando no lo permite. Estoy usando la versión exacta recomendada por Plotly aquí .

También me gustaría encontrar una manera de manipular la etiqueta de cada punto desde los valores actuales de r & theta a algo como value & variable , avíseme si tiene una solución para esto.

Agradezco la ayuda

almost 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

He resuelto mis dos preguntas con las siguientes ediciones:

Para hacer la conexión final entre el primer y el último punto, agregamos las coordenadas del primer punto al final de los elementos 'r' y 'theta'. Asi que,

 r: [35,20,20,20,30], theta: ["A", "B", "C", "D", "E"]

se convierte

 r: [35,20,20,20,30,35], theta: ["A", "B", "C", "D", "E", "A"]

Para cambiar la etiqueta flotante de theta y r , usamos el elemento hovertemplate . Entonces, agregue en la línea:

 hovertemplate: 'Variable: %{theta}, Value: %{r}'

El producto final:

 <!doctype html> <html lang="en-US"> <head> <meta charset="UTF-8"> <script src="https://cdn.plot.ly/plotly-2.8.3.min.js"></script> <style> #radar { position: absolute; } </style> </head> <body> <div id="radar"></div> <script> WS = document.getElementById('radar') Plotly.newPlot( WS, [{ type: 'scatterpolar', r: [35,20,20,20,30, 35], theta: ["A", "B", "C", "D", "E", "A"], fill: "none", name: "Band 1", line: { color: "red" }, hovertemplate: 'Variable: %{theta}, Value: %{r}' },{ type: 'scatterpolar', r: [25,12,12,15,35,25], theta: ["A", "B", "C", "D", "E", "A"], fill: "toself", name: "Band 2", line: { color: "blue" }, hovertemplate: 'Variable: %{theta}, Value: %{r}' }], { polar: { radialaxis: { showticklabels: false, range: [0, 40] } }, margin: {t:0} } ) </script> </body> </html>

almost 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error