guillaume
guillaume

Reputation: 103

How to change labels on the control button in NVD3?

Here is my problem: on the NVD3 charts, there are sometimes options like "Stacked" or "Grouped" with radio buttons.

What I would like to do is to change the label of these buttons. As I'm french, I would like to have "Groupé" in place of "Grouped" and "Empilé" in place of "Stacked". Don't know if I'm clear?

Is it possible? I already took a look in the different js files like "legend", tooltips"... but it wasn't really helpful (for the javascript and nvd3 newbie I am...).

Thank's for your answers!

Upvotes: 1

Views: 955

Answers (2)

Escher
Escher

Reputation: 5786

Just to bring this answer up to date: in version 1.8 you can do:

chart = nv.models.multiBarChart()
    .controlLabels({"grouped":"Groupé","stacked":"Empilé"})
    // add your other chart parameters, eg color, margin etc here
;

Upvotes: 2

Lars Kotthoff
Lars Kotthoff

Reputation: 109242

The strings for those labels are unfortunately hardcoded in the source (in the respective file in models/), so you would have to change the source. The generated control elements with the text have no specific ID or class such that selecting and changing them dynamically is not really an option.

Your best bet is to change the source. Just search the Javascript files for the strings you want to change.

Upvotes: 3

Related Questions