javascript 未捕获的 ReferenceError:图表未定义 - Laravel 5 中的 Chart.js

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34297440/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 17:30:04  来源:igfitidea点击:

Uncaught ReferenceError: Chart is not defined - Chart.js in laravel 5

javascriptchartschart.js

提问by Jose Cerejo

I am creating my control panel and liked to create a chart to show data from my table but is giving me this error. Uncaught ReferenceError: Chart is not definedI do not know much about javascript. If anyone could help me grateful.

我正在创建我的控制面板并喜欢创建一个图表来显示我的表格中的数据,但给了我这个错误。 Uncaught ReferenceError: Chart is not defined我不太了解javascript。如果有人可以帮助我感激不尽。

Html

html

<div class="box-body no-padding">
    <canvas id="canvas" height="450" width="610"></canvas>
</div><!-- /.box-body -->

My script

我的剧本

<script>

    var PieChart = [
            {
                value: 40,
                color:"#fcc79e"
            },
            {
                value : 30,
                color : "#beefd2"
            },
            {
                value : 90,
                color : "#ffddfb"
            }

        ];

var myPieChart = new Chart(document.getElementById("canvas").getContext("2d")).Pie(PieChart);

            </script>   

回答by Farhan

Update your library. I have test this and working.

更新您的图书馆。我已经测试过这个并且正在工作。

 <div class="box-body no-padding">
    <canvas id="canvas" height="450" width="610"></canvas>
</div>
<script src="https://raw.githubusercontent.com/nnnick/Chart.js/master/Chart.min.js" ></script>
<script>

    var PieChart = [
            {
                value: 40,
                color:"#fcc79e"
            },
            {
                value : 30,
                color : "#beefd2"
            },
            {
                value : 90,
                color : "#ffddfb"
            }

        ];

var myPieChart = new Chart(document.getElementById("canvas").getContext("2d")).Pie(PieChart);

            </script>