How to wrap legend text in Chartjs?

落花浮王杯 提交于 2019-12-21 17:50:20

问题


My ChartJs legend text is overflowing in the same line when the text is too long. Is there any parameter that I can use to enable text-wrap.

legend : {
    display : true,
    position : 'bottom',
    fullWidth: false,
    labels : {
        fontColor : "#000",
        //  boxWidth  : "3"
    }
}

In other chart libraries like highcharts, you just have to set width and the text will be wrapped if it exceeds the width. Is there such an option in ChartJS?

Highcharts Library Example:

legend: {
    itemStyle: {
        width: 90 // or whatever, auto-wrap
    },
}

I tried using legendCallback, but in that case I will loose the 'onclick' useful functionalities of the legend boxes that come out of the box in ChartJS. So I don't want to do that. Don't want use legend template either.

来源:https://stackoverflow.com/questions/40792349/how-to-wrap-legend-text-in-chartjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!