1
0
Fork 0

GraphViewer: Added/Tested default colouring of Edges and nodes

This commit is contained in:
Michael Hackstein 2013-04-04 16:36:16 +02:00
parent 0e4b3ae62f
commit ed827d77cd
4 changed files with 43 additions and 39 deletions

View File

@ -298,10 +298,24 @@ function EdgeShaper(parent, flags, idfunc) {
while (toplevelSVG[0][0] && toplevelSVG[0][0].ownerSVGElement) {
toplevelSVG = d3.select(toplevelSVG[0][0].ownerSVGElement);
}
if (flags !== undefined) {
parseConfig(flags);
}
if (flags === undefined) {
flags = {
color: {
type: "single",
stroke: "#686766"
}
};
}
if (flags.color === undefined) {
flags.color = {
type: "single",
stroke: "#686766"
};
}
parseConfig(flags);
if (_.isFunction(idfunc)) {
idFunction = idfunc;

View File

@ -260,28 +260,24 @@ function NodeShaper(parent, flags, idfunc) {
self.parent = parent;
if (flags !== undefined) {
parseConfig(flags);
/*
if (flags === undefined) {
flags = {
color: {
type: "single",
stroke: "#FF8F35",
fill: "#8AA051"
fill: "#FF8F35",
stroke: "#8AA051"
}
};
*/
}
/*
if (flags.color === undefined) {
flags.color = {
type: "single",
stroke: "#FF8F35",
fill: "#8AA051"
};
fill: "#FF8F35",
stroke: "#8AA051"
};
}
*/
parseConfig(flags);
if (_.isFunction(idfunc)) {
idFunction = idfunc;

View File

@ -250,7 +250,23 @@
});
describe('testing for colours', function() {
it('should have a default colouring of no colour flag is given', function() {
var nodes = [{_id: 1}, {_id: 2}],
edges = [{
source: nodes[0],
target: nodes[1]
},{
source: nodes[1],
target: nodes[0]
}],
shaper = new EdgeShaper(d3.select("svg"));
shaper.drawEdges(edges);
expect($("#1-2 line").attr("stroke")).toEqual("#686766");
expect($("#2-1 line").attr("stroke")).toEqual("#686766");
});
it('should be able to use the same colour for all edges', function() {
var s = {_id: 1},
t = {_id: 2},

View File

@ -1,31 +1,9 @@
.link {
fill: none;
stroke: #666;
stroke-width: 1px;
}
.edgegradient {
stroke: url("#edgegradient");
}
.node {
cursor: pointer;
fill: #ccc;
stroke: #fff;
stroke-width: 1px;
}
text {
font: 10px sans-serif;
pointer-events: none;
stroke: #fff;
stroke-width: 1px;
}
marker#arrow {
fill: #666;
}
capitalize {
text-transform:capitalize;