'use strict';angular.module('angular-rickshaw',[]).directive('rickshaw',function($compile){return{restrict:'EA',scope:{options:'=rickshawOptions',series:'=rickshawSeries',features:'=rickshawFeatures'},link:function(scope,element,attrs){function getSettings(el){var settings=angular.copy(scope.options);settings.element=el;settings.series=scope.series;return settings}var graph;function update(){var mainEl=angular.element(element);mainEl.append(graphEl);mainEl.empty();var graphEl=$compile('
')(scope);mainEl.append(graphEl);var settings=getSettings(graphEl[0]);graph=new Rickshaw.Graph(settings);if(scope.features&&scope.features.hover){var hoverConfig={graph:graph};hoverConfig.xFormatter=scope.features.hover.xFormatter;hoverConfig.yFormatter=scope.features.hover.yFormatter;hoverConfig.formatter=scope.features.hover.formatter;var hoverDetail=new Rickshaw.Graph.HoverDetail(hoverConfig)}if(scope.features&&scope.features.palette){var palette=new Rickshaw.Color.Palette({scheme:scope.features.palette});for(var i=0;i')(scope);mainEl.append(legendEl);var legend=new Rickshaw.Graph.Legend({graph:graph,element:legendEl[0]});if(scope.features.legend.toggle){var shelving=new Rickshaw.Graph.Behavior.Series.Toggle({graph:graph,legend:legend})}if(scope.features.legend.highlight){var highlighter=new Rickshaw.Graph.Behavior.Series.Highlight({graph:graph,legend:legend})}}}scope.$watch('options',function(newValue,oldValue){if(!angular.equals(newValue,oldValue)){update()}});scope.$watch('series',function(newValue,oldValue){if(!angular.equals(newValue,oldValue)){update()}});scope.$watch('features',function(newValue,oldValue){if(!angular.equals(newValue,oldValue)){update()}});update()},controller:function($scope,$element,$attrs){}}});