score:0
Accepted answer
You could probably use something like this:
import {Component} from '@angular/core';
import {TranslateService} from '@ngx-translate/core';
@Component({
selector: 'app',
template: `
<canvas baseChart
[labels]="chartLabels"
chartType="pie">
</canvas>
`
})
export class AppComponent {
constructor(private translate: TranslateService) {};
chartLabels = ["korea", "tokyo", "sydney"]
translatedChartLabels = []
ngOnInit() {
this.translate.get(this.chartLabels)
.subscribe(translations => {
/* translations is now an object with {
"key1": "translated value",
"key1": "translated value" }
and needs to be converted to an array again. */
this.translatedChartLabels = Object.values(translations)
});
}
}
<canvas baseChart
[labels]="translatedChartLabels"
chartType="pie">
</canvas>
Source: stackoverflow.com
Related Query
- Changing the label of chart
- I am using chart js to draw a chart. I did everything right but i don't know why the x axis and y axis label is not comming in chart. code below
- Chart JS show multiple data points for the same label
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- Remove the label and show only value in tooltips of a bar chart
- PrimeNg bar chart how to show a label for the y-axis
- Add a custom label to the top or bottom of a stacked bar chart
- chartJS label on each side of the chart
- How to change the label and grid line position on a timeseries chart in Chart.js 3?
- How to rotate the Label text in doughnut chart slice vertically in chart.js canvas, Angular 12?
- Chart JS, ng2-Charts - How to make the label to the right of pie chart instead on top?
- increase the label size of a line chart in chart.js
- show label inside the chart - angular.js and chart.js
- Chart.js reduce canvas size without changing the size of the chart
- How to show symbols after the label and before the numeric value using chart.js Bar chart in Angular
- Vue-Charts label numbers to the side of a bar chart
- How do i have a single Chart.vue component instead of different chart components and then display charts from it by changing id of the API
- Is there a more optimized way to implement the change function of chart js upon changing the dropdowns?
- Chartjs: get the label title on the radar's chart tooltip
- Modify the x-axis label in chart js
- data in charts of charts.js is changing when I click in the line chart
- Chart.js bar chart change the label position X-axis
- Changing the opacity of the colour on the Polar Area chart
- How can I put my label on the right hand side of my chart in Chartjs
- ChartJS - change chart type by changing y-axis Label
- ChartJS fails to render one of the lines in cartesian chart following update after change to max Y axis label value
- Getting the HTML code of a chart created by chart.js
- How can i get the Chart JS Bar Graph Bar Label and Value on click?
- remove undefined label in the upper part of a chart
- Chart js - Line chart - How to hide the data label on the line?
More Query from same tag
- ChartJs line chart - display permanent icon above some data points with text on hover
- Resize Chart Independently From Legend in ChartJS for Canvas Download
- I am Creating pie chart using Chartjs 2.6.0. I want to show label on Slices
- PHP string data passed to Chart.js not rendering well
- chart.js time x-axis - start ticks at specific time
- Is there any way I can customize my chartjs
- Remove 0% from pie chart
- Blazor server-side Chartjs
- chart js bar chart not displaying array
- Which jquery plugin can create a stacked column chart?
- Live update the charts.js graph on a web page using json data received from a remote server
- Can we remove bar chart line on click on pie chart legend label?
- Where is the appropriate place to instantiate a javascript widget/chart/utility when using angular.js?
- Trying to refresh label when click on it. Cannot read property '_meta' of undefined"
- How to apply gradient color in chart.js?
- chartJS label on each side of the chart
- How to make labels clickable in angular-chart
- decrease bar spacing chartJS v2
- Angular Chart Js legends click event not working
- Mixed chart not showing both charts simultaneously chart.js
- Prevent the wiping of an Array after routing Angular.js
- Control Scaling of Canvas When dragged out of chart limit
- Link in ChartJS tooltip not clickable
- Chart.js load new data
- Why does one chart overlays another (chart.js)?
- In chart.js how can I change the x axis on my line \chart from January-December to October-September? Basically, fiscal year instead of calendar year
- chartjs datalabels change font and color of text displaying inside pie chart
- Vue watch not noticing changes on component prop
- Mark X value on Chart Js graph
- Chartjs hide data point labels