Chart js: how can I align the legend and the title

跟風遠走 提交于 2019-12-24 00:56:09

问题


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'
    }

but textalign doesn't seem to work for me nor the horizontal


回答1:


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>


来源:https://stackoverflow.com/questions/54396656/chart-js-how-can-i-align-the-legend-and-the-title

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