Plotly.js: Plotly.validate does not correctly validate layout grids and domains

Created on 3 Aug 2018  路  4Comments  路  Source: plotly/plotly.js

Plotly.validate incorrectly describes the domain.row and domain.column properties of charts as being unused. The chart(s) will indeed render correctly in their assigned grid slot.

Example

https://codepen.io/JonathanWolfe/pen/wxXyap/

Input

var data = [
  {
    values: [1],
    labels: ['Thing'],
    type: 'pie',
    domain: {
      column: 0,
      row: 0
    }
  }
];

var layout = {
  columns: 1,
  rows: 1
};

var validity = Plotly.validate(data);

console.log(validity);

Plotly.newPlot('graph1', data);

Output

[
  {
    "code": "unused",
    "container": "data",
    "trace": 0,
    "path": [
      "domain",
      "column"
    ],
    "astr": "domain.column",
    "msg": "In data trace 0, key domain.column did not get coerced"
  },
  {
    "code": "unused",
    "container": "data",
    "trace": 0,
    "path": [
      "domain",
      "row"
    ],
    "astr": "domain.row",
    "msg": "In data trace 0, key domain.row did not get coerced"
  }
]
bug

All 4 comments

Thanks @JonathanWolfe - you're absolutely right. We hadn't bothered propagating domain.row and domain.column since these are used right away and then no longer needed, but I forgot about Plotly.validate in this regard. We'll fix that. Thanks for the report!

Oh actually, I think it's OK: see updated codepen https://codepen.io/alexcjohnson/pen/jpKZgg
I had to make a few tweaks, but one that may not be obvious is we won't accept a grid with only one cell - either rows or columns must be >1

@JonathanWolfe does this make sense?

@alexcjohnson I must be non-zero basing my rows/columns in my actual app. I'll check on monday and verify.

@alexcjohnson I figured it out. I simply wasn't passing the layout object to .validate in my actual app 馃う

Was this page helpful?
0 / 5 - 0 ratings