Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/component/plotly-graph/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,23 @@ function findMaxArrayLength (cont) {
}

function estimateDataLength (trace) {
const topLevel = findMaxArrayLength(trace)
let dimLevel = 0
let cellLevel = 0

// special case for e.g. parcoords and splom traces
if (Array.isArray(trace.dimensions)) {
return trace.dimensions
dimLevel = trace.dimensions
.map(findMaxArrayLength)
.reduce((a, v) => a + v)
}

return findMaxArrayLength(trace)
// special case for e.g. table traces
if (isPlainObj(trace.cells)) {
cellLevel = findMaxArrayLength(trace.cells)
}

return Math.max(topLevel, dimLevel, cellLevel)
}

function maxPtsPerTrace (trace) {
Expand All @@ -169,6 +178,7 @@ function maxPtsPerTrace (trace) {
case 'scattergl':
case 'splom':
case 'pointcloud':
case 'table':
return 1e7

case 'scatterpolargl':
Expand Down
19 changes: 19 additions & 0 deletions test/unit/plotly-graph_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,25 @@ tap.test('parse:', t => {
})
})

t.test('failing table case', t => {
fn({
data: [{
type: 'table',
cells: {
values: [
new Array(5e6),
new Array(5e6),
new Array(5e6)
]
}
}]
}, {safeMode: true}, (errorCode, result) => {
t.equal(errorCode, 400, 'code')
t.type(result.msg, 'string', 'msg type')
t.end()
})
})

t.test('failing case from too many traces', t => {
var data = new Array(3e3)

Expand Down