plotly / plotly/react-plotly.js
Cannot access customdata array
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 1.1k
- Fork
- 138
- Merge medio
- 3g 2h
- PR unite (30g)
- 4
Descrizione
I can access customdata without an issue if customdata is not an array, hovertemplate formats the x points according to the 1st function correctly.
customdata: d.x.map((x) => {
const years = Math.floor(x);
const months = Math.floor(12 * (x % 1));
if (years === 0) return `${months}m`;
if (months === 0) return `${years}y`;
return `${years}y ${months}m`;
}),
hovertemplate: `<b>${eyeNames[i]}</b><br>
<i>Risk</i>: <br>
<i>Risk</i>: %{y:.2p}<br>
<i>Time</i>: %{customdata}<extra></extra>`,
}));
To add another function to customdata, according to the documentation i need to convert customdata into an array, which i have done, but the hovertemplate no longer picks up customdata.
customdata: [
d.x.map((x) => {
const years = Math.floor(x);
const months = Math.floor(12 * (x % 1));
if (years === 0) return `${months}m`;
if (months === 0) return `${years}y`;
return `${years}y ${months}m`;
}),
d.y.map((y) => {
let p = y.toFixed(2);
if (inverse1 === 0) return p;
if (inverse1 === 1) {
p = null;
}
return p;
})
],
hovertemplate: `<b>${eyeNames[i]}</b><br>
<i>Risk</i>: %{customdata[1]}<br>
<i>Risk</i>: %{y:.2p}<br>
<i>Time</i>: %{customdata[0]}<extra></extra>`,
}));
In hovertemplate if i write %{fullData.customedata} it picks up the array, but the functions map out every point instead of the single point hovered on the graph.
hovertemplate: `<b>${eyeNames[i]}</b><br>
<i>Risk</i>: %{fullData.customdata[1]}<br>
<i>Risk</i>: %{y:.2p}<br>
<i>Time</i>: %{fullData.customdata[0]}<extra></extra>`,
}));
What is the correct syntax here to access the customdata array and have the functions manipulate the hovered point on the graphs only, like in the first image, with the time variable. Thanks.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia confrontando le due strutture customdata e i riferimenti a hovertemplate mostrati nell'issue. Verifica il comportamento di customdata e hovertemplate a livello di punto in Plotly, quindi verifica il risultato rispetto agli esempi nel report. Il lavoro è completato quando il punto su cui si passa il cursore mostra i valori previsti di tempo e rischio senza espandere gli array mappati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, react
- Ambito
- data-visualization, frontend
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 28/100