重新图表线不可见
Rechart line is not visible
我正在尝试使用 rechart 在 reactjs 中绘制折线图。除线条外,所有组件都是可见的。我做错了什么?
import { LineChart, Line, XAxis, YAxis, CartesianGrid, ResponsiveContainer } from 'recharts';
export default function Chart() {
const data = [
{
name: '9 AM',
amt: 2400
},
{
name: '10 AM',
amt: 2210,
},
{
name: '11 AM',
amt: 2290,
},
{
name: '12 PM',
amt: 2000,
},
{
name: '13 PM',
amt: 2181,
},
{
name: '14 PM',
amt: 2500,
},
{
name: '15 PM',
amt: 2100,
},
];
return (
<div className="chart">
<h3 className="chartTitle">Tickets</h3>
<ResponsiveContainer width="100%" aspect={4 / 1}>
<LineChart data={data}>
<XAxis dataKey="name" stroke="#5550bd"/>
<Line type="monotone" datakey="amt" stroke="#82ca9d" activeDot={{ r: 8 }} strokeWidth={3}/>
</LineChart>
</ResponsiveContainer>
</div>
)
}
dataKey中K要大写
我正在尝试使用 rechart 在 reactjs 中绘制折线图。除线条外,所有组件都是可见的。我做错了什么?
import { LineChart, Line, XAxis, YAxis, CartesianGrid, ResponsiveContainer } from 'recharts';
export default function Chart() {
const data = [
{
name: '9 AM',
amt: 2400
},
{
name: '10 AM',
amt: 2210,
},
{
name: '11 AM',
amt: 2290,
},
{
name: '12 PM',
amt: 2000,
},
{
name: '13 PM',
amt: 2181,
},
{
name: '14 PM',
amt: 2500,
},
{
name: '15 PM',
amt: 2100,
},
];
return (
<div className="chart">
<h3 className="chartTitle">Tickets</h3>
<ResponsiveContainer width="100%" aspect={4 / 1}>
<LineChart data={data}>
<XAxis dataKey="name" stroke="#5550bd"/>
<Line type="monotone" datakey="amt" stroke="#82ca9d" activeDot={{ r: 8 }} strokeWidth={3}/>
</LineChart>
</ResponsiveContainer>
</div>
)
}
dataKey中K要大写