Nivo/Bar Customize label, add two labels #2660
CarlosTejosStech
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
I am using the nivo/bar component in a project made with react. Specifically the "ResponsiveBar" component and I need to add another value or additional field below it in the value label, and for both to be centered both vertically and horizontally.
I have something like this but I can't get what I requested.
Code:
<ResponsiveBar
data={data}
theme={theme}
keys={["velocidad"]}
indexBy="conductor"
margin={{ top: 30, right: 10, bottom: 50, left: 80 }}
padding={0.2}
valueFormat={(value) => FormatNumber(value)}
colors={["#DD6D53"]}
borderColor={{
from: "color",
modifiers: [["darker", "1.6"]],
}}
axisTop={null}
axisRight={null}
axisBottom={{
tickSize: 5,
legend: "Conductor",
legendPosition: "middle",
legendOffset: 40,
format: (value) => FormatNumber(value),
}}
axisLeft={{
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
legend: "Velocidad",
legendPosition: "middle",
legendOffset: -60,
format: (value) => FormatNumber(value),
}}
enableTotals={true}
totalsOffset={11}
labelSkipWidth={12}
labelSkipHeight={12}
labelPosition="middle"
label={(bar) => (
{bar.data.velocidad}
{bar.data.conductor}
)}
labelTextColor="#ffffff"
legends={[]}
isInteractive={true}
role="application"
ariaLabel="Gráfica Patentes con más Km."
// }
/>
This currently looks like this, I need the name to be with a line break, how could I achieve it?
ps: Sorry my English, I am Spanish speaking, thank you very much in advance for the help.
Beta Was this translation helpful? Give feedback.
All reactions