Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 656
myf Avatar asked Jul 07 '16 07:07

myf


1 Answers

Please make sure that your data is on double array.

Ex:

data = [
  [10, 20, 30, 20, 10]
];
like image 171
Mohammad Ashraful Islam Avatar answered Nov 05 '22 22:11

Mohammad Ashraful Islam