X-axis type lost after restyle
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- JavaScript
- Estrellas
- 18.3k
- Forks
- 2k
- Merge medio
- 2 d 12 h
- PR fusionados (30 d)
- 28
Descripción
If i create a bar chart with a categorical x-axis, where the x-values are strings of digits, then restyle it with new y-values, the categoricality of the x-axis is lost, and it becomes linear, as if the type had been freshly inferred from the values.
Here is a self-contained example (i'm afraid i don't have a codepen account):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Restyle</title>
<script src="https://cdn.plot.ly/plotly-latest.js"></script>
<script>
addEventListener("DOMContentLoaded", () => {
const plot = document.getElementById("plot");
Plotly.newPlot(plot,
{
data: [{
type: "bar",
x: ["2", "5", "10", "30", "50"],
y: [1, 2, 3, 4, 5]
}],
layout: {
xaxis: {type: "category"}
},
config: {
responsive: true
}
});
document.getElementById("restyle").addEventListener("click", () => {
Plotly.restyle(plot, {y: [[5, 4, 3, 2, 1]]}, 0);
});
});
</script>
</head>
<body>
<div id="plot"></div>
<button id="restyle">Restyle</button>
</body>
</html>
When the page loads, the x-axis is correctly categorical, but when you click the button, it becomes incorrectly linear.
I believe this is the same problem as described in the forum post "X-axis “category” type not honored after Plotly.restyle".
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza ejecutando el ejemplo HTML autocontenido con Plotly.newPlot y Plotly.restyle; después, sigue la ruta de restyle que actualiza el gráfico de barras. La tarea estará terminada cuando el eje x siga siendo categórico después de reemplazar los valores de y, en lugar de volver a inferirse como lineal.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- data-visualization
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100