Skip to content

Localization #99

Open
Open
@mrceperka

Description

@mrceperka

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 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions