Add additional results format for sunburst

This commit is contained in:
Arik Fraimovich 2016-07-31 23:05:00 +03:00
parent 50419f3d8c
commit ca7d8699c8
2 changed files with 37 additions and 10 deletions

View File

@ -417,6 +417,7 @@
var nodeName = nodes[j];
var isLeaf = j + 1 === nodes.length;
if (!children) {
currentNode.children = children = [];
children.push({
@ -455,16 +456,31 @@
}
function buildNodes(raw) {
var grouped = _.groupBy(raw, 'sequence');
var values;
var values = _.map(grouped, function(value, key) {
var sorted = _.sortBy(value, 'stage');
return {
size: value[0].value,
sequence: value[0].sequence,
nodes: _.pluck(sorted, 'node')
}
});
if (_.has(raw[0], 'sequence') && _.has(raw[0], 'stage') && _.has(raw[0], 'node') && _.has(raw[0], 'value')) {
var grouped = _.groupBy(raw, 'sequence');
var values = _.map(grouped, function(value, key) {
var sorted = _.sortBy(value, 'stage');
return {
size: value[0].value,
sequence: value[0].sequence,
nodes: _.pluck(sorted, 'node')
}
});
} else {
var keys = _.sortBy(_.without(_.keys(raw[0]), 'value'), _.identity);
values = _.map(raw, function(row, sequence) {
return {
size: row.value,
sequence: sequence,
nodes: _.compact(_.map(keys, function(key) { return row[key] }))
}
})
}
return values;
}

View File

@ -7,13 +7,24 @@
</div>
<div>
<hr>
This visualization expects the query result to have rows with the following columns:
This visualization expects the query result to have rows in one of the following formats:
<strong>Option 1:</strong>
<ul>
<li><strong>sequence</strong> - sequence id</li>
<li><strong>stage</strong> - what stage in sequence this is (1, 2, ...)</li>
<li><strong>node</strong> - stage name</li>
<li><strong>value</strong> - number of times this sequence occurred</li>
</ul>
<strong>Option 2:</strong>
<ul>
<li><strong>stage1</strong> - stage 1 value</li>
<li><strong>stage1</strong> - stage 2 value (or null)</li>
<li><strong>stage3</strong> - stage 3 value (or null)</li>
<li><strong>stage4</strong> - stage 4 value (or null)</li>
<li><strong>stage5</strong> - stage 5 value (or null)</li>
<li><strong>value</strong> - number of times this sequence occurred</li>
</ul>
</div>
</div>