最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

next.js - Recharts Typeform horizontal bar charts - Stack Overflow

programmeradmin3浏览0评论

I'm trying to use Recharts bar for horizontal bars replicating the one from Typeform where label and percentage are on top of the bar. Trying the position top any any of that doesn't work. Only for answer gets placed good but for the other one in any position it overlaps the answer.

 <ChartContainer config={chartConfig}>
            <BarChart data={chartData} layout="vertical" accessibilityLayer>
            <Bar dataKey="answer" radius={4} >
            <LabelList
                  dataKey="count"
                  position="right"
                  offset={8}
                  fontSize={12}
                  className="fill-[--color-label] w-full"
                  formatter={(value: number) => `${value.toFixed(1)}%`}
                  style={{
                    textAnchor: "start",
                  }}
                />
            </Bar>
            <Bar dataKey="answer" radius={4} >
                <LabelList
                  dataKey="answer"
                  position="insideLeft"
                  offset={8}
                  fontSize={12}
                  className="fill-[--color-label]"
                />
            </Bar>
              <YAxis dataKey="answer" type="category" hide />
              <XAxis dataKey="count" type="number" hide />
              <Bar dataKey="count" radius={4}  background={{ fill: '#e0e0e0' }}/>
              </BarChart>
          </ChartContainer>

Would appreciate if you could help me to navigate how using Recharts with shadcn I could create a bar chart looking like this screenshot how I want it to look like

I need make labels the answer left and percentage on the right. I need also to keep the size of the bars the same and just allow scrolling if they overflow.

would appreciate your help

发布评论

评论列表(0)

  1. 暂无评论