Skip to content

Commit

Permalink
added graph
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Breslav committed Jul 29, 2019
1 parent af18326 commit e7209a3
Show file tree
Hide file tree
Showing 5 changed files with 650 additions and 588 deletions.
3 changes: 0 additions & 3 deletions SeuratExtension/SeuratExtension.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@
<PackageReference Include="DynamoVisualProgramming.ZeroTouchLibrary" version="2.2.*">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Chart.Controls">
<Version>4.7.2046</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Compile Include="src\Clustering.cs" />
Expand Down
4 changes: 2 additions & 2 deletions SeuratExtension/src/html/playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ function getVectorDataMetrics2D() {
x += (data[i2][j2] / maxVals[j2]) * dataStream[0].x[j2];
y += (data[i2][j2] / maxVals[j2]) * dataStream[0].y[j2];
}
//x /= labels.length;
//y /= labels.length;
x /= labels.length;
y /= labels.length;

dataStream[1].x.push(x);
dataStream[1].y.push(y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ <h2>Graph</h2>
<!--<p>
<input type="button" value="Draw graph" onclick="draw();" id="draw">
</p>-->
<div id="2dVectorGraph" style="width:700px;height:450px;padding-bottom: 3px;"></div>
<div id="2dGraph" style="width:700px;height:450px;padding-bottom: 3px;"></div>
<div id="3dGraph"></div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ function load() {
Graph2D = document.getElementById('2dGraph');
Plotly.plot( Graph2D, data2D, {
margin: { t: 0, b: 0 } } );

var data2D_2 = getVectorDataMetrics2D();
Graph2DVector = document.getElementById('2dVectorGraph');
Plotly.plot( Graph2DVector, data2D_2, {
margin: { t: 0, b: 0 } } );

Graph2D.on('plotly_click', function(data){
var pts = '';
Expand Down Expand Up @@ -129,6 +134,62 @@ function getDataClusterStats2D() {
return dataStream;
}

function getVectorDataMetrics2D() {
var labels = allGoals;
var data = allValues;
var dataStream = [];
var angle = (2* Math.PI) / labels.length;
var vecX = [];
var vecY = [];
var a = 0;


dataStream.push({x:[], y:[], text:[],
mode: 'markers',
type: 'scatter',
name: 'Metrics',
marker: { size: 10 }
});
for (var i=0; i < labels.length; ++i){
a = a+angle;
dataStream[0].x.push(Math.cos(a));
dataStream[0].y.push(Math.sin(a));
dataStream[0].text.push(labels[i]);

}

dataStream.push({x:[], y:[],
mode: 'markers',
type: 'scatter',
name: 'Data',
marker: { size: 3 }
});

var maxVals = {};
for (var i1=0; i1 < data.length; ++i1){
for (var j=0; j < labels.length; j++){
if(!maxVals[j] || maxVals[j] < data[i1][j]){
maxVals[j] = data[i1][j];
}
}
}

for (var i2=0; i2 < data.length; ++i2){
var x = 0;
var y = 0;
for (var j2=0; j2 < labels.length; j2++){
x += (data[i2][j2] / maxVals[j2]) * dataStream[0].x[j2];
y += (data[i2][j2] / maxVals[j2]) * dataStream[0].y[j2];
}
//x /= labels.length;
//y /= labels.length;

dataStream[1].x.push(x);
dataStream[1].y.push(y);
}
return dataStream;
}

function getDataMetrics2D() {
//var csv = data; //document.getElementById("csvTextarea").value;

Expand Down
Loading

0 comments on commit e7209a3

Please sign in to comment.