-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yisheng Jiang
committed
Nov 18, 2023
1 parent
296f0f6
commit 5d04bb7
Showing
45 changed files
with
42,047 additions
and
1,086 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import {mkdiv} from "../mkdiv/mkdiv.js"; | ||
const WIDTH = 960, HEIGHT = 420; | ||
import { mkdiv } from "https://unpkg.com/[email protected]/mkdiv.js"; | ||
const WIDTH = 960, | ||
HEIGHT = 420; | ||
export function chart(canvasCtx, dataArray) { | ||
resetCanvas(canvasCtx); | ||
const slider = canvasCtx.canvas.parentElement.querySelector( | ||
|
@@ -30,20 +31,14 @@ export function chartRect(canvasCtx, dataArray, markers) { | |
resetCanvas(canvasCtx); | ||
const [_width, _height] = get_w_h(canvasCtx); | ||
let iWIDTH = _width / dataArray.length; | ||
let max = 0, | ||
min = 340, | ||
x = 0; | ||
for (let i = 1; i < dataArray.length; i++) { | ||
max = dataArray[i] > max ? dataArray[i] : max; | ||
min = dataArray[i] < min ? dataArray[i] : min; | ||
} | ||
canvasCtx.fillStyle = "black"; | ||
canvasCtx.fillRect(0, 0, _width, _height); | ||
canvasCtx.clearRect(0, 0, _width, _height); | ||
canvasCtx.fillStyle = "red"; | ||
let x = 0; | ||
for (let i = 0; i < dataArray.length; i++) { | ||
x += iWIDTH + 1; | ||
canvasCtx.fillRect(x, _height - 10, iWIDTH, dataArray[i] * 120); | ||
canvasCtx.fillRect(x, _height - 10, iWIDTH, dataArray[i] * _height); | ||
} | ||
} | ||
export function mkcanvas(params = {}) { | ||
|
@@ -111,7 +106,7 @@ export async function renderFrames( | |
const existingSlider = canvsCtx.canvas?.parentElement?.querySelector( | ||
"input[type='range']" | ||
); | ||
existingSlider || | ||
existingSlider || | ||
mkdiv("input", { | ||
type: "range", | ||
min: -10, | ||
|
Oops, something went wrong.