flekschas / regl-scatterplot

Scalable WebGL-based scatter plot library build with Regl
https://flekschas.github.io/regl-scatterplot/
MIT License
191 stars 24 forks source link

`aspectRatio` is missing from Typescript declarations #146

Closed funmaker closed 1 year ago

funmaker commented 1 year ago

Hi.

aspectRatio is missing from types.d.ts, trying to specify it in createScatterplot or scatterplot.set throws typescript errors.

Reproduction:

createScatterplot({
  canvas,
  width: canvas.clientWidth,
  height: canvas.clientHeight,
  aspectRatio: 1.0,
});

Error:

(Type) is not assignable to parameter of type  Partial<Properties> 
Object literal may only specify known properties, and  aspectRatio  does not exist in type  Partial<Properties>

Also there is a typo in README.md:

// default it is assumed that your data us following a 1:1 ratio and this ratio

flekschas commented 1 year ago

Turns out what you're trying to do isn't yet supported. At the moment you have to do scatterplot.set({ aspectRatio: 1.337 })

funmaker commented 1 year ago

@flekschas this also doesn't work, aspectRatio is missing from Settable type, which scatterplot.set() expects. In fact, there is no mention of aspectRatio anywhere in types.d.ts

TS2345: Argument of type  { aspectRatio: number; }  is not assignable to parameter of type  Partial<Settable> 
Object literal may only specify known properties, and  aspectRatio  does not exist in type  Partial<Settable>

Another discrepancy in types is that opacity parameter doesn't accept number[], even though it does work and is used in an example in readme.

flekschas commented 1 year ago

I know that the type isn't defined. What I was trying to say is that technically and irrespectively of type hints, createScatterplot({ aspectRatio: 1.377 }); is not implemented yet.

flekschas commented 1 year ago

This PR should fix all three issues: https://github.com/flekschas/regl-scatterplot/pull/147. Let me know if it looks good and I'll merge it and release a new version

funmaker commented 1 year ago

LGTM 👍 Thanks