react-native-chart-kit icon indicating copy to clipboard operation
react-native-chart-kit copied to clipboard

Customize fonts on labels

Open jaimeneto85 opened this issue 6 years ago • 11 comments

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

jaimeneto85 avatar Aug 17 '18 22:08 jaimeneto85

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 avatar Nov 14 '18 11:11 c0mm4nDer

@c0mm4nDer worked like a charm. Thanks a lot!

cyeksan avatar Dec 16 '19 07:12 cyeksan

Should we create a PR for this?

sreuter avatar Jan 25 '21 01:01 sreuter

Any update?

ftzi avatar Apr 27 '21 22:04 ftzi

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.

ftzi avatar Apr 28 '21 00:04 ftzi

add font name in propsForLabels this works for me

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

vaibhavgadekar avatar May 06 '21 06:05 vaibhavgadekar

add font name in propsForLabels this works for me

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

Thanks, it worked for me :)

ozgurbayram avatar May 25 '21 20:05 ozgurbayram

inside data object

{
    legendFontColor: colors.white,
    legendFontSize: 8,
}

3abdawy avatar Jun 13 '21 23:06 3abdawy

{ legendFontColor: colors.white, legendFontSize: 8, } @3abdawy Where we can put this?

Shahekta51995 avatar Aug 01 '22 08:08 Shahekta51995

It pretty easy you can add ### propsForLabels to the config props

<BarChart chartConfig={{ ...chartConfig, propsForLabels: { fontSize:12, fontFamily: "roboto-regular", } }} />

mamadoo123 avatar Nov 03 '22 09:11 mamadoo123

    propsForLabels:{fontFamily :'iransans'},

this work just fine

husseinpenart avatar Feb 04 '24 13:02 husseinpenart