Skip to content

Commit 89991f6

Browse files
author
Christoph Pader
committed
fix: make smoothing mandatory in CreateGraphPath
1 parent 5926e0e commit 89991f6

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/CreateGraphPath.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type GraphPathConfig = {
4646
/**
4747
* Smoothing of the graph path (usually between 0.2 and 0.5)
4848
*/
49-
smoothing?: number
49+
smoothing: number
5050
/**
5151
* Range of the graph's x and y-axis
5252
*/
@@ -134,9 +134,6 @@ export const pixelFactorY = (
134134
return (y - minValue) / diff
135135
}
136136

137-
// A Graph Point will be drawn every second "pixel"
138-
const PIXEL_RATIO = 2
139-
140137
type GraphPathWithGradient = { path: SkPath; gradientPath: SkPath }
141138

142139
function createGraphPathBase(
@@ -146,7 +143,7 @@ function createGraphPathBase(props: GraphPathConfigWithoutGradient): SkPath
146143

147144
function createGraphPathBase({
148145
points,
149-
smoothing = 0.2,
146+
smoothing,
150147
range,
151148
horizontalPadding,
152149
verticalPadding,
@@ -227,7 +224,7 @@ function createGraphPathBase({
227224
const deltaX = point.date.getTime() - prev.date.getTime()
228225
const drawingFactor = deltaX / spanX
229226
const drawingPixels = actualWidth * drawingFactor + horizontalPadding
230-
const numberOfDrawingPoints = Math.floor(drawingPixels / PIXEL_RATIO)
227+
const numberOfDrawingPoints = Math.floor(drawingPixels)
231228

232229
for (let i2 = 0; i2 <= numberOfDrawingPoints; i2++) {
233230
const p = splineFunction(i2 / numberOfDrawingPoints)

0 commit comments

Comments
 (0)