Javascript 角度和图表颜色

Javascript 角度和图表颜色,javascript,angularjs,chart.js,Javascript,Angularjs,Chart.js,我使用的是角度图表js。有人知道如何每隔一行切换图表颜色吗 这是我的标记: <canvas ng-if="hasStats" id="pie" class="chart chart-pie" chart-type="Pie" chart-colours=colors chart-data="data" chart-labels="labels" chart-legend="true"> </canvas> 标记位于表中。我想切换颜色方案以匹配我的行。奇数行是一种

我使用的是角度图表js。有人知道如何每隔一行切换图表颜色吗

这是我的标记:

<canvas ng-if="hasStats" id="pie" class="chart chart-pie"
chart-type="Pie" 
chart-colours=colors 
chart-data="data" 
chart-labels="labels" 
chart-legend="true">
</canvas>
标记位于表中。我想切换颜色方案以匹配我的行。奇数行是一种颜色方案,偶数行是另一种颜色方案

更新:
可能是这样的:

$scope.colorsOdd = [{ // facebook blue
              fillColor: 'rgba(59, 89, 152,0.2)',
              strokeColor: 'rgba(59, 89, 152,1)',
              pointColor: 'rgba(59, 89, 152,1)',
              pointStrokeColor: '#fff',
              pointHighlightFill: '#fff',
              pointHighlightStroke: 'rgba(59, 89, 152,0.8)'
            },
              { // twitter blue
                fillColor: 'rgba(0, 132, 180,0.2)',
                strokeColor: 'rgba(0, 132, 180,1)',
                pointColor: 'rgba(0, 132, 180,1)',
                pointStrokeColor: '#fff',
                pointHighlightFill: '#fff',
                pointHighlightStroke: 'rgba(0, 132, 180,0.8)'
              },
            { // mav
                fillColor: 'rgba(233, 30, 99,0.2)',
                strokeColor: 'rgba(233, 30, 99,1)',
                pointColor: 'rgba(233, 30, 99,1)',
                pointStrokeColor: '#fff',
                pointHighlightFill: '#fff',
                pointHighlightStroke: 'rgba(233, 30, 99,0.8)'
              }];

  $scope.colorsEven = [{ // facebook blue
              fillColor: 'rgba(59, 89, 152,0.2)',
              strokeColor: 'rgba(59, 89, 152,1)',
              pointColor: 'rgba(59, 89, 152,1)',
              pointStrokeColor: '#fff',
              pointHighlightFill: '#fff',
              pointHighlightStroke: 'rgba(59, 89, 152,0.8)'
            },
              { // twitter blue
                fillColor: 'rgba(0, 132, 180,0.2)',
                strokeColor: 'rgba(0, 132, 180,1)',
                pointColor: 'rgba(0, 132, 180,1)',
                pointStrokeColor: '#fff',
                pointHighlightFill: '#fff',
                pointHighlightStroke: 'rgba(0, 132, 180,0.8)'
              },
            { // teal
                fillColor: 'rgba(91, 192, 222,0.2)',
                strokeColor: 'rgba(91, 192, 222,1)',
                pointColor: 'rgba(91, 192, 222,1)',
                pointStrokeColor: '#fff',
                pointHighlightFill: '#fff',
                pointHighlightStroke: 'rgba(91, 192, 222,0.8)'
              }];
我就是想不出在它们之间切换的最佳方式

更新2:

<td rowspan="5" width="200">
                    <div class="ng-scope" ng-controller="AmbasPieCtrl" ng-init="init(data)" style="width: 250px;">
                        <canvas ng-if="hasStats" id="pie" class="chart chart-pie"
                        chart-type="Pie" 
                        chart-colours=colors
                        chart-data="data" 
                        chart-labels="labels" 
                        chart-legend="true">
                        </canvas> 
                        <div ng-if="!hasStats" class="text-center">
                            <h4>No stats found</h4>
                        </div>
                    </div>

                </td>

没有找到任何统计数据

在@ewizard的帮助下,我能够让它正常工作

以下是修改后的标记:

<div class="ng-scope" ng-controller="AmbasPieCtrl" ng-init="init(data)" style="width: 250px;">
                        <div ng-if="hasStats">
                            <div ng-hide="$odd">
                                <canvas id="pie" class="chart chart-pie"
                                chart-type="Pie" 
                                chart-colours=colorsEven
                                chart-data="data" 
                                chart-labels="labels" 
                                chart-legend="true">
                                </canvas>
                            </div>
                            <div ng-hide="$even">
                                <canvas ng-if="hasStats" id="pie" class="chart chart-pie"
                                chart-type="Pie" 
                                chart-colours=colorsOdd
                                chart-data="data" 
                                chart-labels="labels" 
                                chart-legend="true">
                                </canvas>
                            </div>
                        </div>
                        <div ng-if="!hasStats" class="text-center">
                            <h4>No stats found</h4>
                        </div>
                    </div>

没有找到任何统计数据

您是否尝试过更改
fillColor
?您的意思是什么?如上所示,我使用fillColor。我想要的是第二组三种颜色,奇数行设置为1,偶数行设置为2。好吧,我明白你的意思了。我更新了帖子,提出了一个想法。关于如何使用ng if?
<div class="ng-scope" ng-controller="AmbasPieCtrl" ng-init="init(data)" style="width: 250px;">
                        <div ng-if="hasStats">
                            <div ng-hide="$odd">
                                <canvas id="pie" class="chart chart-pie"
                                chart-type="Pie" 
                                chart-colours=colorsEven
                                chart-data="data" 
                                chart-labels="labels" 
                                chart-legend="true">
                                </canvas>
                            </div>
                            <div ng-hide="$even">
                                <canvas ng-if="hasStats" id="pie" class="chart chart-pie"
                                chart-type="Pie" 
                                chart-colours=colorsOdd
                                chart-data="data" 
                                chart-labels="labels" 
                                chart-legend="true">
                                </canvas>
                            </div>
                        </div>
                        <div ng-if="!hasStats" class="text-center">
                            <h4>No stats found</h4>
                        </div>
                    </div>