Published
Edited
Jun 18, 2021
1 fork
1 star
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
fetched_api_nasa_gov = await soFetch('https://api.gsa.gov/analytics/dap/v1.1/domain/'+f1+'/reports/site/data?after='+date_last_month+'&api_key='+thing)
Insert cell
fetched_api_nasa_gov_json = fetched_api_nasa_gov.json()
Insert cell
Insert cell
function deDuplication(json_input){
var deplupicated_json = []
for (var i=0;i < json_input.length;i++){
if (json_input[i]['report_agency'] == "national-aeronautics-space-administration"){
deplupicated_json.push(json_input[i])
}
}
return deplupicated_json
}
Insert cell
fetched_api_nasa_gov_json_NoDups = deDuplication(fetched_api_nasa_gov_json)
Insert cell
Insert cell
md `## How About Total Visits Over That Period?`
Insert cell
total_visits = getTotalVisits(fetched_api_nasa_gov_json_NoDups,"visits")
Insert cell
function getTotalVisits(data,key){
var visits = 0
Array.prototype.sum = function (prop) {
var total = 0
for ( var i = 0, _len = this.length; i < _len; i++ ) {
total += this[i][prop]
}
return total
}
return data.sum(key)
}
Insert cell
Insert cell
Insert cell
Insert cell
d3 = require("d3@5")
Insert cell
import { soFetch } from '@alecglassford/so-fetch'
Insert cell
import {text} from "@jashkenas/inputs"
Insert cell
vegalite = require("@observablehq/vega-lite@0.1")
Insert cell
Inputs = require("@observablehq/inputs@0.7")
Insert cell
moment = require('moment')
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