plotly / plotly/react-plotly.js

Horizontal legend entrywidth does not adjust to font size on initial render

Open
#312 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.1k
Forks
138
Avg merge
3d 2h
Merged PRs (30d)
4

Description

When initially rendering the component, when set to orientation "h", the legend entries do not adjust their size correctly based on the font size set in the layout.

Example:

`
export const Test = (): ReactElement => {

  const data : Data[] =[
      {
          x: [1, 2, 3],
          y: [2, 6, 3],
          name: "my example scatter chart",
          type: 'scatter',
          mode: 'lines+markers',
          marker: {color: 'red'},
      },
      {type: 'bar', name:"my example bar chart", x: [1, 2, 3], y: [2, 5, 3]},
  ]

  const layout = {
      width: 1350,
      height: 950,
      hoverlabel: {
          bgcolor: "#555555",
          font: {
              family: "Open Sans",
              size: 14
          }
      },
      legend: {
          x: 0.25,
          y: -0.35,
          orientation: "h" as any,
          font: {
              family: 'Open Sans',
              size: 24,
              color: '#555555'
          },
          entrywidth:0,
      },
      xaxis: {
          showline: false,
          zeroline: false,
          title: {
              text: 'x',
              font: {
                  family: 'Open Sans',
                  size: 14,
                  color: '#555555'
              }
          },
      },
      yaxis: {
          showline: false,
          zeroline: false,
          title: {
              text: 'y',
              font: {
                  family: 'Open Sans',
                  size: 14,
                  color: '#555555'
              }
          }
      }
  }


  return (<Plot
      layout={layout}
      data={data}
  />)

}
`
image

If I adjust the font size property of the layout object after the initial render, it corrects itself.

image

Any guidance or help would be greatly appreciated.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the initial render path for the component and the horizontal legend sizing behavior described in the example. Reproduce the chart with orientation "h" and a 24px legend font, then compare it with the result after changing the font size; done means entry widths match the configured font on the initial render.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
data-visualization, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.