Search results

Localization in ASP.NET Core Chart control

Localization library allows to localize the default text content of Chart. In Chart component, it has the static text on some features(like zooming toolbars) and this can be changed to any other culture(Arabic, Deutsch, French, etc) by defining the locale value and translation object.

Locale key words Text to display
Zoom Zoom
ZoomIn ZoomIn
ZoomOut ZoomOut
Reset Reset
Pan Pan
ResetZoom Reset Zoom

To load translation object in an application use load function of L10n class.

For more information about localization, refer this localization

tagHelper
localization.cs
<ejs-chart id="container" width="60%" title="Average Sales Comparison" locale="ar-AR">
        <e-chart-zoomsettings enableMouseWheelZooming="true" enableSelectionZooming="true" enablePinchZooming="true"
          enableDeferredZooming="true"></e-chart-zoomsettings>
        <e-chart-primaryxaxis title="Year"></e-chart-primaryxaxis>
        <e-chart-primaryyaxis  title="Sales Amount in Millions"></e-chart-primaryyaxis>
        <e-series-collection>
            <e-series dataSource="ViewBag.dataSource" xName="x" yName="y" type="@Syncfusion.EJ2.Charts.ChartSeriesType.Column" name="Product X"></e-series>
            <e-series dataSource="ViewBag.dataSource" xName="x" yName="y1" type="@Syncfusion.EJ2.Charts.ChartSeriesType.Column" name="Product Y"></e-series>
        </e-series-collection>
    </ejs-chart>
<script>
    L10n.load({
        'ar-AR': {
            'chart': {
                ZoomIn: 'تكبير',
                ZoomOut: 'تصغير',
                Zoom: 'زوم',
                Pan: 'مقلاة',
                Reset: 'إعادة تعيين',
                ResetZoom: ' زومإعادة تعيين'
            },
        }
    });
</script>
public ActionResult Index()
        {
            List<InternalChartData> chartData = new List<InternalChartData>
            {
             new InternalChartData{ x= 1900, y= 4,   y1= 2.6 },
             new InternalChartData{ x= 1920, y= 3.0, y1= 2.8 },
             new InternalChartData{ x= 1940, y= 3.8, y1= 2.6}, 
             new InternalChartData{ x= 1960, y= 3.4, y1= 3 },
             new InternalChartData{ x= 1980, y= 3.2, y1= 3.6 }, 
             new InternalChartData{ x= 2000, y= 3.9, y1= 3 }
            };
            ViewBag.dataSource = chartData;
            return View();
        }
        public class InternalChartData
        {
            public double x;
            public double y;
            public double y1;
        }