Skip to content

Commit 21260e1

Browse files
committed
improve defaults
Signed-off-by: Vanessa Sochat <vsochat@stanford.edu>
1 parent bff5ff5 commit 21260e1

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

codeart/graphics.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424

2525
def generate_interactive_colormap(
26-
vectors, counts, color_width=20, width=6000, row_height=20, outdir=None
26+
vectors, counts, color_width=20, width=1000, row_height=20, outdir=None
2727
):
2828
"""Based on a set of vectors, generate an interactive colormap.
2929
with d3. This function should take output from get_vectors and
@@ -56,8 +56,8 @@ def generate_interactive_colormap(
5656
names = coords.index[color_index:].tolist()
5757
else:
5858
names = coords.index[color_index : color_index + colors_per_row].tolist()
59-
coords.loc[names, "x_center"] = [row_height * row + 1] * len(names)
60-
coords.loc[names, "y_center"] = list(
59+
coords.loc[names, "y_center"] = [row_height * row + 1] * len(names)
60+
coords.loc[names, "x_center"] = list(
6161
range(0, color_width * len(names), color_width)
6262
)
6363
color_index += colors_per_row
@@ -77,6 +77,7 @@ def generate_interactive_colormap(
7777
savedata = {
7878
"records": vectors.to_dict(orient="records"),
7979
"groups": groups,
80+
"rows": rows,
8081
"width": width,
8182
"color_width": color_width,
8283
"row_height": row_height,

codeart/static/interactive-grid.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
.attr("class", "tooltip")
4343
.style("opacity", 0);
4444

45-
var w = data['width'],
46-
h = data["row_height"] * data["records"].length,
45+
var w = "100%",
46+
h = data["row_height"] * data["rows"],
4747
z = data["width"] / data["colors_per_row"]
4848

4949
var svg = d3.select("body").append("svg")
@@ -77,6 +77,9 @@
7777

7878
function redraw(group) {
7979
svg.selectAll("rect").remove()
80+
if (group == "No extension"){
81+
group = "";
82+
}
8083
key = group + "-percent"
8184
console.log(key);
8285

@@ -99,7 +102,7 @@
99102
.attr("x", 120)
100103
.attr("y", function(d,i){ return 100 + i*35}) // 100 is where the first dot appears. 25 is the distance between dots
101104
.style("fill", function(d){ if (d == group) { return "black"}; return "#CCC"})
102-
.text(function(d){ return d})
105+
.text(function(d){ if (d==""){ return "No extension"; }; return d})
103106
.attr("text-anchor", "left")
104107
.style("cursor", "pointer")
105108
.style("font", "32px sans-serif")
@@ -119,7 +122,7 @@
119122
.attr("x", 120)
120123
.attr("y", function(d,i){ return 100 + i*35}) // 100 is where the first dot appears. 25 is the distance between dots
121124
.style("fill", "white")
122-
.text(function(d){ return d})
125+
.text(function(d){ if (d==""){ return "No extension"; }; return d})
123126
.attr("text-anchor", "left")
124127
.style("cursor", "pointer")
125128
.style("font", "32px sans-serif")

0 commit comments

Comments
 (0)