Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon Can I use SVG icons for axis labels in react-google-charts
    React Google Charts SVG icons axis labels chart customization React components


Can I use SVG icons for axis labels in react-google-charts


Yes, you can use SVG icons for axis labels in React Google Charts. Here's an example of how you can do it:

1. Create the SVG Icon - Design your custom SVG icon and save it as a file (e.g., `my-icon.svg`).

2. Import the SVG Icon - In your React component, import the SVG icon file:

javascript
   import myIcon from './my-icon.svg';
   

3. Customize the Axis Labels - In the `options` object for your chart, use the `titleTextStyle` property to set the `fontName` to the SVG icon.
- You can also customize the `fontSize`, `bold`, `italic`, and other properties of the axis label text.

Here's an example code snippet:

```javascript
import React from 'react';
import { Chart } from 'react-google-charts';
import myIcon from './my-icon.svg';

const data = [
['Year', 'Temperature'],
[2019, 25],
[2020, 28],
[2021, 30],
[2022, 32],
];

const options = {
title: 'Highest Temperature in Last Five Years',
hAxis: {
title: 'Year',
titleTextStyle: {
fontName: `url(${myIcon})`,
fontSize: 16,
bold: true,
},
},
vAxis: {
title: 'Temperature