Skip to content
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

Multiple issues with transforms #2908

Closed
dmt0 opened this issue Aug 15, 2018 · 6 comments · Fixed by #3766
Closed

Multiple issues with transforms #2908

dmt0 opened this issue Aug 15, 2018 · 6 comments · Fixed by #3766
Labels
bug something broken

Comments

@dmt0
Copy link
Contributor

dmt0 commented Aug 15, 2018

I’ve been trying to add transforms to multiple trace types with varying degrees of success. Documentation doesn’t make it clear which trace types support transforms. All I know from discussion with @etpinard, is that anything that takes 2d arrays as input doesn’t support them.
react-chart-editor as of now does not prepopulate target/targetsrc:

      "transforms": [
        {
          "type": "filter",
          "target": [],
          "targetsrc": null
        }
      ]

Results:

scatter3d:

  • filter: many warnings: [.Offscreen-For-WebGL-0x7fef4b0d6800]RENDER WARNING: Render count or primcount is 0.

-> https://codepen.io/etpinard/pen/dgWJZg

scatter3d + marker:’line’

  • filter: Uncaught (in promise) TypeError: Cannot read property 'slice' of undefined at LinePlot.proto.update

-> https://codepen.io/etpinard/pen/Edmobo

cone, streamtube, scattergeo, table, heatmap (with 1d array input), contour (with 1d array input)

  • any transforms: as I add them to data, they never get added to fullData

choropleth, scatterternary, scatterpolar, pie:

  • aggregate: Error while plotting: TypeError: Cannot set property 'type' of undefined at Object.plots.supplyTransformDefaults

pie:

  • filter: Error: <path> attribute d: Expected number, "MNaN,NaNa189.5,18…".

-> https://codepen.io/etpinard/pen/wYdppB

2d contour histogram:

  • filter: Error while plotting: TypeError: Cannot read property 'length' of undefined at makeCrossings (plotly-with-meta.js?ab3a:146042)

Edit:
Add this one to the list:

  • When defining a scatter with just Y defined, and than add an aggregate:
    Uncaught TypeError: Cannot set property 'type' of undefined at Object.plots.supplyTransformDefaults
    https://codepen.io/dmt0/pen/xJoWoY

This one got fixed in: #3093

@etpinard
Copy link
Contributor

Ok. Thanks for the report!

What does targetsrc: null which isn't a plotly.js attribute) do?. I suspect it injects target: [] in the user data, but I would like to confirm

@etpinard
Copy link
Contributor

But yeah, we could do better than declaring transforms in the schema for all trace types (including the ones that don't support them yet):

transforms: {
_isLinkedToArray: 'transform',
editType: 'calc',
description: [
'An array of operations that manipulate the trace data,',
'for example filtering or sorting the data arrays.'
].join(' ')
}

@dmt0
Copy link
Contributor Author

dmt0 commented Aug 16, 2018

yes, in fullData I see target: Array[0]

@etpinard
Copy link
Contributor

etpinard commented Oct 10, 2018

Most of these problems occur because transforms[i].target: [] turns data arrays into [] during the calc step (as filter transforms are applied using _module.calcTransform) and the trace type module plot method expect empty data array to be associated with visible: false (from the supplyDefault logic) traces.

Note that

Plotly.newPlot(gd, [{
  y: [1, 2, 1, 3],
  transforms: [{
    type: 'filter',
    target: []
  }]
}], {
  showlegend: true
})

has a legend item, whereas

Plotly.newPlot(gd, [{
  y: [],
}], {
  showlegend: true
})

does not, which I believe is correct.


Perhaps, the most robust to handle this would be to make transform items with target: [] (or any other falsy value?) set enable to false similar to how traces with empty data array get visible:false during supplyDefaults.

@etpinard
Copy link
Contributor

scatterpolar now looks like:

https://codepen.io/etpinard/pen/YJVYYd

@etpinard
Copy link
Contributor

etpinard commented Oct 30, 2018

As far as I can tell, @antoinerg 's #3158 removed the transforms attribute container from all traces that do not support transforms.

etpinard added a commit that referenced this issue Apr 12, 2019
- see #2908 for more info,
- this fixes many potential problems downstream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants