Published
Edited
Dec 3, 2019
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
codejson = d3.json('https://raw.githubusercontent.com/nasa/Open-Source-Catalog/master/code.json')
Insert cell
catalogjson = d3.json('https://raw.githubusercontent.com/nasa/Open-Source-Catalog//master/catalog.json')
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// Function that gets lists of all the Categories_NLP with count for each tag
function getAllTagClusterDescriptions(catalog_clusters_demo_v1){
var cluster_descriptions = []
var cluster_names = []
const clusters_infos = Object.values(catalog_clusters_demo_v1)
for (var i = 0; i < clusters_infos.length; i++){
cluster_descriptions.push(clusters_infos[i]["keyword_descriptions"])
cluster_names.push(clusters_infos[i]["project_names"])
}
var results = [cluster_descriptions,cluster_names]
return results
}
Insert cell
Insert cell
Insert cell
Insert cell
function make_cluster_descriptions_for_selection(cluster_descriptions){
// making a list of strings appear as single string so it can work in selection UI at top
var cluster_descriptions_for_selection = []
for (var i = 0; i < cluster_descriptions.length; i++){
var cluster_desc_string = cluster_descriptions[i].join()
cluster_descriptions_for_selection.push(cluster_desc_string)
}
return cluster_descriptions_for_selection
}
Insert cell
Insert cell
// countNLPTagsWNames gets all the tag and group the tags based of project names that utilized this tag.
function countNLPTagsWNames(catalog,selected_project_names){
var counts = {}
var tag_holder = {}
var project = {"name":"NASA Open Source","projects":[]}
for (var i = 0; i < catalog.length; i++){
for (var j = 0; j < catalog[i]["Categories_NLP"].length; j++){
var tag = catalog[i]["Categories_NLP"][j]
var name = catalog[i]["Software"]
var children_1_list = project['projects']
var nlp_tag = catalog[i]["Categories_NLP"][j]
//Compare selected_project_name against current project name
var isProjNameInSelectedProjectsClusters = false
for (var w = 0; w < selected_project_names.length; w++){
if (selected_project_names[w] == name){
isProjNameInSelectedProjectsClusters = true
}
}
if (counts[nlp_tag] && tag_holder[nlp_tag] && isProjNameInSelectedProjectsClusters) {
tag_holder[nlp_tag].push(name)
counts[nlp_tag]+= 1
var count = counts[nlp_tag]
var tags = tag_holder[nlp_tag]
children_1_list.push({"names": tags, tag_name: nlp_tag, "value": count})
}
else {
if (!tag_holder[nlp_tag]){tag_holder[nlp_tag] = [name]}
if (!counts[nlp_tag]){counts[nlp_tag] = 1}
children_1_list.push({"names": [name], tag_name: nlp_tag, "value": 1})
}
}
}
var results = {"name":"NASA Open Source","children":[]}
var tag_array = Object.keys(counts)
for (var k = 0; k < tag_array.length; k++){
var tag = tag_array[k]
if (counts[tag] >= min_tag_counts && counts[tag] <= max_tag_counts){
results["children"].push({"name":tag,"value":counts[tag],"projects":tag_holder[tag]})
}
}
return results
}
Insert cell
tag_holder = countNLPTagsWNames(catalogjson, selected_project_names)
Insert cell
// selectTagCluster that select each tag cluster base of cluster tag selected
function selectTagCluster(data,clusters_selected) {
// split cluster tags into single tags
var clusters_selected_list = clusters_selected[0].split(",")
var length_ = Object.keys(data).length
// loop though keys of data length
for (var i = 0; i < length_; i++) {
var tag = data[i]["keyword_descriptions"]
var name = data[i]["project_names"]
// loop through all the tags
for (var k = 0; k < tag.length; k++){
// compare current tag and clusters_selected_list and return project name
if (tag[k] == clusters_selected_list[k]){
return name
}
}
}
}
Insert cell
selected_project_names = selectTagCluster(catalog_clusters_demo_v1, clusters_selected)
Insert cell
Insert cell
Insert cell
function namesDisplay() {
return html`<section style='background-color:#eaeaea;display: block; width: 700px;height: 400px;padding: 1em;overflow-y: scroll;text-align:left; border: 2px solid;'>
${ project_names_with_links.map(
(item) => `<p><a href=${item.link} target="_blank">${item.name}</a></p>`
)}
</section>`
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
vegalite = require("@observablehq/vega-lite@0.1")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more