|
|
|
@ -16,7 +16,7 @@ d3.select('svg').selectAll('path')
|
|
|
|
.attr('fill', '#099')
|
|
|
|
.attr('fill', '#099')
|
|
|
|
.attr('d', dAttributeFunction);
|
|
|
|
.attr('d', dAttributeFunction);
|
|
|
|
|
|
|
|
|
|
|
|
const points = [];
|
|
|
|
let points = [];
|
|
|
|
d3.select('svg').on('click', (event)=>{
|
|
|
|
d3.select('svg').on('click', (event)=>{
|
|
|
|
points.push([event.x, event.y])
|
|
|
|
points.push([event.x, event.y])
|
|
|
|
const path = d3.path();
|
|
|
|
const path = d3.path();
|
|
|
|
@ -25,9 +25,22 @@ d3.select('svg').on('click', (event)=>{
|
|
|
|
path.lineTo(points[i][0], points[i][1])
|
|
|
|
path.lineTo(points[i][0], points[i][1])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
path.closePath()
|
|
|
|
path.closePath()
|
|
|
|
|
|
|
|
d3.select('#polygon').remove()
|
|
|
|
d3.select('svg')
|
|
|
|
d3.select('svg')
|
|
|
|
.append('path')
|
|
|
|
.append('path')
|
|
|
|
.attr('id', 'polygon')
|
|
|
|
.attr('id', 'polygon')
|
|
|
|
.attr('fill', 'black')
|
|
|
|
.attr('fill', 'black')
|
|
|
|
.attr('d', path)
|
|
|
|
.attr('d', path)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
d3.select('body').on('keydown', (event)=>{
|
|
|
|
|
|
|
|
d3.select('tbody').html('');
|
|
|
|
|
|
|
|
for(point of points){
|
|
|
|
|
|
|
|
const row = d3.select('tbody')
|
|
|
|
|
|
|
|
.append('tr')
|
|
|
|
|
|
|
|
row.append('td')
|
|
|
|
|
|
|
|
.html(point[0])
|
|
|
|
|
|
|
|
row.append('td')
|
|
|
|
|
|
|
|
.html(point[1])
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
points = [];
|
|
|
|
|
|
|
|
})
|
|
|
|
|