如何更改角chart.js之色 [英] How to change colours for Angular-Chart.js

查看:286
本文介绍了如何更改角chart.js之色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用角chart.js之(在AngularJS chart.js之版本)来创建一个条形图。图表正在与除颜色的选项。

I use Angular-Chart.js (the AngularJS Chart.js version) to create a bar chart. The Chart is working with the options except for the colours.

即使我把他们来说,这表示在文档,他们留灰色。

Even if I set them it is indicated in the documentation, they stay grey.

<div class="graph-display" ng-controller="chartController">
    <canvas class="chart chart-bar"
    data="bilans.data"
    labels="bilans.labels"
    series="bilans.series"
    options="{
        scaleShowHorizontalLines: true,
        scaleShowVerticalLines: false,
        tooltipTemplate: '<%= value %> $',
        responsive: true
    }"
    colours="{
    fillColor: 'rgba(47, 132, 71, 0.8)',
    strokeColor: 'rgba(47, 132, 71, 0.8)',
    highlightFill: 'rgba(47, 132, 71, 0.8)',
    highlightStroke: 'rgba(47, 132, 71, 0.8)'
    }"
    ></canvas>
</div>

其实,选项工作,但颜色不是。难道我做错了什么?

Actually, the options are working but the colours are not. Am I doing something wrong?

推荐答案

您应该声明颜色对象的数组

"colours": [{
    fillColor: 'rgba(47, 132, 71, 0.8)',
    strokeColor: 'rgba(47, 132, 71, 0.8)',
    highlightFill: 'rgba(47, 132, 71, 0.8)',
    highlightStroke: 'rgba(47, 132, 71, 0.8)'
}];

工作Plunkr

有关详细信息请参阅<一个href=\"http://stackoverflow.com/questions/28278178/load-json-to-display-data-using-ng-repeat/28278331#28278331\">this帖子 / <一个href=\"http://stackoverflow.com/questions/28278096/angular-js-loading-data-for-chart/28278459#28278459\">this了。

For more info refer this post / this too.

这篇关于如何更改角chart.js之色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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