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

查看:162
本文介绍了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"],则每个元素都被视为单独的行."

Quoting the DOCs: "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天全站免登陆