class MyChart {
_height = 200
constructor(data) {
this._data = data
this._svg = d3.create("svg")
.attr("width", width)
.attr("height", this._height)
}
data(_) {
return arguments.length ? (this._data = _, this) : this._data;
}
removeData() {
this._data.shift()
console.log(this._data)
}
render() {
this._svg
.selectAll("circle")
.data(this._data)
.join(
enter => enter.append("circle")
.attr("cx", d => d * 30)
.attr("cy", this._height / 2)
.attr("r", d => d)
.attr("fill", "hsl(216deg 100% 13%)"),
update => update
.attr("fill", "gray"),
exit => exit
.attr("fill", "red")
);
return this._svg.node();
}
}