Skip to content

Commit

Permalink
Edge color encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
pissang committed Aug 4, 2016
1 parent 788c51f commit 4dcbfa3
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
19 changes: 19 additions & 0 deletions dist/echarts-graph-modularity.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,25 @@ return /******/ (function(modules) { // webpackBootstrap
var comm = result[id];
graph.data.setItemVisual(idIndexMap[id], 'color', seriesModel.getColorFromPalette(comm, paletteScope));
}

graph.edgeData.each(function (idx) {
var itemModel = graph.edgeData.getItemModel(idx);
var edge = graph.getEdgeByIndex(idx);
var color = itemModel.get('lineStyle.normal.color');

switch (color) {
case 'source':
color = edge.node1.getVisual('color');
break;
case 'target':
color = edge.node2.getVisual('color');
break;
}

if (color != null) {
edge.setVisual('color', color);
}
});
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion dist/echarts-graph-modularity.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions example/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
width: '50%',
bottom: 0
}, {
name: 'Without Modularity',
name: 'With Modularity',
type: 'graph',
layout: 'force',
modularity: true,
Expand All @@ -75,7 +75,12 @@
left: '50%',
top: 0,
width: '50%',
bottom: 0
bottom: 0,
lineStyle: {
normal: {
color: 'source'
}
}
}]
};

Expand Down
19 changes: 19 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ echarts.registerVisual(echarts.PRIORITY.VISUAL.CHART + 1, function (ecModel, api
var comm = result[id];
graph.data.setItemVisual(idIndexMap[id], 'color', seriesModel.getColorFromPalette(comm, paletteScope));
}

graph.edgeData.each(function (idx) {
var itemModel = graph.edgeData.getItemModel(idx);
var edge = graph.getEdgeByIndex(idx);
var color = itemModel.get('lineStyle.normal.color');

switch (color) {
case 'source':
color = edge.node1.getVisual('color');
break;
case 'target':
color = edge.node2.getVisual('color');
break;
}

if (color != null) {
edge.setVisual('color', color);
}
});
}
});
});

0 comments on commit 4dcbfa3

Please sign in to comment.