plotly / plotly/react-plotly.js
Can't disable sunburst default animation
還沒有人認領這個 Issue。
- 主要語言
- JavaScript
- 星號
- 1.1k
- 分支
- 138
- 平均合併
- 3 天 2 小時
- 30 天內合併 PR
- 4
描述
Using NextJS 13, passing onSunburstClick={() => false} to the Plot component does not disable the default behaviour of clicking in a sunburst node and zooming in to that node.
The component I'm creating:
import {
Content,
ContextualHelp,
Flex,
Heading,
Slider,
} from '@adobe/react-spectrum';
import plotly, { Font, PlotData } from 'plotly.js';
import { useState } from 'react';
import createPlotComponent from 'react-plotly.js/factory';
const Plot = createPlotComponent(plotly);
interface SunburstPlotData extends Partial<PlotData> {
outsidetextfont?: Partial<Font>;
leaf?: { opacity?: number };
maxdepth?: number;
}
// NOTE: to access the taxon id:
// e.points[0].customdata
export default function TaxonSunburst() {
const [maxDepthValue, setMaxDepthValue] = useState<number>(3);
const data: SunburstPlotData[] = [
{
type: 'sunburst',
// NOTE: this is for the taxon names
labels: [
'Eve',
'Cain',
'Seth',
'Enos',
'Noam',
'Abel',
'Awan',
'Enoch',
'Azura',
],
// NOTE: this is going to be used for the taxids
customdata: [1, 2, 3, 4, 5, 6, 7, 8, 9],
// NOTE: parent of each taxon
parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve'],
// NOTE: paper counts per taxon
values: [10, 14, 12, 10, 2, 6, 6, 4, 4],
outsidetextfont: { size: 20, color: '#377eb8' },
leaf: { opacity: 0.4 },
marker: { line: { width: 2 } },
maxdepth: maxDepthValue,
},
];
return (
<Flex
direction="column"
alignItems="center"
marginY="size-200"
maxWidth="100%"
>
<Slider
label="Depth"
minValue={1}
maxValue={3}
value={maxDepthValue}
onChange={setMaxDepthValue}
isFilled
contextualHelp={
<ContextualHelp>
<Heading>What is depth?</Heading>
<Content>
Depth controls the maximum taxonomic level that is shown in the
plot.
</Content>
</ContextualHelp>
}
/>
<Plot
data={data}
style={{ width: '100%' }}
layout={{ autosize: true }}
useResizeHandler
onSunburstClick={() => false}
/>
</Flex>
);
}
In order for SSR to work properly, I'm loading the component like so (from my pages/index.tsx):
// ...
import dynamic from 'next/dynamic';
// ...
const TaxonSunburst = dynamic(import('../components/TaxonSunburst'), {
ssr: false,
loading: () => (
<Flex
justifyContent="center"
marginY="size-200"
>
<ProgressCircle
aria-label="Loading sunburst plot"
isIndeterminate
/>
</Flex>
),
});
The onClick event works properly. Also, modifying onSunburstClick with something like onSunburstClick={() => alert("test")} also works. I would like to disable the default behaviour of the sunburst plots.
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 Plot 元件的 onSunburstClick 處理和 Plotly 的 sunburst 點擊行為著手。將其與正常運作的 onClick callback 進行比較,並找出一個用於防止預設縮放的聚焦回歸測試。當 callback 能夠抑制預設的 sunburst 行為,同時仍能接收事件時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- javascript, nextjs, react
- 領域
- data-visualization, frontend
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100