chart.js饼图中的两种音色

时间:2017-10-16 07:14:08

标签: jquery css charts chart.js pie-chart

根据截图,有没有人在chart.js饼图的一个部分中遇到过两个音效?

two tone effect

知道如何解决这个问题吗?它并不是一直出现的。这是一个显示性别百分比的简单饼图。

抱歉,我忘了提供代码。

JSFIDDLE LINK

    var xitems = ['male','female'];
    var yitems = [478,522];
    new Chart(document.getElementById("chartcanvas"), {
                    type: 'pie',
                    data: {
                      labels: xitems,
                      datasets: [
                        {
                          data: yitems,
                          backgroundColor: ["#8DB6CD","#FFB6C1","#DC143C","#800080","#0000FF","#00C5CD","#00EE00","#FFFF00","#FFD700","#FFA500","#8B5A00","#FF4500","#FA8072","#FF3E96",
                          "#BA55D3","#191970","#00FF7F","#B7B7B7","#000000","#006400","#ADFF2F","#EEEE00","#3D59AB","#AB82FF","#CDB5CD","#FF69B4",
                          "#FF0000"],
                          fill: false
                        }
                      ]
                    },
                    options: {
                        tooltips: {
                            enabled: false,
                        },
                        showPercentage: true, //Enables percentages on the pie
                    }
                });

1 个答案:

答案 0 :(得分:0)

我只是看了JS Fiddle并替换了为我工作的Chart JS脚本链接。我使用版本2.7.0而不是CDNJS中的2.4.0。

我不确定你是否也需要这两个库。只需使用https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.0/Chart.bundle.min.js即可。

希望这有帮助。