React-native-chart-kit: Customize fonts on labels

Created on 18 Aug 2018  路  8Comments  路  Source: indiespirit/react-native-chart-kit

Is it possible customize fonts on labels? fontFamily, fontSize etc

Most helpful comment

You can add fontFamily property to Text into react-native-chart-kit.
for example : in pie-chart.js - line 47 add this code:
fontFamily={c.item.fontFamily}
Now you can set fontFamily in your data entities.

but react-native-svg can't render all font type!

All 8 comments

You can add fontFamily property to Text into react-native-chart-kit.
for example : in pie-chart.js - line 47 add this code:
fontFamily={c.item.fontFamily}
Now you can set fontFamily in your data entities.

but react-native-svg can't render all font type!

@c0mm4nDer worked like a charm. Thanks a lot!

Should we create a PR for this?

Any update?

Just found out by accident while reading someone else code:

Under chartConfig prop, there is the propsForLabels prop. You may enter the fontFamily there and other texts properties.

add font name in propsForLabels this works for me

chartConfig={{
    propsForLabels:{
    fontFamily:'MontserratBold',
    },
...
  }}

add font name in propsForLabels this works for me

chartConfig={{
    propsForLabels:{
    fontFamily:'MontserratBold',
    },
...
  }}

Thanks, it worked for me :)

inside data object

{
    legendFontColor: colors.white,
    legendFontSize: 8,
}
Was this page helpful?
0 / 5 - 0 ratings