Wednesday, November 3, 2021

How to draw polyline in d3js

 <!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8" />

    <title>D3JS</title>

    <script src="https://d3js.org/d3.v4.min.js" type="text/javascript"></script>

    <link href="https://www.w3schools.com/w3css/4/w3.css" rel="stylesheet"

          type="text/css"/>

    <link 

          href="https://image.shutterstock.com/image-vector/internet-icon-black-computer-arrow-600w-1028095990.jpg" 

          rel="shortcut icon" />

</head>

<body>

    

        <p>D3 Tutorials</p>

    <script>

        var width = 400; height = 300;


        var data = [10, 15, 20, 25, 30];


        var svg = d3.select("body").append("svg").attr("width", width)

            .attr("height", height);


        svg.append("polyline")      // attach a polyline

            .style("stroke", "black")  // colour the line

            .style("fill", "none")     // remove any fill colour

            .attr("points", "100,50, 200,150, 300,50");  // x,y points


    </script>

    <input type="button" class="w3-button w3-black" value="Input Button">

</body>

</html>

No comments:

Post a Comment