Merge pull request #1222 from getredash/feature/sunburst_visualization

Add: additional results format for sunburst visualization
This commit is contained in:
Arik Fraimovich 2016-07-31 23:10:18 +03:00 committed by GitHub
commit a02eddabb5
2 changed files with 37 additions and 10 deletions

View File

@ -417,6 +417,7 @@
var nodeName = nodes[j]; var nodeName = nodes[j];
var isLeaf = j + 1 === nodes.length; var isLeaf = j + 1 === nodes.length;
if (!children) { if (!children) {
currentNode.children = children = []; currentNode.children = children = [];
children.push({ children.push({
@ -455,6 +456,10 @@
} }
function buildNodes(raw) { function buildNodes(raw) {
var values;
if (_.has(raw[0], 'sequence') && _.has(raw[0], 'stage') && _.has(raw[0], 'node') && _.has(raw[0], 'value')) {
var grouped = _.groupBy(raw, 'sequence'); var grouped = _.groupBy(raw, 'sequence');
var values = _.map(grouped, function(value, key) { var values = _.map(grouped, function(value, key) {
@ -465,6 +470,17 @@
nodes: _.pluck(sorted, 'node') 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; return values;
} }

View File

@ -7,13 +7,24 @@
</div> </div>
<div> <div>
<hr> <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> <ul>
<li><strong>sequence</strong> - sequence id</li> <li><strong>sequence</strong> - sequence id</li>
<li><strong>stage</strong> - what stage in sequence this is (1, 2, ...)</li> <li><strong>stage</strong> - what stage in sequence this is (1, 2, ...)</li>
<li><strong>node</strong> - stage name</li> <li><strong>node</strong> - stage name</li>
<li><strong>value</strong> - number of times this sequence occurred</li> <li><strong>value</strong> - number of times this sequence occurred</li>
</ul> </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>
</div> </div>