reactjs - 饼图标签在 ReactJS 中不可见
问题描述
我正在尝试创建一个饼图仪表板。图表正在根据值绘制,但图例未显示。我已经尝试了如下标签。
摘要.js:
import React, { Component } from 'react';
import PieChart from 'react-minimal-pie-chart';
class Summary extends Component {
render()
{
return(
<PieChart className="chart-style" x={50} y={60} outerRadius={100} innerRadius={50}
data={[
{ value: 11, color: '#E38627',label: 'New' },
{ value: 12, color: '#C13C37',label: 'Closed' },
{ value: 8, color: '#6A2135',label: 'Reopened' },
]}
/>
);
}
}
export default Summary;
解决方案
添加这个对我有用。
label={(props) => { return props.dataEntry.title;}}
例子
<PieChart
label={(props) => { return props.dataEntry.title;}}
data={[{ title: "One", value: 10, color: "#E38627" },
{ title: "Two", value: 15, color: "#C13C37" },
{ title: "Three", value: 20, color: "#6A2135" },
]}
/>
它至少适用于显示标签,但您也可以自定义它以显示百分比。
推荐阅读
- sql - 从单个表中获取数据到一个空表
- r - 一个表中行的条件组合
- marklogic - 为什么无效字符会进入 MarkLogic 数据库?
- matplotlib - 如何在用 scikit-learn / matplotlib 绘制的混淆矩阵中格式化 xticklabels?
- javascript - html中的电话号码输入字段
- wordpress - 如何批量提取pdf?
- python - 为什么我的 url 有时会返回数据并返回错误 404 not found others?
- c# - 使用 Roslyn 编译 .net 核心应用程序时出错
- graphics - 始终如一地确定面部法线的方向?
- java - 放置 WAR 依赖项的“正确”位置在哪里?