plotly / react-plotly.js

A plotly.js React component from Plotly 📈
MIT License
1.01k stars 135 forks source link

[TypeScript] Missing property in `Partial<PlotData>` #308

Open chaojian-zhang opened 1 year ago

chaojian-zhang commented 1 year ago

Hi, thanks very much for this handy component!

I tried to look at all examples and API docs available but can't figure out how to make use of connector among other properties (e.g. measure) for a Waterfall chart. I wonder whether there is a generic way to pass those parameters or it's just not possible at the moment?

This is the code I have:

<Plot
  data={[
    {
      type: 'waterfall', 
      x: ['Name 1', 'Name 2'], 
      y: [15, 20],
      connector: {line: {color: 'red'}} // Cause error: Object literal may only specify known properties, and 'connector' does not exist in type 'Partial<PlotData>'
    },
  ]}
  layout={{
    width: 300 
    height: 150
  }}
/>

The root of the problem seems that only limited number of properties are implemented on Partial<PlotData> - including for instance (as shown in example) the marker: {color: 'red'} property - which is NOT relevant to a waterfall chart at all.

Actually, due to my limited knowledge with React/TypeScript, I don't even know how to look at the definition of PlotData (it looks not available on this repo?) in order to inspect what properties are actually implemented there - would be helpful if anyone can provide some pointers.

This might be related to this: https://github.com/plotly/react-plotly.js/issues/247

chaojian-zhang commented 1 year ago

As a reference, as to "how to use with TypeScript", I find those links provide useful insights:

BenXel commented 1 year ago

I fund an other missing property in Partial. The property value:number[] is required for isosurface type (https://plotly.com/javascript/reference/isosurface/). So value should be value: number | number[] | undefined