plotly / plotly/react-plotly.js
Cannot access customdata array
還沒有人認領這個 Issue。
- 主要語言
- JavaScript
- 星號
- 1.1k
- 分支
- 138
- 平均合併
- 3 天 2 小時
- 30 天內合併 PR
- 4
描述
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.
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先比較 issue 中顯示的兩種 customdata 形狀和 hovertemplate 參照。檢查 Plotly 的點層級 customdata 和 hovertemplate 行為,然後根據報告中的範例驗證結果。完成的標準是,游標停留的點會顯示預期的時間值和風險值,且不會展開映射後的陣列。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- javascript, react
- 領域
- data-visualization, frontend
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 28/100