未捕获的类型错误:(中间值).饼图不是一个函数-图表.js

Uncaught TypeError: (intermediate value).Pie is not a function -Chart.js

本文关键字:一个 函数 js 图表 错误 类型 中间      更新时间:2023-09-26

我想用图表画饼图.js 2.1.6

我的代码 :

<script src="~/Plugin/Chart.js 2.1.6/dist/Chart.min.js"></script>
<canvas id="mychart"></canvas>
var data = [
        {
            value: 300,
            color: "#F7464A",
            highlight: "#FF5A5E",
            label: "Red"
        },
        {
            value: 50,
            color: "#46BFBD",
            highlight: "#5AD3D1",
            label: "Green"
        },
        {
            value: 100,
            color: "#FDB45C",
            highlight: "#FFC870",
            label: "Yellow"
        }
    ]

var ctx = $("#myChart").get(0).getContext("2d"); var myPieChart = new Chart(ctx).Pie(data);

但是我收到一个错误:

未捕获的类型错误:(中间值)。馅饼不是一个函数。

您是否尝试过使用以下代码?

var myPieChart = new Chart(ctx,{
    type: 'pie',
    data: data,
    options: options
});