Unable to parse color in line chart (angular-chart.js)

myf picture myf · Jul 7, 2016 · Viewed 7.3k times · Source

I have 2 types of charts bar and line. This is my view (in slim):

    canvas#line.chart.chart-line(
      ng-if="stateStats == 'global'"
      chart-data="data"
      chart-labels="labels"
      chart-colours="colours"
    )
    canvas#bar.chart.chart-bar(
      ng-if="stateStats != 'global' && data.length != 0"
      chart-data="data"
      chart-labels="labels"
      chart-options="optionsBarChart"
    )

My colours option:

$scope.colours = [{
    fillColor: "rgba(151,187,205,0.2)",
    strokeColor: "rgba(151,187,205,1)",
    pointColor: "rgba(151,187,205,1)",
    pointStrokeColor: "#fff",
    pointHighlightFill: "#fff",
    pointHighlightStroke: "rgba(151,187,205,0.8)"
  }];

My problem is that I can't change a color of displaying data on line-chart. And when I want to move cursor on the point - I have error:

Uncaught Error: Unable to parse color from object ["rgba(151,187,205,1)","rgba(220,220,220,1)"...] What I did wrong?

Answer

Ashraful Islam picture Ashraful Islam · Aug 23, 2016

Please make sure that your data is on double array.

Ex:

data = [
  [10, 20, 30, 20, 10]
];