本文介绍了图表JS:如何对齐图例和标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将订单向左对齐,将图例对齐中心。
我尝试过
I want to align the orders to the left and the legends to center center.I've tried doing
title:{
display:true,
fontSize:18,
text: "Products",
titleAlign:'left'
}
,但 textalign
似乎对我不起作用,也没有 horizontal
but textalign
doesn't seem to work for me nor the horizontal
推荐答案
检查Chart.js文档,没有诸如titleAlign之类的选项,请参见:。
应该是在将来,对此有一个拉取请求:
。
Check the Chart.js docs, there is no options like titleAlign, see: https://www.chartjs.org/docs/latest/configuration/title.html.It should be in the future, there is an pull request for that:https://github.com/chartjs/Chart.js/pull/5866 .
您可以选择执行此操作不显示图表标题并添加您自己的图表。
这是我如何执行此操作的示例
There is an option to do that, you should not display chart title and add your own.Here is example how I've done that
<div class="panel panel-default">
<div class="panel-heading">
<h5>{{ title }}</h5>
</div>
<div class="panel-body">
<canvas id="my-chart" width="150" height="150"></canvas>
</div>
</div>
这篇关于图表JS:如何对齐图例和标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!