How to apply custom fonts for legend in React Chart?
This article explains how to customize the legend font in React Chart.
Customize the font of legend
You can set a custom font family to all the text elements in the chart. You can easily customize the legend font by using the fontFamily, fontWeight, fontStyle, size, and color properties within the textStyle property of the legend.
In the following code example, the legend font is customized by using the fontStyle, fontWeight, and color properties.
Index.js
import { createRoot } from 'react-dom/client';
import * as React from 'react';
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Legend, Category, ColumnSeries,
 Highlight, DataLabel } from '@syncfusion/ej2-react-charts';
const Column = () => {
 return (
       <chartcomponent id="charts" legendsettings="{{" visible:="" true,="" position:="" 'top',="" enablehighlight:="" textstyle:="" {="" fontstyle:="" 'italic',="" fontweight:="" '800',="" color:="" 'blue'="" }="" }}="" primaryxaxis="{{" valuetype:="" 'category',="" interval:="" 1,="" title:="" 'country'="" primaryyaxis="{{" 'medal="" count',="" maximum:="" 50,="" 10="" tooltip="{{" enable:="" header:="" '<b="">${point.tooltip}',
           shared: true
         }}
         title="Olympic Medal Counts - RIO"
         titleStyle={{
           position: 'Top',
           size: '16px',
           fontStyle: 'Arial',
           fontWeight: '700'
         }}
       >
         <inject services="{[ColumnSeries," legend,="" category,="" highlight,="" datalabel]}="">
         <seriescollectiondirective>
           <seriesdirective datasource="{data1}" xname="x" yname="y" name="Gold" type="Column" columnwidth="{0.8}" marker="{{" datalabel:="" {="" visible:="" true,="" fill:="" '#1ac9e6',="" rx:="" 0,="" ry:="" position:="" 'outer'="" }="" }}="">
           <seriesdirective datasource="{data2}" xname="x" yname="y" name="Silver" type="Column" columnwidth="{0.8}" marker="{{" datalabel:="" {="" visible:="" true,="" fill:="" '#da4cb2',="" rx:="" 0,="" ry:="" position:="" 'outer'="" }="" }}="">
           <seriesdirective datasource="{data3}" xname="x" yname="y" name="Bronze" type="Column" columnwidth="{0.8}" marker="{{" datalabel:="" {="" visible:="" true,="" fill:="" '#edbb40',="" rx:="" 0,="" ry:="" position:="" 'outer'="" }="" }}="">
         </seriesdirective></seriesdirective></seriesdirective></seriescollectiondirective>
       </inject></chartcomponent>
     
   
 );
};
export default Column;
const root = createRoot(document.getElementById('sample'));
root.render(<column>);
The following screenshot illustrates the output of the above code snippet.
Screenshot:
Refer to the working sample for additional details and implementation: View Sample in Stackblitz
Conclusion
We hope you enjoyed learning how to customize the legend font in React Chart Component.
You can refer to our React Chart feature tour page to learn about its other groundbreaking feature representations and documentation, as well as how to quickly get started with configuration specifications. You can also explore our React Chart example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!