Skip to content

Commit

Permalink
Use d3-array extend instead of Math.min and Math.max with spread op…
Browse files Browse the repository at this point in the history
…erator
  • Loading branch information
Stukova authored and rokotyan committed Mar 12, 2024
1 parent 2036a5f commit 2eba967
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/modules/Points/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import regl from 'regl'
import { scaleLinear } from 'd3-scale'
import { extent } from 'd3-array'
import { CoreModule } from '@/graph/modules/core-module'
import { defaultConfigValues } from '@/graph/variables'
import { createColorBuffer, createGreyoutStatusBuffer } from '@/graph/modules/Points/color-buffer'
Expand Down Expand Up @@ -466,10 +467,10 @@ export class Points<N extends CosmosInputNode, L extends CosmosInputLink> extend
if (xs.length === 0) return
const ys = nodes.map(n => n.y).filter((n): n is number => n !== undefined)
if (ys.length === 0) return
const minX = Math.min(...xs)
const maxX = Math.max(...xs)
const minY = Math.min(...ys)
const maxY = Math.max(...ys)
const [minX, maxX] = extent(xs)
if (minX === undefined || maxX === undefined) return
const [minY, maxY] = extent(ys)
if (minY === undefined || maxY === undefined) return
const w = maxX - minX
const h = maxY - minY

Expand Down

0 comments on commit 2eba967

Please sign in to comment.