Replies: 4 comments
-
Yes @zRelux To show Y-axis labels only at specific positions, we can use the Here is an example- const data = [
{value: 67, label: '24/11'},
{value: 67.8, label: '25/11'},
{value: 69.3, label: '26/11'},
{value: 68.3, label: '27/11'},
{value: 68.8, label: '28/11'},
{value: 68.3, label: '29/11'},
{value: 71, label: '30/11'},
];
const yAxisLabelTexts = [
'kg', // at origin, it will show kg
' ',
'67',
' ',
' ',
' ',
' ',
' ',
' ',
'71',
' ',
];
return (
<LineChart
data={data}
hideDataPoints
color="red"
thickness={5}
hideRules
yAxisSide={yAxisSides.RIGHT}
xAxisColor={'lightgray'}
yAxisThickness={0}
width={336}
yAxisOffset={66}
showFractionalValues // since range of values is small (between 67 - 71)
yAxisLabelTexts={yAxisLabelTexts}
yAxisTextStyle={{fontWeight: 'bold', color: 'black'}}
/>
); |
Beta Was this translation helpful? Give feedback.
-
Oh awesome thanks for the response! |
Beta Was this translation helpful? Give feedback.
-
Update on this how do I make sure the right side values match the one in the data array? For example the 67 is supposed to match with the lowest value and 71 with the height but the graph may look different |
Beta Was this translation helpful? Give feedback.
-
Hi @zRelux You need to adjust the For your use case, you can set- stepValue={1}
noOfSections={5} After this the chart is rendered like this- ![]() The complete code is- const data = [
{value: 67, label: '24/11'},
{value: 67.8, label: '25/11'},
{value: 69.3, label: '26/11'},
{value: 68.3, label: '27/11'},
{value: 68.8, label: '28/11'},
{value: 68.3, label: '29/11'},
{value: 71, label: '30/11'},
];
const yAxisLabelTexts = [
'kg', // at origin, it will show kg
'67',
' ',
' ',
' ',
'71',
];
return (
<LineChart
data={data}
hideDataPoints
color="red"
thickness={5}
// hideRules // uncomment this to hide the rules
yAxisSide={yAxisSides.RIGHT}
xAxisColor={'lightgray'}
yAxisThickness={0}
width={336}
yAxisOffset={66}
stepValue={1}
noOfSections={5}
showFractionalValues // since range of values is small (between 67 - 71)
yAxisLabelTexts={yAxisLabelTexts}
yAxisTextStyle={{fontWeight: 'bold', color: 'black'}}
/>
); |
Beta Was this translation helpful? Give feedback.
-
Is it possible to achieve something like this?
Also can you label the base?
Beta Was this translation helpful? Give feedback.
All reactions