-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStockLineChart.tsx
62 lines (57 loc) · 1.47 KB
/
StockLineChart.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { useRecords } from "beneath-react";
import { FC } from "react";
import {
Line,
LineChart,
ResponsiveContainer,
Tooltip,
XAxis,
YAxis,
} from "recharts";
interface Props {
filter: string;
}
const StockLineChart: FC<Props> = ({ filter }) => {
const { records, loading, error } = useRecords({
table: "examples/wallstreetbets-analytics/stock-mentions-rollup-daily",
query: { type: "index", filter },
subscribe: false,
pageSize: 30,
});
// Q: This gets hit 3 times. Are the records getting fetched three times?
console.log(records);
return (
<ResponsiveContainer width={"100%"} height={400}>
<LineChart width={500} height={300} data={records}>
<XAxis
dataKey="day"
tickFormatter={(tickItem) => {
const d = new Date(tickItem);
return d.toLocaleDateString("en-US");
}}
/>
<YAxis
yAxisId="left"
dataKey="num_mentions"
label={{ value: "Mentions", angle: -90, position: "insideLeft" }}
/>
<Line
type="monotone"
dataKey="num_mentions"
stroke="#8884d8"
yAxisId="left"
isAnimationActive={false}
/>
<Line
type="monotone"
dataKey="num_positive"
stroke="#82ca9d"
yAxisId="left"
isAnimationActive={false}
/>
<Tooltip />
</LineChart>
</ResponsiveContainer>
);
};
export default StockLineChart;