Internationalization in Vue Circular Gauge component
11 Jun 202417 minutes to read
Circular Gauge provides internationalization support for below elements.
- Axis Labels
- Tooltip
For more information about number formatter, you can refer internationalization.
Globalization
Globalization is the process of designing and developing a component that works in different cultures/locales.
Internationalization library is used to globalize number in Circular Gauge component using format property in labelStyle.
Numeric Format
In the below example, axis labels are globalized to EUR.
<template>
<div id="app">
<div class='wrapper'>
<ejs-circulargauge :axes='axes'>
</ejs-circulargauge>
</div>
</div>
</template>
<script setup>
import { CircularGaugeComponent as EjsCirculargauge } from "@syncfusion/ej2-vue-circulargauge";
import { loadCldr, L10n, setCulture, setCurrencyCode } from '@syncfusion/ej2-base';
setCulture('de');
setCurrencyCode('EUR');
const axes = [{
labelStyle: {
position: 'Inside',
//Label format set as currency.
format: 'c'
}
}]
</script>
<style>
.wrapper {
max-width: 300px;
margin: 0 auto;
}
</style>
<template>
<div id="app">
<div class='wrapper'>
<ejs-circulargauge :axes='axes'>
</ejs-circulargauge>
</div>
</div>
</template>
<script>
import { CircularGaugeComponent } from "@syncfusion/ej2-vue-circulargauge";
import { loadCldr, L10n, setCulture, setCurrencyCode } from '@syncfusion/ej2-base';
setCulture('de');
setCurrencyCode('EUR');
export default {
name: "App",
components: {
"ejs-circulargauge": CircularGaugeComponent,
},
data: function () {
return {
axes: [{
labelStyle: {
position: 'Inside',
//Label format set as currency.
format: 'c'
}
}]
}
}
};
</script>
<style>
.wrapper {
max-width: 300px;
margin: 0 auto;
}
</style>
Right-to-left
Circular Gauge can render its elements from right to left, which improves the user experience for certain language users. To do so, set the enableRtl property to true. When this property is enabled, elements such as the tooltip and legend will be rendered from right to left. Meanwhile, the axis can be rendered from right to left by setting the direction property to AntiClockWise. For more information on axis, click here.
The following example illustrates the right to left rendering of the Circular Gauge.
<template>
<div id="app">
<div class='wrapper'>
<ejs-circulargauge :axes='axes' :legendSettings='legendSettings' :tooltip='tooltip' :enableRtl='enableRtl'>
</ejs-circulargauge>
</div>
</div>
</template>
<script setup>
import { provide } from "vue";
import { CircularGaugeComponent as EjsCirculargauge, GaugeTooltip, Legend } from "@syncfusion/ej2-vue-circulargauge";
const enableRtl = true;
const tooltip = {
type: ['Pointer', 'Range'],
format: 'Pointer : {value} ',
enable: true,
enableAnimation: false
};
const legendSettings = {
visible: true,
position: 'Right'
};
const axes = [{
direction: 'AntiClockWise',
lineStyle: { width: 10, color: 'transparent' },
labelStyle: {
position: 'Inside', useRangeColor: false,
font: {
size: '12px',
color: '#424242',
fontFamily: 'Roboto',
fontStyle: 'Regular'
}
},
majorTicks: {
height: 10,
offset: 5,
color: '#9E9E9E'
},
minorTicks: { height: 0 },
startAngle: 210,
endAngle: 150,
minimum: 0,
maximum: 120,
radius: '80%',
ranges: [{
start: 0,
end: 40,
color: '#30B32D'
},
{
start: 40,
end: 80,
color: '#FFDD00'
},
{
start: 80,
end: 120,
color: '#F03E3E'
}],
pointers: [{
animation: { enable: false },
value: 65,
radius: '60%',
color: '#757575',
pointerWidth: 8,
cap: {
radius: 7,
color: '#757575'
},
needleTail: {
length: '18%'
}
}]
}]
provide('circulargauge', [GaugeTooltip, Legend]);
</script>
<style>
.wrapper {
max-width: 300px;
margin: 0 auto;
}
</style>
<template>
<div id="app">
<div class='wrapper'>
<ejs-circulargauge :axes='axes' :legendSettings='legendSettings' :tooltip='tooltip' :enableRtl='enableRtl'>
</ejs-circulargauge>
</div>
</div>
</template>
<script>
import { CircularGaugeComponent, GaugeTooltip, Legend } from "@syncfusion/ej2-vue-circulargauge";
export default {
name: "App",
components: {
"ejs-circulargauge": CircularGaugeComponent
},
data: function () {
return {
enableRtl: true,
tooltip: {
type: ['Pointer', 'Range'],
format: 'Pointer : {value} ',
enable: true,
enableAnimation: false
},
legendSettings: {
visible: true,
position: 'Right'
},
axes: [{
direction: 'AntiClockWise',
lineStyle: { width: 10, color: 'transparent' },
labelStyle: {
position: 'Inside', useRangeColor: false,
font: {
size: '12px',
color: '#424242',
fontFamily: 'Roboto',
fontStyle: 'Regular'
}
},
majorTicks: {
height: 10,
offset: 5,
color: '#9E9E9E'
},
minorTicks: { height: 0 },
startAngle: 210,
endAngle: 150,
minimum: 0,
maximum: 120,
radius: '80%',
ranges: [{
start: 0,
end: 40,
color: '#30B32D'
},
{
start: 40,
end: 80,
color: '#FFDD00'
},
{
start: 80,
end: 120,
color: '#F03E3E'
}],
pointers: [{
animation: { enable: false },
value: 65,
radius: '60%',
color: '#757575',
pointerWidth: 8,
cap: {
radius: 7,
color: '#757575'
},
needleTail: {
length: '18%'
}
}]
}]
}
},
provide: {
circulargauge: [GaugeTooltip, Legend]
}
};
</script>
<style>
.wrapper {
max-width: 300px;
margin: 0 auto;
}
</style>