在ChartJS中避免Y标签重叠

时间:2018-06-21 06:03:53

标签: chart.js

我有以下ChartJS:

enter image description here

标签相互重叠。我的代码是:

var actionData = {
            labels: [['Enhance use of biodiversity','for food and agriculture'],['Favour the maintenance and use','of biodiversity for food and','agriculture'],['Management practices','supporting the access to and','conservation of genetic','resources'],['Avoided negative impacts on','biodiversity or wild foods'],['Consumption practices','supporting the use and','conservation of biodiversity','for food and agriculture'],['Diversified diet'],['Diversified food'],['Food diversification'],['Nutritionally diverse'],['Diversified diet'],['Diversified farm'],['Livestock diversity'],['Mixed crop-livestock system'],['Certified seed'],['Community enterprise'],],
            datasets: [{
                label: 'Action & Commitment',
                backgroundColor: "#3180B8",
                borderColor: "#fff",
                borderWidth: 1,
                data: [1.20,6.48,0.41,4.91,2.53,10.14,6.76,6.76,10.14,6.76,10.14,6.76,10.14,6.76,10.14,]
            }]

        };

        var ctx3 = document.getElementById('Ibar1').getContext('2d');
        window.myHorizontalBar = new Chart(ctx3, {
            type: 'horizontalBar',
            data: actionData,
            options: {
                // Elements options apply to all of the options unless overridden in a dataset
                // In this case, we are setting the border of each horizontal bar to be 2px wide
                elements: {
                    rectangle: {
                        borderWidth: 2,
                    }
                },
                responsive: true,
                legend: {
                        display: false
                    }
            }
        });

我尝试为画布设置更大的高度,但是它不起作用。任何想法表示赞赏。

0 个答案:

没有答案