0
<!doctype html>
<html>
<head>
<title>Transitions  Tutorial</title>
<script src="https://d3js.org/d3.v4.min.js"></script>
</head>
<body>
    <script>

    d3.json("myData.json",function(data){

    var canvas= d3.select("body").append("svg")
                                .attr("width",500)
                                .attr("height",500);
        canvas.selectAll("rect")
                        .data(data)
                        .enter()
                            .append("rect")
                            .attr("width",function(d){return d.age*10;})
                            .attr("height",48)
                            .attr("y",function(d,i){ i*48;})
                            .attr("fill","blue");
    })


    //console.log(d3);


    </script>
</body>
</html>

the following html is to extract data from json file myData.json I am getting this error message :"Failed to load file:///D:/Java/D3_DEMO/myData.json: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https."

  • are you running a local http server? Its best to do so when making html d3 js webpages, which access separate data files – Tom Shanley Oct 31 '17 at 20:22
  • I am just creating a simple html file and opening it as an html file, I am not running it on server. – avanish kumar Nov 01 '17 at 04:51
  • Please refer to https://stackoverflow.com/questions/10752055/cross-origin-requests-are-only-supported-for-http-error-when-loading-a-local – Tom Shanley Nov 01 '17 at 23:29

0 Answers0