ng-morris-js
Version:
Super Easy AngularJS Chart directives for MorrisJS line, bar and donut charts!
17 lines • 2.23 kB
JavaScript
/**
* ng-morris-js v0.3.4
* Copyright © 2015-2016 Jeff Boothe
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
;!function(){angular.module("ng-morris-js",[]).directive("ngMorrisLineChart",function(){return{restrict:"EA",scope:{chartData:"=",chartOptions:"="},replace:!0,template:"<div></div>",link:function(t,a){t.$watch("chartData",function(){t.chartData&&t.chartOptions&&(t.chartOptions.element=a,t.chartOptions.data=t.chartData,t.chartInstance?t.chartInstance.setData(t.chartData):t.chartInstance=new Morris.Line(t.chartOptions))})}}}).directive("ngMorrisAreaChart",function(){return{restrict:"EA",scope:{chartData:"=",chartOptions:"="},replace:!0,template:"<div></div>",link:function(t,a){t.$watch("chartData",function(){t.chartData&&t.chartOptions&&(t.chartOptions.element=a,t.chartOptions.data=t.chartData,t.chartInstance?t.chartInstance.setData(t.chartData):t.chartInstance=new Morris.Area(t.chartOptions))})}}}).directive("ngMorrisBarChart",function(){return{restrict:"EA",scope:{chartData:"=",chartOptions:"="},replace:!0,template:"<div></div>",link:function(t,a){t.$watch("chartData",function(){t.chartData&&t.chartOptions&&(t.chartOptions.element=a,t.chartOptions.data=t.chartData,t.chartInstance?t.chartInstance.setData(t.chartData):t.chartInstance=new Morris.Bar(t.chartOptions))})}}}).directive("ngMorrisDonutChart",function(){return{restrict:"EA",scope:{chartData:"=",chartOptions:"="},replace:!0,template:"<div></div>",link:function(t,a){t.$watch("chartData",function(){t.chartData&&t.chartOptions&&(t.chartOptions.element=a,t.chartOptions.data=t.chartData,t.chartInstance?t.chartInstance.setData(t.chartData):t.chartInstance=new Morris.Donut(t.chartOptions))})}}})}();