plotly / plotly/react-plotly.js

Localization

Open
#99 10 comments 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

Hello 👋
I am having trouble with localization.
I have looked at plotly.js tests for some inspiration and I've seen that config.locale and config.locales are being set here and passed to newPlot fn. But it didn't really help me.

My Chart components looks like this:

import * as Plotly from 'plotly.js'
import * as csDictionary from 'plotly.js/lib/locales/cs.js'
import * as React from 'react'
import * as Plot from 'react-plotly.js'

Plotly.register(csDictionary)
Plotly.setPlotConfig({ locale: 'cs' })

const trace1 = {
  x: [0, 1, 2],
  y: [1, 1, 1],
  mode: 'lines+markers+text',
  name: 'Lines, Markers and Text',
  text: ['Text A', 'Text B', 'Text C'],
  textposition: 'top right',
  textfont: {
    family: 'sans serif',
    size: 18,
    color: '#1f77b4',
  },
  type: 'scatter',
}

class Chart extends React.Component {
  render() {
    return (
      <Plot
        config={{ locale: 'cs' }}
        data={[trace1]}
        layout={{
          width: 800,
          height: 400,
          title: 'A Fancy Plot',
        }}
      />
    )
  }
}
export default Chart

❓ Any ideas how to make this work?

Localization is crucial for me and it looks that it is somehow supported, but I just cannot figure how to set it up.

Thanks 🙏

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 by reproducing the localization setup shown in the issue, including Plotly.register, Plotly.setPlotConfig, config.locale, and the React Chart component. Compare the configured locale with the rendered chart and determine what change is needed for Czech localization to work; done means the chart's localized UI is visibly applied.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react, typescript
Domain
data-visualization, frontend, internationalization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.