0

我正在使用谷歌图表制作甜甜圈图。我已经正确编写了所有内容并且我正确地获取了所有值,它仍然会抛出这个错误:- Uncaught TypeError: Cannot read property 'value' of null (在第 10 行,这是 var 员工行)

我的图表制作代码

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
               <script type="text/javascript">

                var exemployee = parseFloat(document.getElementById('exemployee').value);
                var consultant = parseFloat(document.getElementById('consultant').value);
                var vendor = parseFloat(document.getElementById('vendor').value);
                var client = parseFloat(document.getElementById('client').value);
                var investor = parseFloat(document.getElementById('investor').value);
                  google.load("visualization", "1", {packages:["corechart"]});
                  google.setOnLoadCallback(drawChart);
                  function drawChart() {
                    var data = google.visualization.arrayToDataTable([
                      ['Description', 'Value'],
                      ['Employee',     employee],
                      ['ExEmployee',      exemployee],
                      ['Consultant',      consultant],
                      ['Vendor',      vendor],
                      ['Client',      client],
                      ['Investor',      investor],
                      ['Total', total]
                    ]);

                    var options = {
                      title: 'Mail Activity',
                      pieHole: 0.4,
                    };

                    var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
                    chart.draw(data, options);
                  }
                </script>

HTML

 <input type="hidden" name="employee" id="employee" value="0">
                <input type="hidden" name="exemployee" id="exemployee" value="1">
                <input type="hidden" name="consultant" id="consultant" value="1">
                <input type="hidden" name="vendor" id="vendor" value="0">
                <input type="hidden" name="client" id="client" value="0">
                <input type="hidden" name="investor" id="investor" value="0">
                 <div id="donutchart" class="donutchart" style="width: 700px; height: 300px;"></div>

这里可能有什么问题?

4

0 回答 0