4(D) : Showing the data as a Line chart (single, fewer and multiple lines) Using HTML5 and D3.js and Canvas.js

 

 Data Visualization 

( 3160717 )

Practical and Source Codes



<!DOCTYPE HTML>
<html>

<head>
    <title>Single Line chart</title>
    <meta charset="utf-8">
    <meta name="author" content="SidPro" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <meta name="description" content="Showing the data as a Single Line chart" />
    <meta name="keywords" content="Single,Line,Chart,Single Line Chart,Line" />
    <script src="js/jquery-3.5.1.min.js"></script>
    <script src="js/canvasjs.min.js"></script>
</head>

<body>
    <h2>Showing the data as a Single Line chart</h2>
    <div id="chartContainer" style="height: 600px; width: 100%;"></div>
</body>
<script type="text/javascript">

    window.onload = function () {
        /*CanvasJS.addColorSet("colors",
            [//colorSet Array
            "#2F4F4F",
            "#008080",
            "#2E8B57",
            "#3CB371",
            "#90EE90"                
            ]);*/
        var chart = new CanvasJS.Chart("chartContainer", {
            //colorSet: "colors",
            title: {
                text: "Showing the sales data of Facewash as a Single Line chart",
                fontSize: 30,
            },
            axisX: {
                title: "Month",
            },
            axisY: {
                title: "Sales Unit",
            },
            theme: "dark1", //"light1", "light2", "dark1", "dark2"
            data: [
                {
                    // Change type to "column", "doughnut", "line", "splineArea", etc.
                    type: "line",
                    showInLegend: true,
                    legendText: "Facewash",
                    dataPoints: [
                        { label: "Jan", y: 1200 },
                        { label: "Feb", y: 2100 },
                        { label: "Mar", y: 3550 },
                        { label: "Apr", y: 1870 },
                        { label: "May", y: 1560 },
                        { label: "Jun", y: 1890 },
                        { label: "Jul", y: 1780 },
                        { label: "Aug", y: 2860 },
                        { label: "Sep", y: 2100 },
                        { label: "Oct", y: 2300 },
                        { label: "Nov", y: 2400 },
                        { label: "Dec", y: 1800 }
                    ]
                }
            ]
        });
        chart.render();
    }
</script>

</html>




Go Back

No comments:

Get new posts by email:


APY Logo