Skip to content

Commit

Permalink
add support for custom rendering tag cloud
Browse files Browse the repository at this point in the history
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Jul 16, 2022
1 parent 8af25ed commit 73eb86a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
6 changes: 6 additions & 0 deletions rse/main/export/jekyll/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ description: "Research Software Database"
baseurl: "/software" #important: start with /
url: ""

# Number of tags to show in cloud
min_tag_count: 1

# Change color above this upper range
tag_threshold: 10

# Customize template
logo: assets/img/logo/logo-transparent.svg
url: "https://rseng.github.io/rse"
Expand Down
2 changes: 1 addition & 1 deletion rse/main/export/jekyll/pages/software.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Software
description: "Browse software"
layout: software
permalink: /software
permalink: /software/
datatables: true
tipue_search_active: true
exclude_from_search: true
Expand Down
32 changes: 10 additions & 22 deletions rse/main/export/jekyll/pages/tags-circle.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,18 @@
data = []
children = {}
$.each(raw, function(i, e) {

// Add known parsers
if (!(e['parser'] in children)) {
children[e['parser']] = {}
}
$.each(e['topics'], function(ii, topic) {
if (!(topic in children[e['parser']])) {
children[e['parser']][topic] = 0
if (!(topic in children)) {
children[topic] = 0
}
children[e['parser']][topic] += 1
children[topic] += 1
})
})

// TODO parse that data into this:
$.each(children, function(parser, e) {

// name is the parser
$.each(e, function(tag, count) {

// Don't include singletons! TODO need to scale this
if (count > 1) {
data.push({"word": tag, "size": count, "parser": parser})
}
})
$.each(children, function(tag, count) {
if (count >= {{ site.min_tag_count }}) {
data.push({"word": tag, "size": count})
}
})

color.domain(d3.extent(data, d => +d.size))
Expand All @@ -91,10 +79,10 @@
leaf.append('text')
.attr("fill", d => d3.hsl(color(d.data.size)).darker(2.6))
.text(d => {
if (d.data.size > 10) {
return d.data.word
} else if (d.data.size > 5) {
if (d.data.size > {{ site.tag_threshold }}) {
return format(d.data.size)
} else if (d.data.size >= {{ site.min_tag_count }}) {
return d.data.word
}
})
.attr('y', 5)
Expand Down

0 comments on commit 73eb86a

Please sign in to comment.