7 changed files with 202 additions and 75 deletions
-
10src/pages/measure/components/MeasureAction.tsx
-
31src/pages/measure/components/graph/AreaLayer.tsx
-
3src/pages/measure/components/graph/GridLayer.tsx
-
31src/pages/measure/components/graph/MarkLayer.tsx
-
31src/pages/measure/components/graph/RealtimeLayer.tsx
-
31src/pages/measure/components/graph/StandardLayer.tsx
@ -0,0 +1,31 @@ |
|||
import { useCallback, useEffect, useRef } from "react"; |
|||
|
|||
export default function AreaLayer(props: { |
|||
width: number; |
|||
height: number; |
|||
leftPadding: number; |
|||
rightPadding: number; |
|||
topPadding: number; |
|||
bottomPadding: number; |
|||
}) { |
|||
const canvasRef = useRef<HTMLCanvasElement | null>(null); |
|||
const draw = useCallback((ctx: CanvasRenderingContext2D) => { |
|||
// 使用context对象进行绘图
|
|||
ctx.fillStyle = "skyblue"; // 设置填充颜色
|
|||
ctx.fillRect(50, 50, 150, 100); // 绘制一个矩形
|
|||
}, []); |
|||
useEffect(() => { |
|||
const canvas = canvasRef.current; |
|||
if (!canvas) return; |
|||
|
|||
const context = canvas.getContext("2d"); |
|||
if (!context) return; |
|||
draw(context); |
|||
}, [draw]); |
|||
|
|||
return ( |
|||
<div> |
|||
<canvas ref={canvasRef} width={props.width} height={props.height}></canvas> |
|||
</div> |
|||
); |
|||
} |
@ -0,0 +1,31 @@ |
|||
import { useCallback, useEffect, useRef } from "react"; |
|||
|
|||
export default function MarkLayer(props: { |
|||
width: number; |
|||
height: number; |
|||
leftPadding: number; |
|||
rightPadding: number; |
|||
topPadding: number; |
|||
bottomPadding: number; |
|||
}) { |
|||
const canvasRef = useRef<HTMLCanvasElement | null>(null); |
|||
const draw = useCallback((ctx: CanvasRenderingContext2D) => { |
|||
// 使用context对象进行绘图
|
|||
ctx.fillStyle = "skyblue"; // 设置填充颜色
|
|||
ctx.fillRect(50, 50, 150, 100); // 绘制一个矩形
|
|||
}, []); |
|||
useEffect(() => { |
|||
const canvas = canvasRef.current; |
|||
if (!canvas) return; |
|||
|
|||
const context = canvas.getContext("2d"); |
|||
if (!context) return; |
|||
draw(context); |
|||
}, [draw]); |
|||
|
|||
return ( |
|||
<div> |
|||
<canvas ref={canvasRef} width={props.width} height={props.height}></canvas> |
|||
</div> |
|||
); |
|||
} |
@ -0,0 +1,31 @@ |
|||
import { useCallback, useEffect, useRef } from "react"; |
|||
|
|||
export default function RealtimeLayer(props: { |
|||
width: number; |
|||
height: number; |
|||
leftPadding: number; |
|||
rightPadding: number; |
|||
topPadding: number; |
|||
bottomPadding: number; |
|||
}) { |
|||
const canvasRef = useRef<HTMLCanvasElement | null>(null); |
|||
const draw = useCallback((ctx: CanvasRenderingContext2D) => { |
|||
// 使用context对象进行绘图
|
|||
ctx.fillStyle = "skyblue"; // 设置填充颜色
|
|||
ctx.fillRect(50, 50, 150, 100); // 绘制一个矩形
|
|||
}, []); |
|||
useEffect(() => { |
|||
const canvas = canvasRef.current; |
|||
if (!canvas) return; |
|||
|
|||
const context = canvas.getContext("2d"); |
|||
if (!context) return; |
|||
draw(context); |
|||
}, [draw]); |
|||
|
|||
return ( |
|||
<div> |
|||
<canvas ref={canvasRef} width={props.width} height={props.height}></canvas> |
|||
</div> |
|||
); |
|||
} |
@ -0,0 +1,31 @@ |
|||
import { useCallback, useEffect, useRef } from "react"; |
|||
|
|||
export default function StandardLayer(props: { |
|||
width: number; |
|||
height: number; |
|||
leftPadding: number; |
|||
rightPadding: number; |
|||
topPadding: number; |
|||
bottomPadding: number; |
|||
}) { |
|||
const canvasRef = useRef<HTMLCanvasElement | null>(null); |
|||
const draw = useCallback((ctx: CanvasRenderingContext2D) => { |
|||
// 使用context对象进行绘图
|
|||
ctx.fillStyle = "skyblue"; // 设置填充颜色
|
|||
ctx.fillRect(50, 50, 150, 100); // 绘制一个矩形
|
|||
}, []); |
|||
useEffect(() => { |
|||
const canvas = canvasRef.current; |
|||
if (!canvas) return; |
|||
|
|||
const context = canvas.getContext("2d"); |
|||
if (!context) return; |
|||
draw(context); |
|||
}, [draw]); |
|||
|
|||
return ( |
|||
<div> |
|||
<canvas ref={canvasRef} width={props.width} height={props.height}></canvas> |
|||
</div> |
|||
); |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue