Created
August 18, 2014 09:13
-
-
Save sang4lv/4c5712b244f0cce83212 to your computer and use it in GitHub Desktop.
angularjs-nvd3-directives xAxisTickFormat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div ng-controller="TestCtrl"> | |
| <nvd3-line-chart | |
| x="chart.xVal()" | |
| y="chart.yVal()" | |
| xAxisTickFormat="chart.xAxis()" | |
| data="data" | |
| width="640" | |
| height="400" | |
| showXAxis="true" | |
| showYAxis="true" | |
| interactive="true" | |
| objectEquality="true"> | |
| <svg></svg> | |
| </nvd3-line-chart> | |
| </div> | |
| <script> | |
| function TestCtrl( $scope ) { | |
| $scope.data = [ | |
| { | |
| "key" : "Series 1", | |
| "values" : [ | |
| {"order_date" : "2014-07-24", "sub_order" : "1", "sub_amount" : "383", "series" : 0}, | |
| {"order_date" : "2014-08-04", "sub_order" : "2", "sub_amount" : "1975", "series" : 0}, | |
| {"order_date" : "2014-08-15", "sub_order" : "1", "sub_amount" : "0", "series" : 0} | |
| ] | |
| } | |
| ]; | |
| $scope.chart = { | |
| xVal : function() { | |
| return function( entry ) { | |
| return entry.order_date; | |
| }; | |
| }, | |
| yVal : function() { | |
| return function( entry ) { | |
| return entry[ $scope.local.yaxis_filters[$scope.local.current_yaxis].key ]; | |
| }; | |
| }, | |
| xAxis : function() { | |
| return function( index ) { //When I thought it passed the index back | |
| return d3.format( 'd' )( $scope.data[0].values[index].order_date ); | |
| } | |
| /*return function( entry ) { //when I thought it passed the original entry back | |
| return entry.order_date; | |
| }*/ | |
| } | |
| }; | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment