plotly / plotly/react-plotly.js

Can't disable sunburst default animation

オープン
#331 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
JavaScript
スター
1.1k
フォーク
138
平均マージ
3日 2時間
マージ済み PR(30日)
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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Plot コンポーネントの onSunburstClick の処理と、Plotly の sunburst のクリック動作から始めます。動作している onClick コールバックと比較し、デフォルトのズームを防ぐための焦点を絞った回帰テストを特定します。コールバックがイベントを受け取り続けながら、デフォルトの sunburst 動作を抑制できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, nextjs, react
領域
data-visualization, frontend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。