首页 > 解决方案 > chartjs 上的标签,当屏幕尺寸较小时无法点击

问题描述

我遇到了chartjs的问题,当我的屏幕尺寸较小时,我无法单击标签,可能只是其中一个但不是全部,就像它们被禁用或我不知道一样。

function generatePieChart(data, labels, chartElementId) {
    var colors = new Array();

    var randomColorFactor = function () {
        return Math.round(Math.random() * 255);
    };
    var randomColor = function (opacity) {
        return 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',' + (opacity || '.3') + ')';
    };

    for (var i = 0; i < labels.length; i++) {
        colors.push(randomColor(0.7))
    }
    var config = {
        type: 'pie',
        data: {
            datasets: [{
                data: data,
                label: labels,
                backgroundColor: colors,
            }],
            labels: labels
        },
        options: {
            responsive: true
        }
    };

    var ctx = document.getElementById(chartElementId).getContext("2d");
    window.myPie = new Chart(ctx, config);
}

标签: javascriptcharts

解决方案


推荐阅读