react-native-charts-wrapper
react-native-charts-wrapper copied to clipboard
Customizing y axis labels
How to customise y axis? Is there any customisable methods or something equivalent? More required feature for me to implement in one of the project? Could you please give the solution soon?
Exactly what you want to customize? Actually we can customize granularity, textColor, texSize, and others, for each yAxis (left & right)
For example,
I have a y-axis like [0, 1000, 3000, 6400, 9300, 12350]. If I want to print this number it will work fine. But If I have to convert this number to the format like [0, 1k, 3k, 6k, 9k, 12k]. It is not possible.
I am not able to pass the array of string to y-axis like x-axis also.
I want to customise y-axis label while printing.
How can I achieve this. Please help to write customise method for this?
Check
valueFormatter: PropTypes.oneOfType([
PropTypes.oneOf(['largeValue', 'percent', 'date']),
PropTypes.string,
PropTypes.arrayOf(PropTypes.string)
]),
try largeValue
Yes I have tried it. But it is not working properly. For 1999, it will print 1.99k and for 0.5 it will print 0EEE.
I want only one decimal after dot(.), For example: 1999 should print 1.9k and 0.5 should be same. How can I achieve that?
Additional to @pavanural comment, sometimes we need other conversions. for example, let say [0, 1000, 3000, 6400, 9300, 12350] are the size of some files and we need to show them with MB or GB suffix. so if it's supported by native libraries, actually we need a function like this:
formatter: function(): string {
// conversion logic and return a string to use as y-axis label
}
something similar to highchart's formatter option
How are you dealing with this? All I want is to add a space between the yLabel value and the chart...
It would be very helpful if we can set custom value formatter like
formatter: function(value: number): string { // conversion logic and return a string to use as y-axis label }
Native MPAndroidChart supports custom ValueFormatter too.
I am able to set prefix/suffix using valueFormatter using #
as a number/value in y axis.
valueFormatter: "# bu" // 10000 bu, 20000 bu, 30000 bu
valueFormatter: "$#" // $200, $300, $400, $500
is there anyway I can format values?
e.g. I want to format number by comma. 10,000 bu, 20,000 bu, 30,000 bu
#,### bu?
valueFormatter 什么时候能支持函数