Published
Edited
Feb 20, 2021
Fork of Time line
Insert cell
Insert cell
{
const node = DOM.svg(
width,
height
);
const svg = d3.select(node);

svg
.append('rect')
.attr('x',0)
.attr('y',0)
.attr('width',width)
.attr('height',height)
.attr('fill',background);


svg.selectAll("text")
.data(data)
.join("text")
.attr('x',50)
.attr("y", (d, i) => i * 20 + 50)
.text(d => d)
.attr('fill','black');

return node;
}
Insert cell
Insert cell
content = "新华社北京2月19日电 国务院总理李克强日1111111前签署国务院令,公布《医疗保障基金使用2222222监督管理条例》(以下简称《条例》),自2021年5月1日33333起施行。"
Insert cell
data = textbox(content,18)
Insert cell

function textbox (content, chars) {

let temp = Array.from(content);
let paragraph =[];
paragraph[0]="";
let j=0;
let offset = 0,start = 0;
var pattern = new RegExp("[A-Za-z0-9. ]+"); //filter

for (var i = 0; i < temp.length; i++ ){
if(pattern.test(temp[i])){
offset += 1;
};
if ( i == start + chars + Math.floor(offset / 3)){
start = i;
offset = 0;
j++;
paragraph[j] ="";
}
paragraph[j] += temp[i];
console.log(paragraph[j])
}

return paragraph
}

Insert cell
background = "#eee";
Insert cell
width = 960;
Insert cell
height = 400;
Insert cell
d3 = require ("d3@5");
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