-
Notifications
You must be signed in to change notification settings - Fork 0
add mapvis #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
add mapvis #2
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Pie Chart Data Update Loop and Negative Values
The useEffect hook for updating pie chart data creates an infinite re-render loop. It includes data in its dependency array but also modifies data within the effect, leading to multiple concurrent update intervals and erratic data changes. The data dependency should be removed. Furthermore, the data adjustment logic to ensure the total sum is 100 can result in negative values for the first data item if rounding causes the sum to exceed 100, which is invalid for a pie chart.
src/app/(demo)/datavisbochu/components/d3-pie-chart.tsx#L31-L59
recording/src/app/(demo)/datavisbochu/components/d3-pie-chart.tsx
Lines 31 to 59 in d4effc8
| // 随机更新数据 | |
| useEffect(() => { | |
| if (paused) return; | |
| const interval = setInterval(() => { | |
| const newData = [...data]; | |
| // 随机更新数据 | |
| newData.forEach((item) => { | |
| item.value = Math.max( | |
| 10, | |
| Math.min(50, item.value + Math.floor(Math.random() * 5) - 2), | |
| ); | |
| }); | |
| // 确保总和为100 | |
| const total = newData.reduce((sum, item) => sum + item.value, 0); | |
| newData.forEach((item) => { | |
| item.value = Math.round((item.value / total) * 100); | |
| }); | |
| // 调整,确保总和为100 | |
| const finalTotal = newData.reduce((sum, item) => sum + item.value, 0); | |
| if (finalTotal !== 100) { | |
| newData[0].value += 100 - finalTotal; | |
| } | |
| setData([...newData]); | |
| }, 5000); | |
| return () => clearInterval(interval); | |
| }, [paused, data]); |
Bug: Incorrect CSS Property for Pie Chart Segments
The clipPath CSS property in the PieChart component is incorrectly assigned a conic-gradient value. clipPath only accepts shape functions (e.g., polygon(), circle()) for clipping, not gradients. This will not work as intended for creating pie chart segments; the conic-gradient should be applied to the background property instead.
src/app/(demo)/datavisbochu/components/charts.tsx#L225-L229
recording/src/app/(demo)/datavisbochu/components/charts.tsx
Lines 225 to 229 in d4effc8
| <motion.div | |
| className={`absolute inset-0 ${colors[index % colors.length]}`} | |
| style={{ | |
| clipPath: `conic-gradient(from ${startAngle}deg, currentColor ${angle}deg, transparent ${angle}deg)`, | |
| }} |
BugBot free trial expires on July 22, 2025
You have used $0.00 of your $0.00 spend limit so far. Manage your spend limit in the Cursor dashboard.
Was this report helpful? Give feedback by reacting with 👍 or 👎
No description provided.