-
Notifications
You must be signed in to change notification settings - Fork 71
How to change localization? #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Try to add something like |
I have tried the following with no success: I then first tried setting the locale prop on the component without success:
And then by setting a config prop on the component, which again was unsuccesful:
|
Try to import plotly-locale-da.js as weel as Plotly and add:
|
That does not seem to work either. |
Any progress on this? |
I think the issue is simply that calling const plotly = require('plotly.js');
Plotly.setPlotConfig({
staticPlot: true,
showTips: false,
}); should both make charts non-interactive and disable hint tooltips (such as the one about double-clicking to revert zoom when first zooming on a chart), but it does neither. Would it be possible to add a |
I've created a pull request for the config prop. I've realized that one can just pass additional props that get merged into the config object created internally, but passing a user config object enables keeping this encapsulated and to potentially reuse it, as well as keeping things tidier. This does, however, not yet resolve this actual isse as simply passing a locale attribute inside the object doesn't work; the corresponding locale data JS file still needs to be loaded, I assume, in the context of the Plotly Vue component prior to calling Plotly.newPlot(). |
So, without wanting to further spam this issue, what works is adding this right before Plotly.register(require('plotly.js/lib/locales/da')); This in combination with either adding I think that on the component's side, this could be implemented by having the component look at Still, this would probably leave the issue of the locale data getting thrown out by any tree-shaking happening because the module reference is non-static. One way to avoid this might consist in adding props for all supported locales ( |
This solution help me. In your component need:
<template>
<vue-plotly
:data="data"
:layout="layout"
:displayModeBar="options.displayModeBar"
:displaylogo="options.displaylogo"
:modeBarButtonsToRemove="options.modeBarButtonsToRemove"
:locale="options.locale"
/>
</template>
<script>
import "plotly.js/dist/plotly-locale-ru";
import { Plotly } from "vue-plotly";
export default {
name: "PlotlyLocale",
components: {
VuePlotly: Plotly
},
data() {
return {
layout: {
width: 800,
height: 660,
margin: { l: 10, r: 10, b: 10, t: 90 },
title: "Locale change test",
mode: "lines",
showlegend: true
},
options: {
locale: "ru",
displayModeBar: true,
displaylogo: false,
modeBarButtonsToRemove: [
"sendDataToCloud",
"select2d",
"lasso2d",
"autoScale2d",
"hoverClosestCartesian",
"toggleSpikelines",
"hoverCompareCartesian",
"resetCameraLastSave3d",
"tableRotation",
"hoverClosest3d"
]
},
data: []
};
}
</script> |
Tried this, differences were locale import ( import "plotly.js-locales/pt-br"; ) and locale itself ( locale: "pt-BR" ), but no changes in the plot, axis number still not formatted in "pt-BR". Locale import seems to work properly (object imported is moduleType: "locale") still missing something to make it work |
Hi, @ncarneiro ! You need to change your import from |
Hi @kulemeevag you're completely right. Took me some time to realize locale actually changed since month day, year isn't how it is used in pt-BR (but I've corrected these with tickformatstops and hoverformat). Thank you very much. |
Hi, @ncarneiro! Glad to help you! |
Hey, is it possible to change the localization?
Plotly.js descripes how to change it here: https://github.com/plotly/plotly.js/tree/master/dist#to-include-localization
but from what I can see it is not possible to access the Plotly instance that I need to call
.setPlotConfig
on.The text was updated successfully, but these errors were encountered: