var myData = [{
"x": "45.4969717",
"y": "10.605375399999957"
}, {
"x": "45.4847328802866",
"y": "9.236798286437988"
}, {
"x": "42.4838657",
"y": "9.25125330000003",
}, {
"x": "40.1053737",
"y": "12"
}, {
"x": "42.4",
"y": "10.4"
}];
var margin = {top: 10, bottom: 10, left: 10, right: 10},
width = 450.57913-margin.left-margin.right,
height = 350-margin.top-margin.bottom;
// parse data
myData.forEach(function(d) {
d.x = +d.x;
d.y = +d.y;
});
var xline = d3.scaleLinear().domain(d3.extent(myData, function(d) { return d.x; })).nice().range([0, width]);
var yline = d3.scaleLinear().domain(d3.extent(myData, function(d) { return d.y; })).nice().range([height, 0]);
var colorScale = d3.scaleOrdinal(d3.schemeCategory10);
var svgViewport = d3.select("#mappa-italia")
.attr('width', width+margin.left+margin.right)
.attr('height', height+margin.top+margin.bottom)
.append("g")
.attr('transform', 'translate('+margin.left+', ' + margin.top+')')
.attr("id", "locations");
var circleElements = svgViewport.selectAll("circle").data(myData).enter().append("circle").attr("cx", function(d) {
return xline(d.x);
}).attr("cy", function(d) {
return yline(d.y);
}).attr("r", "5").style('fill', function(d, i) {
return colorScale(i);
});
<script src="https://d3js.org/d3.v5.min.js"></script>
<svg id="mappa-italia"></svg>