Chart.js 和长标签 [英] Chart.js and long labels

查看:29
本文介绍了Chart.js 和长标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Chart.js 来显示雷达图.我的问题是有些标签很长:图表无法显示或看起来很小.

I use Chart.js to display a Radar Chart. My problem is that some labels are very long : the chart can't be display or it appears very small.

那么,有没有办法断行或为标签分配最大宽度?

So, is there a way to break lines or to assign a max-width to the labels?

感谢您的帮助!

推荐答案

对于 Chart.js 2.0+ 你可以使用数组作为标签:

For Chart.js 2.0+ you can use an array as label:

引用文档:

用法:如果标签是数组而不是字符串,即 [[June",2015"],July"],则每个元素都被视为单独的一行."

"Usage: If a label is an array as opposed to a string i.e. [["June","2015"], "July"] then each element is treated as a seperate line."

var data = {
   labels: [["My", "long", "long", "long", "label"], "another label",...],
   ...
}

这篇关于Chart.js 和长标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