<graph data="graphData" height="400" width="100%">
<x field="Month" order-by="Date"></x>
<y field="Unit Sales"></y>
<legend></legend>
diff --git a/site/documentation/partials/line-graph.html b/site/documentation/partials/line-graph.html
index c394c56..c8f190d 100644
--- a/site/documentation/partials/line-graph.html
+++ b/site/documentation/partials/line-graph.html
@@ -6,7 +6,7 @@
-
+
@@ -15,7 +15,7 @@
-<graph data="graphData">
+<graph data="graphData" width="100%" height="600px">
<x field="Month" order-by="Date"></x>
<y field="Unit Sales"></y>
<legend></legend>
@@ -41,3 +41,20 @@
<line field="Owner" value="Black Mesa"></line>
<line field="Owner" value="Tyrell Corp"></line>
</graph>
+Inside ng-repeat
+
+
+
+
+
+
+
+
+
+
+<graph data="graphData" width="100%" height="600px">
+ <x field="Month" order-by="Date"></x>
+ <y field="Unit Sales"></y>
+ <legend></legend>
+ <line field="Owner"></line>
+</graph>
diff --git a/site/documentation/partials/ring.html b/site/documentation/partials/ring.html
new file mode 100644
index 0000000..2134323
--- /dev/null
+++ b/site/documentation/partials/ring.html
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+ <graph data="graphData" width="100%" height="600px">
+ <r field="Unit Sales"></r>
+ <legend></legend>
+ <ring field="Owner" thickness="20"></ring>
+ </graph>
+
+
+
+
+
+
+
+
+
+
+
+
+ <graph data="graphData" width="100%" height="600px">
+ <r field="Unit Sales"></r>
+ <legend></legend>
+ <ring field="Owner" thickness="20"></ring>
+ <ring field="Price Tier" thickness="20" diameter="75"></ring>
+ </graph>
diff --git a/site/documentation/partials/scatter-plot.html b/site/documentation/partials/scatter-plot.html
index 751f0b0..1d8d70c 100644
--- a/site/documentation/partials/scatter-plot.html
+++ b/site/documentation/partials/scatter-plot.html
@@ -6,7 +6,7 @@
-
+
@@ -15,7 +15,7 @@
-<graph data="graphData" height="600px">
+<graph data="graphData" width="100%" height="600px">
<x field="Operating Profit" type="Measure"></x>
<y field="Unit Sales" type="Measure"></y>
<legend></legend>
diff --git a/site/documentation/partials/stacked-area.html b/site/documentation/partials/stacked-area.html
index 243ceb4..5037028 100644
--- a/site/documentation/partials/stacked-area.html
+++ b/site/documentation/partials/stacked-area.html
@@ -6,7 +6,7 @@
-
+
@@ -47,7 +47,7 @@
-
+
@@ -55,7 +55,7 @@
-<graph data="graphData" height="600">
+<graph data="graphData" width="100%" height="600px">
<x field="Month" order-by="Date"></x>
<y field="Unit Sales" type="Percent"></y>
<legend></legend>
diff --git a/site/documentation/partials/stacked-bar-graph.html b/site/documentation/partials/stacked-bar-graph.html
index a6cdc9d..ccb3aae 100644
--- a/site/documentation/partials/stacked-bar-graph.html
+++ b/site/documentation/partials/stacked-bar-graph.html
@@ -6,7 +6,7 @@
-
+
@@ -15,7 +15,7 @@
-<graph data="graphData">
+<graph data="graphData" width="100%" height="600px">
<x field="Month" order-by="Date"></x>
<y field="Unit Sales"></y>
<legend></legend>
diff --git a/site/documentation/partials/testerguy.html b/site/documentation/partials/testerguy.html
deleted file mode 100644
index 7c45e87..0000000
--- a/site/documentation/partials/testerguy.html
+++ /dev/null
@@ -1,9 +0,0 @@
-
-<div class="white-panel">
- <graph data="graphData">
- <x field="Month" order-by="Date"></x>
- <y field="Unit Sales"></y>
- <legend></legend>
- <area field="Owner"></area>
- </graph>
-</div>
diff --git a/site/examples/index.html b/site/examples/index.html
index 1e1736e..39b6ab4 100644
--- a/site/examples/index.html
+++ b/site/examples/index.html
@@ -17,7 +17,7 @@
-
+
@@ -86,6 +86,12 @@
Scatter Plot
+
+
+
+ Ring
+
+
diff --git a/site/img/ring.svg b/site/img/ring.svg
new file mode 100644
index 0000000..39c6ca7
--- /dev/null
+++ b/site/img/ring.svg
@@ -0,0 +1,16 @@
+
+
+
+
diff --git a/site/index.html b/site/index.html
index 9d7f45f..d43b30d 100644
--- a/site/index.html
+++ b/site/index.html
@@ -17,7 +17,7 @@
-
+
@@ -70,11 +70,14 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -113,7 +116,7 @@
The Power of Angular Directives
</graph>
-
+
@@ -202,6 +205,20 @@
+
+
+
diff --git a/site/js/app.js b/site/js/app.js
index fb4fa93..7fbc695 100644
--- a/site/js/app.js
+++ b/site/js/app.js
@@ -10,6 +10,12 @@ angular.module('myApp', [
.config(['$routeProvider', '$logProvider', function($routeProvider, $logProvider) {
$routeProvider
+ .when('/animation-test', {
+ templateUrl: '../documentation/partials/animation-test.html',
+ controller: 'testController'
+ })
+
+
.when('/line-graph', {
templateUrl: '../documentation/partials/line-graph.html',
controller: 'lineGraphController'
@@ -38,6 +44,10 @@ angular.module('myApp', [
templateUrl: '../documentation/partials/scatter-plot.html',
controller: 'scatterController'
})
+ .when('/ring', {
+ templateUrl: '../documentation/partials/ring.html',
+ controller: 'ringController'
+ })
.otherwise({
redirectTo: '/line-graph'
@@ -46,3 +56,4 @@ angular.module('myApp', [
$logProvider.debugEnabled(true);
}]);
+
diff --git a/site/js/controllers.js b/site/js/controllers.js
index 42f885d..e81dd52 100644
--- a/site/js/controllers.js
+++ b/site/js/controllers.js
@@ -1,8 +1,39 @@
angular.module('myApp.controllers', [])
+
+
+.controller('testController', ['$scope', 'dataService', function($scope, dataService) {
+ $scope.line = true;
+ $scope.generate_data = function () {
+ var retary = [];
+ for (var i = 0; i < 5; i++) {
+ var date = new Date(Date.now() + i * 86400000);
+ var obj = {
+ 'Date': date,
+ 'Month': date.getMonth() + '-' + date.getDate(),
+ 'Owner': 'Aperture',
+ 'Unit Sales': (Math.random() * 1000) + 1000
+ };
+ retary[retary.length] = obj;
+ }
+ return {'data': retary};
+ };
+
+ $scope.update_data = function () {
+ var newData = $scope.generate_data().data;
+ $scope.graphData = newData;
+ };
+
+ $scope.update_data();
+
+}])
+
+
+
.controller('lineGraphController', ['$scope', 'dataService', function($scope, dataService) {
dataService.getData().then(function(response) {
$scope.graphData = response.data;
+ $scope.arrayOfData = [{data: response.data}, {data: response.data}];
});
}])
@@ -37,6 +68,12 @@ angular.module('myApp.controllers', [])
});
}])
+.controller('ringController', ['$scope', 'dataService', function($scope, dataService) {
+ dataService.getData().then(function(response) {
+ $scope.graphData = response.data;
+ });
+}])
+
.controller('scatterController', ['$scope', 'dataService', function($scope, dataService) {
dataService.getData().then(function(response) {
$scope.graphData = response.data;
diff --git a/site/js/lib/angular-dimple.js b/site/js/lib/angular-dimple.js
index 6d242af..f4e6200 100644
--- a/site/js/lib/angular-dimple.js
+++ b/site/js/lib/angular-dimple.js
@@ -1,43 +1,19 @@
-/*! Angular-Dimple - 1.0.2 - 2014-05-30
+/*! Angular-Dimple - 1.0.2 - 2014-09-17
* https://github.com/esripdx/angular-dimple
* Licensed ISC */
-angular.module('angular-dimple.core', [])
-
-.service('angular-dimple.core', [function(){
- return {
- filter: function (chart, scopeData, field, value, filter) {
- if (scopeData !== null) {
- var data = this.filterData(scopeData, filter);
- chart.data = data;
- if (value !== undefined) {
- chart.data = dimple.filterData(data, field, [value]);
- }
- }
- },
- filterData: function (data, filter) {
- if (filter) {
- var filters = filter.split(':');
- return dimple.filterData(data, filters[0], [filters[1]]);
- } else {
- return data;
- }
- }
- };
-}]);
-
-
angular.module('angular-dimple', [
- 'angular-dimple.core',
'angular-dimple.graph',
'angular-dimple.legend',
'angular-dimple.x',
'angular-dimple.y',
+ 'angular-dimple.r',
'angular-dimple.line',
'angular-dimple.bar',
'angular-dimple.stacked-bar',
'angular-dimple.area',
'angular-dimple.stacked-area',
- 'angular-dimple.scatter-plot'
+ 'angular-dimple.scatter-plot',
+ 'angular-dimple.ring'
])
.constant('MODULE_VERSION', '0.0.1')
@@ -47,7 +23,7 @@ angular.module('angular-dimple', [
});
angular.module('angular-dimple.area', [])
-.directive('area', ['angular-dimple.core', function (core) {
+.directive('area', [function () {
return {
restrict: 'E',
replace: true,
@@ -68,15 +44,15 @@ angular.module('angular-dimple.area', [])
var values = dimple.getUniqueValues($scope.data, $attrs.field);
angular.forEach(values, function(value){
area = chart.addSeries([$attrs.field], dimple.plot.area);
- core.filter(area, $scope.data, $attrs.field, value, $attrs.filter);
+ graphController.filter($attrs);
area.lineMarkers = true;
});
}
graphController.draw();
}
- $scope.$watch('data', function(newValue, oldValue) {
- if (newValue) {
+ $scope.$watch('dataReady', function(newValue, oldValue) {
+ if (newValue === true) {
addArea();
}
});
@@ -87,7 +63,7 @@ angular.module('angular-dimple.area', [])
angular.module('angular-dimple.bar', [])
-.directive('bar', ['angular-dimple.core', function (core) {
+.directive('bar', [function () {
return {
restrict: 'E',
replace: true,
@@ -102,14 +78,14 @@ angular.module('angular-dimple.bar', [])
function addBar () {
var filteredData;
bar = chart.addSeries([$attrs.field], dimple.plot.bar);
- core.filter(bar, $scope.data, $attrs.field, $attrs.value, $attrs.filter);
+ graphController.filter($attrs);
graphController.draw();
}
- $scope.$watch('data', function(newValue, oldValue) {
- if (newValue) {
+ $scope.$watch('dataReady', function(newValue, oldValue) {
+ if (newValue === true) {
addBar();
}
});
@@ -123,37 +99,52 @@ angular.module('angular-dimple.graph', [])
restrict: 'E',
replace: true,
scope: {
- data: '='
+ data: '=',
},
require: ['graph'],
transclude: true,
- compile: function($element, $attrs) {
- var id = (Math.random() * 1e9).toString(36).replace(".", "_");
- $element.append('');
- return {
- post: function postLink(scope, element, attrs, controllers, transclude) {
- var graphController = controllers[0];
- graphController._createChart(id);
- scope.$watch('data', function(newValue, oldValue) {
- if (newValue) {
- graphController.setData();
- }
- });
- transclude(scope, function(clone){
- element.append(clone);
- });
+ link: function (scope, element, attrs, controllers, transclude) {
+ var graphController = controllers[0];
+ graphController._createChart();
+ scope.dataReady = false;
+ scope.filters = [];
+
+ var chart = graphController.getChart();
+ var transition;
+ if (attrs.transition) {
+ transition = attrs.transition;
+ } else {
+ transition = 750;
+ }
+
+ scope.$watch('data', function(newValue, oldValue) {
+ if (newValue) {
+ scope.dataReady = true;
+ graphController.setData();
+ chart.draw(transition);
}
- };
+ });
+
+ transclude(scope, function(clone){
+ element.append(clone);
+ });
},
controller: ['$scope', '$element', '$attrs', function($scope, $element, $attrs) {
var chart;
- var id;
- this._createChart = function (domId) {
- id = domId;
- var svg = dimple.newSvg('#dng-'+ id +'', $attrs.width, $attrs.height);
- chart = new dimple.chart(svg);
+ this._createChart = function () {
+ // create an svg element
+ var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
+ svg.setAttribute('width', $attrs.width);
+ svg.setAttribute('height', $attrs.height);
+
+ // end the svg to this
+ $element.append(svg);
+ // create the dimple chart using the d3 selection of our