2017-04-03 64 views
0

夥計們,如何更改線圖中的不透明度?看我的圖:Angular-Chart.js,折線圖中的不透明度如何?

enter image description here

紅色,灰色和藍色的背景。我需要讓它100%無形。

這裏是我的代碼:

<canvas id="line" class="chart chart-line" chart-data="data2"       chart-labels="labels2" chart-series="series2" chart-options="options2" 
chart-dataset-override="datasetOverride2" chart-click="onClick" chart-colours="colours"> 
</canvas> 

和片斷的JS:

$scope.rysujWykres2 = function (daneX, daneY, daneZ, daneA) { //metoda rysująca wykres 
     $scope.labels2 = daneX; 
     $scope.series2 = ['Ur', 'Ul', 'Uz']; 
     $scope.data2 = [ 
      daneY, 
      daneZ, 
      daneA 
     ]; 
     $scope.datasetOverride2 = [{ yAxisID: 'y-axis-1' }]; 
     $scope.options2 = { 
      scales: { 
       yAxes: [ 
        { 
        id: 'y-axis-1', 
        type: 'linear', 
        display: true, 
        position: 'left' 
       } 
        ] 
      }, 
      elements: { 
       point: { 
        radius: 1 
       } 
      }, 
      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)' 
     }] 
    }; 
} 

,但它不工作。你能幫我解決這個問題嗎?我只需要線路。

+0

在你的html應該是options2.colours而不是僅僅是顏色? – Mickers

+0

抱歉,你是對的,但我也想嘗試其他選項,如$ scope.colours = ...但無效 – Giacomo

+0

我看到你正在將所有的值存儲在一個函數中。爲什麼不從函數中刪除它們,並且在頁面加載時在控制器中設置$ scope? – Mickers

回答

1

如果您不想看到該行下的填充,請將fill屬性設置爲false(這是line chart dataset configuration的一部分)。我不確定如何在角度chart.js中做到這一點,但它看起來像你可以將它添加到你的datasetOverride2對象。

$scope.datasetOverride2 = [{fill: false}, {fill: false}, {fill: false}]; 

如果這不起作用,那麼無論您在何處定義每個數據集,都需要使用該屬性。

0

我的朋友,

​​

工作,但僅限於藍色日期,請看:

enter image description here

0

噢,它的那麼容易。看:

enter image description here

解決方案:

$scope.datasetOverride2 = [{fill: false},{fill: false},{fill: false}]; 

謝謝你們的幫助。我們做到了!