Chartjs-How to store a chart.js chart options in another file in AngularJS

1👍

Looking at the documentation for angular-chart.js, it looks like you can configure base options in an angular.config() function. Just import ChartJsProvider and follow the code below.

(function (ChartJsProvider) {
    ChartJsProvider.setOptions({ colors : [ '#803690', '#00ADF9', '#DCDCDC', '#46BFBD', '#FDB45C', '#949FB1', '#4D5360'] });
}); 

If this isn’t what you’re looking for, and you just want to extract a config object out of your controller and have it imported, look into angular.value().

https://docs.angularjs.org/guide/providers#value-recipe

Leave a comment