Published
Edited
Jan 13, 2022
Insert cell
Insert cell
Insert cell
Insert cell
chart_mriver
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// {
// return html`${d3
// .ticks(d3.min(data, d => d.interest_avg), d3.max(data, d => d.interest_avg), 20)
// .map(color)
// .map(
// t =>
// `<span style="background:${t}; height: 50px; width:4%; display: inline-block;">&nbsp;</span>`
// )}`;
// }
Insert cell
Insert cell
Insert cell
Insert cell
data_mriver = [...d3.rollup(data_mriver_raw, v => v, d => d.search)].map(e => ({
search: e[0],
interest_avg: e[1][0].interest_avg,
order: e[1][0].order,
data: e[1].map(d => (({week_num, week, interest}) => ({week_num, week, interest}))(d))
})).sort((a, b) => d3.ascending(a.order, b.order))
Insert cell
// data_raw_new = FileAttachment("2020-news-cycle-data-4@1.csv").csv({typed: true})
data_mriver_raw = FileAttachment("ridgedatanew.csv").csv({typed: true})
Insert cell
// data_raw_old = FileAttachment("2020-news-cycle-data@2.csv").csv({typed: true})
Insert cell
Insert cell
// d3_6 = require("d3@6")
Insert cell
Insert cell
Insert cell
// aaa = printTable(volumes,['link'])
Insert cell
aaa = render_data_table(
volumes.length === 0 ? [{ "No matches found": "" }] : volumes
)

