-
Notifications
You must be signed in to change notification settings - Fork 967
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
1,954 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE visualization SYSTEM "../../visualization.dtd"> | ||
<visualization name="Venn Diagram (Benfred)" regular="True"> | ||
<description>A javascript library for laying out area proportional venn and euler diagrams hosted at https://github.com/benfred/venn.js.</description> | ||
<data_sources> | ||
<data_source> | ||
<model_class>HistoryDatasetAssociation</model_class> | ||
<test type="isinstance" test_attr="datatype" result_type="datatype">tabular.Tabular</test> | ||
<test type="isinstance" test_attr="datatype" result_type="datatype">tabular.CSV</test> | ||
<to_param param_attr="id">dataset_id</to_param> | ||
</data_source> | ||
</data_sources> | ||
<params> | ||
<param type="dataset" var_name_in_template="hda" required="true">dataset_id</param> | ||
</params> | ||
<entry_point entry_point_type="chart" src="static/script.js" css="static/script.css" func="func"/> | ||
<specs> | ||
<tag>svg</tag> | ||
</specs> | ||
<groups> | ||
<input> | ||
<label>Provide a label</label> | ||
<name>key</name> | ||
<type>text</type> | ||
<placeholder>Data label</placeholder> | ||
<value>Data label</value> | ||
</input> | ||
<input> | ||
<label>Column with observations</label> | ||
<name>observation</name> | ||
<type>data_column</type> | ||
<is_label>true</is_label> | ||
</input> | ||
</groups> | ||
</visualization> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "visualization", | ||
"version": "0.1.0", | ||
"keywords": [ | ||
"galaxy", | ||
"visualization" | ||
], | ||
"license": "AFL-3.0", | ||
"dependencies": { | ||
"babel-preset-env": "^1.6.1", | ||
"backbone": "^1.3.3", | ||
"bootstrap": "^3.3.7", | ||
"jquery": "^3.1.1", | ||
"parcel-bundler": "^1.4.1", | ||
"d3": "^3.4.5" | ||
}, | ||
"scripts": { | ||
"build": "parcel build src/script.js -d static" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import * as Venn from "./venn"; | ||
import * as d3 from "d3"; | ||
window.d3 = d3; | ||
var Datasets = window.bundleEntries.chartUtilities.Datasets; | ||
_.extend(window.bundleEntries || {}, { | ||
func: function(options) { | ||
var self = this; | ||
var separator = '_'; | ||
function _combinations( current, remaining, results ) { | ||
var self = this; | ||
_.each( remaining, function( value, index ) { | ||
var new_current = current.slice(); | ||
var new_remaining = remaining.slice(); | ||
new_remaining.splice( 0, index + 1 ); | ||
new_current.push( value ); | ||
results.push( new_current ); | ||
_combinations( new_current, new_remaining, results ); | ||
}); | ||
}; | ||
Datasets.request({ | ||
dataset_id : options.chart.get( 'dataset_id' ), | ||
dataset_groups : options.chart.groups, | ||
success : function( result ) { | ||
var group_keys = []; | ||
var group_values = []; | ||
var all_values = {}; | ||
var set_size = {}; | ||
var group_ids = []; | ||
_.each( result, function( group, i ) { | ||
var group_index = {}; | ||
_.each( group.values, function( d ) { | ||
all_values[ d.observation ] = group_index[ d.observation ] = true; | ||
}); | ||
group_keys.push( group.key ); | ||
group_values.push( group_index ); | ||
group_ids.push( i ); | ||
}); | ||
var combos = []; | ||
_combinations( [], group_ids, combos ); | ||
var sets = []; | ||
_.each( combos, function( c ) { | ||
var size = 0; | ||
for ( var value in all_values ) { | ||
var found = 0; | ||
_.each( c, function( group_id ) { | ||
if ( group_values[ group_id ][ value ] ) { | ||
found++; | ||
} | ||
}); | ||
if ( found == c.length ) { | ||
size++; | ||
} | ||
} | ||
if ( size > 0 ) { | ||
var set_labels = []; | ||
_.each( c, function( id ) { | ||
set_labels.push( group_keys[ id ]); | ||
}); | ||
sets.push( { sets: set_labels, size: size } ); | ||
} | ||
}); | ||
var svg = d3.select( '#' + options.targets[ 0 ] ).datum( sets ).call( Venn.VennDiagram() ); | ||
var tooltip = null; | ||
svg.selectAll( 'g' ) | ||
.on( 'mouseover', function( d, i ) { | ||
Venn.sortAreas( svg, d ); | ||
tooltip = d3.select( 'body' ).append( 'div' ).attr( 'class', 'venntooltip' ); | ||
tooltip.transition().duration( 400 ).style( 'opacity', .9 ); | ||
tooltip.text(d.size ); | ||
var selection = d3.select( this ).transition( 'tooltip' ).duration( 400 ); | ||
selection.select( 'path' ) | ||
.style( 'stroke-width', 3 ) | ||
.style( 'fill-opacity', d.sets.length == 1 ? .4 : .1 ) | ||
.style( 'stroke-opacity', 1 ); | ||
}) | ||
.on( 'mousemove', function() { | ||
tooltip.style( 'left', ( d3.event.pageX ) + 'px') | ||
.style( 'top', ( d3.event.pageY - 28 ) + 'px'); | ||
}) | ||
.on( 'mouseout', function( d, i ) { | ||
tooltip.remove(); | ||
}); | ||
options.chart.state( 'ok', 'Venn diagram drawn.' ); | ||
options.process.resolve(); | ||
} | ||
}); | ||
} | ||
}); |
Oops, something went wrong.