Monday, December 6, 2021

To make dotted lines or dashed lines on yaxis

 svg.selectAll(".grid")

    .data(uniqueDistanceArr)

    .enter.append("g")

    .attr("class", "grid")

    .attr("transform", "translate(194, '+10+')")

    .style("stroke-dasharray", function(d){

                return(5+","+yscalestatiocode(d)+");})

    .call(make_x_gridlines()

    .tickSize(-height)

    .tickFormat("")

    .ticks(d3.timeMinute.every(2))

)


or


svg.selectAll('.grid')

    .data(d3.timeMinute.range(data[0].arrivalTime, data[data.length-1].departuretime, 2))

    .enter().append("g")

    .attr("class", "grid")

    .attr("transform", translate(50, "+10+")"))

.style("stroke-dasharray", function(d){

                return(1+","+xscale(d)+"");

                })

    .call(make_y_gridlines()

            .ticksize(-width)

            .tickFormat(""))


No comments:

Post a Comment