Published
Edited
Sep 30, 2019
Insert cell
Insert cell
Insert cell
buildvis = {
let view = md`${container()}`
let dataTable= dc.dataTable(view.querySelector("#dc-table-graph"))
dataTable.width(960)
.height(800)
.dimension(dateDimension)
.group(d => "List of all earthquakes corresponding to the filters")
.size(10)
.columns(['dtg', 'magnitude', 'depth', 'latitude', 'longitude']) //os nomes dos atributos
.sortBy(d => d.dtg)
.order(d3.ascending)
let barChart = dc.barChart(view.querySelector("#magnitude-chart"))
barChart.width(480)
.height(150)
.dimension(magnitudeDimension)
.x(d3.scaleLinear()
.range([0, width])
.domain([0, 8]))
.xUnits(dc.units.integers)
.gap(53)
.elasticY(true)
.group(magnitudeGroup)
let barChart2 = dc.barChart(view.querySelector("#depth-chart"))
barChart2.width(480)
.height(150)
.dimension(depthDimension)
.x(d3.scaleLinear()
.range([0, width])
.domain([0, 100]))
.xUnits(dc.units.integers)
.gap(1)
.elasticY(true)
.group(depthGroup)
let lineChart = dc.lineChart(view.querySelector("#time-chart"))
lineChart.width(960)
.height(150)
.dimension(depthDimension)
.x(d3.scaleTime()
.domain(d3.extent(dataset, d => d.dtg)))
.group(timeGroup)
dc.renderAll()
return view

}
Insert cell
map = {
buildvis;
let mapInstance = L.map('mapid').setView([-41.05,172.93], 5)
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://www.openstreetmap.org/">OpenStreetMap</a> contributors',
maxZoom: 17
}).addTo(mapInstance)
return mapInstance
}
Insert cell
circlesLayer = L.layerGroup().addTo(map)
Insert cell
circles = {
circlesLayer.clearLayers()
dataset.forEach( function(d) {
//let circle = L.circle([d.latitude, d.longitude], 10000, {
let circle = L.circle([d.latitude, d.longitude], d.magnitude * 10000, {
color: '#fd8d3c',
weight: 2,
fillColor: '#fecc5c',
fillOpacity: 0.5
})
circle.bindPopup("magnitude:",d.magnitude,"time:",d.dtg)
circlesLayer.addLayer(circle) })
}
Insert cell
Insert cell
Insert cell
data = crossfilter(dataset)
Insert cell
dateDimension = data.dimension(d => d.dtg)
Insert cell
magnitudeDimension = data.dimension(d => d.magnitude)
Insert cell
magnitudeGroup = magnitudeDimension.group()
Insert cell
depthDimension = data.dimension(d => d.depth)
Insert cell
depthGroup = depthDimension.group()
Insert cell
timeDimension = data.dimension((d) => d3.timeHour(d.dtg))
Insert cell
timeGroup = timeDimension.group()
Insert cell
Insert cell
dc = require('dc')
Insert cell
crossfilter = require('crossfilter2')
Insert cell
d3 = require('d3')
Insert cell
$ = require('jquery').then(jquery => {
window.jquery = jquery;
return require('popper@1.0.1/index.js').catch(() => jquery);
})
Insert cell
bootstrap = require('bootstrap')
Insert cell
L = require('leaflet@1.5.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