Dunivivi
Posts: 14
Joined: Mon Mar 20, 2023 1:56 pm

Internationalize

How can we internationalize text label from drilldown ? (Highchart pie)
jakub.s
Posts: 1233
Joined: Fri Dec 16, 2022 11:45 am

Re: Internationalize

Hi,

Thanks for the question.

You can format the drilldown labels with drilldown.breadcrumbs.formatter function.

Here's a demo: https://jsfiddle.net/BlackLabel/53w4ug2L/

API: https://api.highcharts.com/highcharts/d ... .formatter

Let me know if that's what you were looking for.

Best regards,
Jakub
Jakub
Highcharts Developer
Dunivivi
Posts: 14
Joined: Mon Mar 20, 2023 1:56 pm

Re: Internationalize

I mean not breadcrumb, but name of series. Sorry for incorrect aproach of answer
jakub.s
Posts: 1233
Joined: Fri Dec 16, 2022 11:45 am

Re: Internationalize

Hmm, I'm not sure I fully understand - you can change the series name by simply setting the series.name.

Here's a demo: https://jsfiddle.net/BlackLabel/wr2pz68g/
API: https://api.highcharts.com/highcharts/series.line.name

Is that what you're looking for?
Jakub
Highcharts Developer
Dunivivi
Posts: 14
Joined: Mon Mar 20, 2023 1:56 pm

Re: Internationalize

Doesnt exists something like tooltips code?
tooltip: {
headerFormat: '<span style="font-size:10px">{series.name}</span><br>',
pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
},

I need to change series.name dynamic, to translate it in 3 languages, depends by setted LNG.
jakub.s
Posts: 1233
Joined: Fri Dec 16, 2022 11:45 am

Re: Internationalize

Sure,

Instead of format strings, I'd recommend you use tooltip.formatter function where you can place some additional logic.

Here's a demo: https://jsfiddle.net/BlackLabel/6tyrsd5c/

You can read more about this function in the API: https://api.highcharts.com/highcharts/tooltip.formatter

You can also use spans, apply colors, and add header and footer within this function.

It all depends if your tooltip is split or shared.

Best regards,
Jakub
Jakub
Highcharts Developer
Dunivivi
Posts: 14
Joined: Mon Mar 20, 2023 1:56 pm

Re: Internationalize

For drilldown series name we have such a function ? I read API, but nothing about drilldown. I need to translate like in your example, name of drilldown series.
drilldown: {
series: [{
type: 'pie',
name: 'Angular versions',
id: 'esempla-documents',
data: [
['Active', 360],
['Spre stergere', 100],
['Blocate', 40],
]
}]
}

And here not Angular versions, for example, but something else, depends by language.
jakub.s
Posts: 1233
Joined: Fri Dec 16, 2022 11:45 am

Re: Internationalize

Sure, it works the same.

tooltip.formatter applies to all of the series, even the drilled-down ones.

Just click on "NAME1" and hover over the drilled-down series: https://jsfiddle.net/BlackLabel/cnmh9L6z/

The tooltip formatter function also applies so you can have your own translating method in there.

Drilldown series acts like a normal series.

Regards,
Jakub
Jakub
Highcharts Developer
Dunivivi
Posts: 14
Joined: Mon Mar 20, 2023 1:56 pm

Re: Internationalize

Works fine, thanks !
Last question and sorry for troubles ^_^
How can i acces this.language variable in formatter function and can we also change not only tooltip, but current name of axis through same approach ? ( where's now 123, 1345)
Here's live code : https://stackblitz.com/edit/highcharts- ... mponent.ts
jakub.s
Posts: 1233
Joined: Fri Dec 16, 2022 11:45 am

Re: Internationalize

Hi,

Sure, no problem :)

You can update the chart with chart.update. If you want to update a series or the yAxis, you could use series.update or yAxis.update methods after your language changes.

Here's a demo: https://jsfiddle.net/BlackLabel/59Lwuj46/

API:
- https://api.highcharts.com/class-refere ... ies#update
- https://api.highcharts.com/class-refere ... xis#update

Best regards,
Jakub
Jakub
Highcharts Developer
Dunivivi
Posts: 14
Joined: Mon Mar 20, 2023 1:56 pm

Re: Internationalize

I have not such variable like yours "chart", to acces language. Does exists approach for mine code from previous link ?
jakub.s
Posts: 1233
Joined: Fri Dec 16, 2022 11:45 am

Re: Internationalize

I'll pass your topic to a collegue of mine who works with Angular and he'll try to fix it on your demo.
Jakub
Highcharts Developer
Dunivivi
Posts: 14
Joined: Mon Mar 20, 2023 1:56 pm

Re: Internationalize

Thank YOU, I’m waiting for response :)
User avatar
dawid.d
Posts: 848
Joined: Thu Oct 06, 2022 11:31 am

Re: Internationalize

Hi Dunivivi,

In the Angular wrapper, the easiest way to get to the Highcharts chart object is to declare a parameter and overwrite it in the load callback option.

Demo: https://stackblitz.com/edit/highcharts- ... mponent.ts

If I may clarify any matters I am available at your convenience.
Best regards!
Dawid Draguła
Highcharts Developer
Dunivivi
Posts: 14
Joined: Mon Mar 20, 2023 1:56 pm

Re: Internationalize

All works great, dawid, thanks. But last one question, how can i redraw only drilldown series name if they are equal with "deleted", for example?
To clarify: If it's deleted, yes? I want to display "Bin". Else, if it's "active", i want to display "Active". I need this, cause i got drilldown data from backend API and they are written as in database. Thanks for help!

Return to “Highcharts Usage”