Skip to content

Commit 56e0aef

Browse files
committed
put colors in chromatic order
1 parent c27d4ce commit 56e0aef

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

chord.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ function createGraph(chord_matrix, clusters, labels, heatmap, title) {
246246
.on("mouseout", fade(1.0));
247247

248248
g.append("svg:path")
249-
.style("stroke", function(d) { return fill(clusters[d.index]); })
250-
.style("fill", function(d) { return fill(clusters[d.index]); })
249+
.style("stroke", function(d) { return d3Cat10Colors(clusters[d.index]); })
250+
.style("fill", function(d) { return d3Cat10Colors(clusters[d.index]); })
251251
.attr("d", arc);
252252

253253
// add gene labels
@@ -311,7 +311,7 @@ function createGraph(chord_matrix, clusters, labels, heatmap, title) {
311311
.endAngle(function(d) { return d.endAngle + chord_padding/2; })
312312
)
313313
.attr("class", "cluster_arc")
314-
.attr("fill", function(d) { return fill(d.cluster); })
314+
.attr("fill", function(d) { return d3Cat10Colors(d.cluster); })
315315
.on("mouseover", fadeCluster(fade_opacity))
316316
.on("mouseout", fadeCluster(1.0));
317317

@@ -330,8 +330,8 @@ function createGraph(chord_matrix, clusters, labels, heatmap, title) {
330330
d.target.cluster = clusters[d.target.index];
331331
d.pathString = d3.svg.chord().radius(innerRadius)(d);
332332
})
333-
.style("stroke", function(d) { return d3.rgb(fill(clusters[d.source.index])).darker(); })
334-
.style("fill", function(d) { return fill(clusters[d.source.index]); })
333+
.style("stroke", function(d) { return d3.rgb(d3Cat10Colors(clusters[d.source.index])).darker(); })
334+
.style("fill", function(d) { return d3Cat10Colors(clusters[d.source.index]); })
335335
.attr("d", d3.svg.chord().radius(innerRadius));
336336

337337
// draw a legend for the clusters in the upper right corner
@@ -381,7 +381,7 @@ function drawClusterLegend(clusterLegend) {
381381
.attr("y", i*20)
382382
.attr("width", 10)
383383
.attr("height", 10)
384-
.style("fill", fill(d));
384+
.style("fill", d3Cat10Colors(d));
385385
g.append("text")
386386
.attr("x", 40)
387387
.attr("y", i*20 + 10)
@@ -666,8 +666,8 @@ function drawGradientPath(path, i) {
666666
deltapi = 0,
667667
mask = [],
668668
colorGradient = d3.scale.linear()
669-
.range([fill( path.source.cluster ),
670-
fill( path.target.cluster )])
669+
.range([d3Cat10Colors( path.source.cluster ),
670+
d3Cat10Colors( path.target.cluster )])
671671
.domain([0,n]);
672672

673673
for (var i = 1; i < n; i++) {

config.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@ var margin = {top: 180, right: 160, bottom: 160, left: 160},
1313
.innerRadius(innerRadius)
1414
.outerRadius(outerRadius),
1515

16-
fill = d3.scale.category10(),
1716
colorScale = d3.scale.linear()
1817
.range(["#232323", "green", "red"]),
1918
heatmapLegendScale = d3.scale.linear()
2019
.domain([0,3]),
20+
21+
matlabColors = function(i) {
22+
return (['#F00', '#FF0', '#0F0', '#0FF', '#00F', '#F0F'])[(i-1)%6];
23+
},
24+
d3Cat10Colors = function(i) {
25+
return (['#D62728', '#FF7F0E', '#2CA02C', '#1F77B4', '#9467BD',
26+
'#8C564B'])[(i-1)%6];
27+
},
2128

2229
colorGradientPrecision = 20,
2330

events.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,10 @@ $(".additional-settings").click(function() {
251251
$('.chord-fill-btns').click(function() {
252252
switch ($(this).attr('data-action')) {
253253
case 'setD310Colors':
254-
recolor(function(i) {
255-
return (['#1F77B4', '#FF7F0E', '#2CA02C', '#D62728', '#9467BD',
256-
'#8C564B'])[(i-1)%6];
257-
});
254+
recolor(d3Cat10Colors);
258255
break;
259256
case 'setMatlabColors':
260-
recolor(function(i) {
261-
return (['#F00', '#FF0', '#0F0', '#0FF', '#00F', '#F0F'])[(i-1)%6];
262-
});
257+
recolor(matlabColors);
263258
default:
264259
break;
265260
}

0 commit comments

Comments
 (0)