可拖动的点阵衰减图表
深色等宽字体工具,用 8px 圆点画出 24 小时内的体内咖啡因。拖动轴上的杯子会重算峰值、睡前水平和最晚饮用时间;点按图表可添加或移除一杯。HTML 与 Skia 共用一份显示列表。
灵感来自 RedNote 上的一条帖子由 Now In Code 从零重建
import { Piece } from "./components";
export function Example() {
const progress = useSharedValue(0);
…
export function Example() {
const progress = useSharedValue(0);
…
Agent 提示词
Add the Now In Code component "dot-matrix-decay-chart-draggable-points" to this project. The full source is attached at the end of this prompt. Put the files under components/dot-matrix-decay-chart-draggable-points/, install the listed dependencies with `npx expo install`, and render it on a route I can open. Keep the timing and easing values documented in the source comments. Replace the sample copy and artwork with content from my app, or leave placeholders and list what I still need to supply. === Source files are attached here for paid plans ===
Pro 作品。提示词包含完整源码。开始使用
详情
你是设计者吗? 请求我们修改或下架此作品.
CLI 与 MCP 服务器 即将推出
在终端添加作品,或让智能体自行获取。在此之前,用“复制提示词”也能做到。 文档
功能说明
一张深色的等宽字体卡片,用一片小圆点绘制 24 小时内体内咖啡因含量的变化。开始时时间轴上有三杯咖啡。拖动某杯咖啡沿时间轴移动,会改变它被饮用的时间,曲线、峰值及其时间、就寝标记处仍剩余的含量,以及“last cup by”时间都会实时更新。点按空白图表区域会添加一杯,点按某杯所在的列则会移除它。在图表上按住会显示时间和毫克数的读数。上升的圆点大而明亮,衰减的圆点小而呈灰色,纵轴会随峰值重新缩放。
实现方式
一个吸收与消除模型(半衰期为五小时)把每杯咖啡的贡献相加。共享的 JavaScript 核心把状态转换为扁平的显示列表,包含圆点、圆环、矩形和文字,每帧数千个元素。一个薄适配器负责绘制这个列表:在 HTML 预览中使用 Canvas2D,在 React Native 中则由 Skia PictureRecorder 录制并在 Skia Canvas 中回放。手势使用 PanResponder,纵向比例用指数平滑缓动,打包的等宽字体通过 useFont 加载。没有使用任何图表库。
适用场景
- 用户可以移动服药或饮用时间并查看其效果的咖啡因、睡眠或药物应用
- 任何“拖动时间线上的事件并观察累积结果”的仪表盘
- 点阵风格的健康或分析类统计卡片
依赖
@shopify/react-native-skiareact-native标签
数据分析图表光标跟随深色数据填充拖拽健康健身极简像素复古状态切换