Notebooks 2.0 is here.

Public
Edited
Oct 11, 2021
Insert cell
Insert cell
Insert cell
Insert cell
idView = 'MX-DY6K5-K1YZ0-VLP6A' // Watershed
Insert cell
mapx.ask('view_add', {idView: idView}) // Watershed
Insert cell
Insert cell
view_attribute_table_url = mapx.ask('get_view_table_attribute_url', {idView: idView})
Insert cell
html`<a href="${view_attribute_table_url}" target="_blank">Attribute table for ${mxGetViewByiD(idView).data.title.en}</a>`
Insert cell
Insert cell
data = mapx.ask('get_view_table_attribute', {idView: idView})
Insert cell
o = mapx.ask('download_view_source_vector', {idView: idView})
Insert cell
Insert cell
basin_hectares = d3.rollup(data, v => d3.sum(v, d => d.hectares), d => d.mj_basin__);
Insert cell
basin_hectares_array = [...basin_hectares].sort( (a, b) => a[1] - b[1]);
Insert cell
html`<div id="chart" style="height: 300px;"></div>`
Insert cell
{
let chart_option = {
grid: {
left: '0%',
right: '0%',
top: '3%',
bottom: '0%',
containLabel: true
},
yAxis: {
data: basin_hectares_array.map(v => v[0])
},
xAxis: {
},
series: [{
data: basin_hectares_array.map(v => v[1]),
type: 'bar',
color: 'green'
}]
};
let chart = echarts.init(document.getElementById('chart'));
window.addEventListener('resize', function(event){
chart.resize();
});
chart.setOption(chart_option);
return chart;
}
Insert cell
Insert cell
Insert cell
d3 = require("d3-array")
Insert cell
echarts = require('https://unpkg.com/echarts@4.8.0/dist/echarts.js')
Insert cell
views = mapx.ask('get_views')
Insert cell
function mxGetViewByiD(id) {
let out = null;
views.forEach((view) => {
if (view.id === id) {
out = view;
return;
}
});
return out;
}
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