You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
how do you change the axis label without changing the values?
This is the chart that I have, and I want to change the circled area
The issue is, if I format those numbers to something like 180K, 200K etc in this axis options definition, note the comment:
const secondaryAxes = useMemo(
(): AxisOptions<Datum>[] => [
{
position: chart.type === 'bar-h' ? 'bottom' : 'left',
getValue: datum => {
const val = datum[1]
if (chart.type === 'bar-h') {
return typeof val === 'number' && val.toString().length > 4 // 4 just in case it's too long
? abbreviateNumber(val) // abbreviateNumber will return a string and this breaks the chart
: val
} else {
return val
}
},
elementType: chart.type === 'bar-h' ? 'bar' : chart.type,
},
],
[chart],
)
converting the value to string will error out as it expects to return numerical values, is there a way to change the label shown without changing the value to be calculated?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
how do you change the axis label without changing the values?
This is the chart that I have, and I want to change the circled area
The issue is, if I format those numbers to something like 180K, 200K etc in this axis options definition, note the comment:
converting the value to string will error out as it expects to return numerical values, is there a way to change the label shown without changing the value to be calculated?
Beta Was this translation helpful? Give feedback.
All reactions