我们是否使用JavaScript创建了组合图?

时间:2018-11-23 12:48:00

标签: javascript html5

我正在尝试创建组合(混合图表)barChart和lineChart。 iam创建有关员工详细信息,当前在职员工和离职员工的图表。在第一个数据集中,我采用了当前在职员工的条形图,第二个数据集是在辞职员工的折线图中显示的,这里我对第一个数据集和第二个数据集有不同的强调。条形图工作正常,但是折线图工作不正常。有谁能帮助我获得正确的线图以及所需的详细信息

<!doctype html>
<html lang="en">
<head>
    <meta charset ="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bar-Graphs</title>
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script>
            </head>
            <body>
            <canvas id="myChart" width="400" height="400"></canvas>
            <div class="container">
            <div class="col-lg-12">
            <div class="col-lg-4">

            </div>
            <div class="col-lg-4">

            </div>
            <div class="col-lg-4">

            </div>
            </div>
            </div>
            <script>
        var ctx = document.getElementById('myChart').getContext('2d');
        var populationChart = new Chart(ctx, {
            type: 'bar',
            data:{
                labels:['Rakesh', 'Geetha', 'Harthika', 'Kesav', 'Satya', 'Anusha', 'Sandeep', 'Hima'],
                datasets:[{
                    label:'GDS Employ',
                    data:[2010, 2013, 2015, 2016, 2017, 2017, 2018, 2018],
                    backgroundColor: [
                        'rgba(255, 99, 132, 0.2)',
                        'rgba(54, 162, 235, 0.2)',
                        'rgba(255, 206, 86, 0.2)',
                        'rgba(75, 192, 192, 0.2)',
                        'rgba(153, 102, 255, 0.2)',
                        'rgba(255, 159, 64, 0.2)',
                        'rgba(255, 99, 132, 0.2)',
                        'rgba(54, 162, 235, 0.2)',
                        'rgba(255, 206, 86, 0.2)',
                        'rgba(75, 192, 192, 0.2)',
                        'rgba(153, 102, 255, 0.2)',
                        'rgba(255, 159, 64, 0.2)'
                    ],
                    borderColor: [
                        'rgba(255,99,132,1)',
                        'rgba(54, 162, 235, 1)',
                        'rgba(255, 206, 86, 1)',
                        'rgba(75, 192, 192, 1)',
                        'rgba(153, 102, 255, 1)',
                        'rgba(255, 159, 64, 1)',
                        'rgba(255,99,132,1)',
                        'rgba(54, 162, 235, 1)',
                        'rgba(255, 206, 86, 1)',
                        'rgba(75, 192, 192, 1)',
                        'rgba(153, 102, 255, 1)',
                        'rgba(255, 159, 64, 1)'
                    ],
                },
                    {
                        labels:['Ipsitha', 'Urakesh', 'Ramakanth', 'sindhu', 'Abhilash'],
                        type:'line',
                        label:'Resign employee',
                        data:[2013, 2014, 2014, 2016, 2018],
                        backgroundColor: [
                            'rgba(255, 99, 132, 0.2)',
                        ],
                        borderColor: [
                            'rgba(255,99,132,1)',
                        ],
                    }]
            },
            options:{
                title:{
                    display:true,
                    text:'Total Employee'

                },
                ticks: {
                    beginAtZero:false
                }
            }
        })
    </script>
        </body>
</html>




<!--
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Home</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body onload="myfunction()">
<div id="spinner"></div>
<header>
    <nav class="navbar navbar-expand-lg navbar-light bg-transparent" style="z-index: 1">
        <div class="container">
        <a class="navbar-brand" href="#" style="color: rgb(248, 152, 50);font-size: 30px;">Navbar</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse justify-content-end" id="navbarNavDropdown">
            <ul class="navbar-nav">
                <li class="nav-item active">
                    <a class="nav-link" href="#" style="color: rgb(248, 152, 50);">Home <span class="sr-only">(current)</span></a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#" style="color: rgb(248, 152, 50);">Features</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#" style="color: rgb(248, 152, 50);">Pricing</a>
                </li>
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="color: rgb(248, 152, 50);">
                        Dropdown link
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
                        <a class="dropdown-item" href="#">Action</a>
                        <a class="dropdown-item" href="#">Another action</a>
                        <a class="dropdown-item" href="#">Something else here</a>
                    </div>
                </li>
            </ul>
        </div>
        </div>
    </nav>
    <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel" style="bottom: 72px">
        <ol class="carousel-indicators">
            <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
            <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
            <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
        </ol>
        <div class="carousel-inner">
            <div class="carousel-item active">
                <img class="d-block w-100" src="images/banner3.jpg" alt="First slide">
            </div>
            <div class="carousel-item">
                <img class="d-block w-100" src="images/banner1.jpg" alt="Second slide">
            </div>
            <div class="carousel-item">
                <img class="d-block w-100" src="images/banner2.jpg" alt="Third slide">
            </div>
        </div>
        <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
            <span class="carousel-control-prev-icon" aria-hidden="true"></span>
            <span class="sr-only">Previous</span>
        </a>
        <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"></span>
            <span class="sr-only">Next</span>
        </a>
    </div>
</header>
<main id="pagecontent" style="display: none;">
<div class="container">
    <div  class="row">
        <section id="aboutus">
            <div>
                <h1 class="ma-auto">ABOUT US</h1>
                <p>zxcvbn asdfghjklk qwertyuiop zxcvbnm asdfghjkll qwertyuiop zxcvbnm asdfghjkl qwertyuiop zxcvbnm asdfghjkl yuioop asdfag ghjkl asdf ghjl asdfsg hjkl asdfg jk;lh asdfg jk;h asdafsg jkl;h </p>
                <div class="col-md-6">
                    <img src="images/col.jpg">
                </div>
                <div class="col-md-6">
                    <div class="progress">
                        <div class="progress-bar progress-bar-striped" role="progressbar" style="width: 10%" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100"></div>
                    </div>
                    <div class="progress">
                        <div class="progress-bar progress-bar-striped bg-success" role="progressbar" style="width: 25%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
                    </div>
                    <div class="progress">
                        <div class="progress-bar progress-bar-striped bg-info" role="progressbar" style="width: 50%" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100"></div>
                    </div>
                    <div class="progress">
                        <div class="progress-bar progress-bar-striped bg-warning" role="progressbar" style="width: 75%" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"></div>
                    </div>
                    <div class="progress">
                        <div class="progress-bar progress-bar-striped bg-danger" role="progressbar" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
                    </div>
                </div>
            </div>
        </section>
    </div>
</div>
</main>
<script type="text/javascript">
    function myfunction(){
        var test = setTimeout(loadpage, 2000);
    }
    function loadpage() {
        document.getElementById("pageContent").style.display = "block";
        document.getElementById("spinner").style.display = "none;";
    }
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</body>
</html>-->

强文本

0 个答案:

没有答案