Problem in Modal dialog box

12 views
Skip to first unread message

Sara Malik

unread,
Nov 15, 2017, 1:32:53 PM11/15/17
to d3-js
Hello
I have a problem in Modal Dialog box, when i click then modal dialog box will not appear. Please kindly help me, i shall be very thankful to you for this favor 

HTML CODE

<div class="modal fade" id="myModal" role="dialog" data-toggle="modal" >
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title"></h4>
            </div>
            <div class="modal-body">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>


JS Script 

var newmap= d3.json("USA_adm1.json", function(error, topology) {
    g.selectAll("path")
      .data(topojson.object(topology,topology.objects.USA_adm3)
          .geometries)
    .enter()
      .append("path")
      .attr("d", path)
       .attr('x',function(d,i) { return i; })
    .attr('y',80)
       .style("fill", function(d,i) { return color(i); })
      

.on("click", function (d) {
            
    d3.select('#myModal').on('shown.bs.modal', function(d) {
    var d = d3.select(".info").data().pop(); 
    let modalTitle = d3.selectAll("h4.modal-title");
    modalTitle.text("test");
    let modalBody = d3.selectAll(".modal-body");
    modalBody.html("Country should be: " + d.properties.NAME_1 + "<br>" + "Operator should be: " + d.properties.NAME_3);
    console.log(d, "operator: " + d.properties.NAME_1 + "   Country: " + d.properties.NAME_3);
})
  }) 


             .on("mouseout", function(d){
     g.append("rect")
                  .style("stroke", "black")
                  .style("stroke-width", "4")
                  .style("fill", "none")
                  .style("stroke-linecap", "round")
                  .style("stroke-linejoin", "round")
                  .attr("class", "infoLine info")
                  .datum(d)
                
                
   
  })
Reply all
Reply to author
Forward
0 new messages