Search results

Internationalization in ASP.NET Core Chart control

30 Jul 2021 / 1 minute to read

Chart provide supports for internationalization for below chart elements.

  • Datalabel.
  • Axis label.
  • Tooltip.

For more information about number and date formatter you can refer internationalization.

Globalization

Globalization is the process of designing and developing an component that works in different cultures/locales. Internationalization library is used to globalize number, date, time values in Chart component using labelFormat property in axis.

Numeric Format

In the below example axis, point and tooltip labels are globalized to EUR.

tagHelper
number-format.cs
Copied to clipboard
<ejs-chart id="container" width="60%" title="Average Sales Comparison" locale="ar-AR">
        <e-chart-tooltipsettings enable="true" format="${series.name} <br>${point.x} : ${point.y}"></e-chart-tooltipsettings>
        <e-chart-primaryxaxis title="Year"></e-chart-primaryxaxis>
        <e-chart-primaryyaxis labelFormat="c" 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-marker visible="true" height="10" width="10">
                    <e-series-datalabel visible="true"></e-series-datalabel>
                </e-series-marker>
            </e-series>
            <e-series dataSource="ViewBag.dataSource" xName="x" yName="y1" type="@Syncfusion.EJ2.Charts.ChartSeriesType.Column" name="Product Y">
                <e-series-marker visible="true" height="10" width="10">
                    <e-series-datalabel visible="true"></e-series-datalabel>
                </e-series-marker>
            </e-series>
        </e-series-collection>
        <e-chart-zoomsettings enableMouseWheelZooming="true" mode="XY"></e-chart-zoomsettings>
    </ejs-chart>

<script>
    ej.base.L10n.load({
        'ar-AR': {
            'chart': {
                ZoomIn: 'تكبير',
                ZoomOut: 'تصغير',
                Zoom: 'زوم',
                Pan: 'مقلاة',
                Reset: 'إعادة تعيين',
                ResetZoom: ' زومإعادة تعيين'
            },
        }
    });
</script>
Copied to clipboard
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;
        }