Insert cell
Insert cell
import { text, select } from "@jashkenas/inputs"
Insert cell
import { render_data_table as data_table } from "@info474/utilities"
Insert cell
// Function to render a table
render_data_table = options => html`<table>
<thead>
<tr>${Object.keys(options[0]).map((d, i) => {
let label = d;
if (d === "keywords" || d === "content" || d === 'time' || d === 'type' || d === 'link' || d === '') return "";
return `<th>${label}</th>`;
})}
</tr>
<thead>
<tbody>
${options.map(row => {
// return html`<tr>`
return html`<tr>${Object.keys(row).map((key, index) => {
if (key === "title") {
return `<td><a href=${row.link} target="_blank">${row[key]}</a></td>`;
} else if (key === "link" || key === "keywords" || key === "content"|| key === 'time' || key=== 'type' || key === '') return "";
return `<td>${row[key]}</td>`;
})}</tr>`;
})}
</tbody>

</table>
`
Insert cell
mutable filter = undefined
Insert cell
s = d3.scaleSqrt()
.domain([1, d3.max(data.map(d => d.value))])
.range([6, 82]);
Insert cell
volumes = {
let volumes = d3.csvParse(await FileAttachment("newstotal.csv").text())
//const attachment = await FileAttachment("nati_father_surname.csv").csv();
//let volumes = d3.sort(attachment, d => d)
//console.log(volumes)
volumes = volumes.filter(d=>d["content"].toLowerCase().includes(filter.toLowerCase()+" ")) // filter out Eremita a Parigi (V020)
return volumes
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// Chinatxt = (await FileAttachment("China.txt").text()).trim()
Insert cell
cloudtxt = {
if(chart_mriver == 'China'){
return (await FileAttachment("China.txt").text()).trim()
}
if(chart_mriver == 'people'){
return (await FileAttachment("people.txt").text()).trim()
}
if(chart_mriver == 'Secretary'){
return (await FileAttachment("Secretary.txt").text()).trim()
}
if(chart_mriver == 'Afghanistan'){
return (await FileAttachment("Afghanistan.txt").text()).trim()
}
if(chart_mriver == 'Blinken'){
return (await FileAttachment("Blinken.txt").text()).trim()
}
if(chart_mriver == 'Tigray'){
return (await FileAttachment("Tigray.txt").text()).trim()
}
if(chart_mriver == 'military'){
return (await FileAttachment("military.txt").text()).trim()
}
if(chart_mriver == 'Taiwan'){
return (await FileAttachment("Taiwan.txt").text()).trim()
}
if(chart_mriver == 'President'){
return (await FileAttachment("President.txt").text()).trim()
}
if(chart_mriver == 'Foreign'){
return (await FileAttachment("Foreign.txt").text()).trim()
}
if(chart_mriver == 'Mexico'){
return (await FileAttachment("Mexico.txt").text()).trim()
}
if(chart_mriver == 'human'){
return (await FileAttachment("human.txt").text()).trim()
}
if(chart_mriver == 'rights'){
return (await FileAttachment("rights.txt").text()).trim()
}
if(chart_mriver == 'Iraq'){
return (await FileAttachment("Iraq.txt").text()).trim()
}
if(chart_mriver == 'climate'){
return (await FileAttachment("climate.txt").text()).trim()
}
if(chart_mriver == 'State'){
return (await FileAttachment("State.txt").text()).trim()
}
if(chart_mriver == 'international'){
return (await FileAttachment("international.txt").text()).trim()
}
if(chart_mriver == 'Iran'){
return (await FileAttachment("Iran.txt").text()).trim()
}
if(chart_mriver == 'Russia'){
return (await FileAttachment("Russia.txt").text()).trim()
}
if(chart_mriver == 'ASEAN'){
return (await FileAttachment("ASEAN.txt").text()).trim()
}
if(chart_mriver == 'security'){
return (await FileAttachment("security.txt").text()).trim()
}
if(chart_mriver == 'September'){
return (await FileAttachment("September.txt").text()).trim()
}
if(chart_mriver == 'Senegal'){
return (await FileAttachment("Senegal.txt").text()).trim()
}
if(chart_mriver == 'Minister'){
return (await FileAttachment("Minister.txt").text()).trim()
}
if(chart_mriver == 'death'){
return (await FileAttachment("death.txt").text()).trim()
}
if(chart_mriver == 'work'){
return (await FileAttachment("work.txt").text()).trim()
}
if(chart_mriver == 'Japan'){
return (await FileAttachment("Japan.txt").text()).trim()
}
if(chart_mriver == 'Korea'){
return (await FileAttachment("Korea.txt").text()).trim()
}
if(chart_mriver == 'rights'){
return (await FileAttachment("rights.txt").text()).trim()
}
if(chart_mriver == 'delegation'){
return (await FileAttachment("delegation.txt").text()).trim()
}
if(chart_mriver == 'Sudan'){
return (await FileAttachment("Sudan.txt").text()).trim()
}
if(chart_mriver == 'forces'){
return (await FileAttachment("forces.txt").text()).trim()
}
if(chart_mriver == 'National'){
return (await FileAttachment("National.txt").text()).trim()
}
if(chart_mriver == 'Croatia'){
return (await FileAttachment("Croatia.txt").text()).trim()
}
if(chart_mriver == 'Sweden'){
return (await FileAttachment("Sweden.txt").text()).trim()
}
if(chart_mriver == 'AIDS'){
return (await FileAttachment("AIDS.txt").text()).trim()
}
if(chart_mriver == 'State'){
return (await FileAttachment("State.txt").text()).trim()
}
if(chart_mriver == 'violence'){
return (await FileAttachment("violence.txt").text()).trim()
}
if(chart_mriver == 'refugees'){
return (await FileAttachment("refugees.txt").text()).trim()
}
if(chart_mriver == 'torture'){
return (await FileAttachment("torture.txt").text()).trim()
}
if(chart_mriver == 'democratic'){
return (await FileAttachment("democratic.txt").text()).trim()
}
if(chart_mriver == 'regime'){
return (await FileAttachment("regime.txt").text()).trim()
}
if(chart_mriver == 'meeting'){
return (await FileAttachment("meeting.txt").text()).trim()
}
if(chart_mriver == 'peace'){
return (await FileAttachment("peace.txt").text()).trim()
}
if(chart_mriver == 'Uganda'){
return (await FileAttachment("Uganda.txt").text()).trim()
}
if(chart_mriver == 'Colombia'){
return (await FileAttachment("Colombia.txt").text()).trim()
}
if(chart_mriver == 'Assistant'){
return (await FileAttachment("Assistant.txt").text()).trim()
}
if(chart_mriver == 'democracy'){
return (await FileAttachment("democracy.txt").text()).trim()
}
if(chart_mriver == 'Egypt'){
return (await FileAttachment("Egypt.txt").text()).trim()
}
if(chart_mriver == 'government'){
return (await FileAttachment("government.txt").text()).trim()
}
if(chart_mriver == 'Bosnia'){
return (await FileAttachment("Bosnia.txt").text()).trim()
}
if(chart_mriver == 'Pacific'){
return (await FileAttachment("Pacific.txt").text()).trim()
}
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more