-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Fix last point of line charts. And small other fixes to line charts. #21235
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -22,9 +22,15 @@ const calcPoints = ( | |||||
let xRatio = width / (hours - (detail === 1 ? 1 : 0)); | ||||||
xRatio = isFinite(xRatio) ? xRatio : width; | ||||||
|
||||||
const first = history.filter(Boolean)[0]; | ||||||
let first = history.filter(Boolean)[0]; | ||||||
if (detail > 1) { | ||||||
first = first.filter(Boolean)[0]; | ||||||
} | ||||||
let last = [average(first), lastValue(first)]; | ||||||
|
||||||
const getY = (value: number): number => | ||||||
height + strokeWidth / 2 - (value - min) / yRatio; | ||||||
|
||||||
const getCoords = (item: any[], i: number, offset = 0, depth = 1) => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid using Specify a different type for the -const getCoords = (item: any[], i: number, offset = 0, depth = 1) => {
+const getCoords = (item: { state: string }[], i: number, offset = 0, depth = 1) => { Committable suggestion
Suggested change
ToolsBiome
|
||||||
if (depth > 1 && item) { | ||||||
return item.forEach((subItem, index) => | ||||||
|
@@ -37,20 +43,15 @@ const calcPoints = ( | |||||
if (item) { | ||||||
last = [average(item), lastValue(item)]; | ||||||
} | ||||||
const y = | ||||||
height + strokeWidth / 2 - ((item ? last[0] : last[1]) - min) / yRatio; | ||||||
const y = getY(item ? last[0] : last[1]); | ||||||
return coords.push([x, y]); | ||||||
}; | ||||||
|
||||||
for (let i = 0; i < history.length; i += 1) { | ||||||
getCoords(history[i], i, 0, detail); | ||||||
} | ||||||
|
||||||
if (coords.length === 1) { | ||||||
coords[1] = [width, coords[0][1]]; | ||||||
} | ||||||
|
||||||
coords.push([width, coords[coords.length - 1][1]]); | ||||||
coords.push([width, getY(last[1])]); | ||||||
return coords; | ||||||
}; | ||||||
|
||||||
|
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.
Use
Number.isFinite
instead of the globalisFinite
.ES2015 moved some globals into the Number namespace for consistency.
Committable suggestion
Tools
Biome