Skip to content

Commit

Permalink
removed getValues from pie chart
Browse files Browse the repository at this point in the history
updated pie chart example
additional fixes to axis configuration
  • Loading branch information
cmaurer committed Sep 6, 2013
1 parent ad094c8 commit 671a40b
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 54 deletions.
52 changes: 27 additions & 25 deletions dist/angularjs-nvd3-directives.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/*! angularjs-nvd3-directives - v0.0.0 - 2013-09-05
/*! angularjs-nvd3-directives - v0.0.0 - 2013-09-06
* Copyright (c) 2013 Christian Maurer; Licensed Apache */
function configureXaxis(chart, scope, attrs){
"use strict";
if(attrs.xaxisorient){
chart.xAxis.orient(scope.xaxisorient());
chart.xAxis.orient(attrs.xaxisorient);
}
if(attrs.xaxisticks){
chart.xAxis.ticks(scope.xaxisticks());
}
if(attrs.xaxistickvalues){
chart.xAxis.tickValues(scope.xaxistickvalues());
chart.xAxis.tickValues(scope.$eval(attrs.xaxistickvalues));
}
if(attrs.xaxisticksubdivide){
chart.xAxis.tickSubdivide(scope.xaxisticksubdivide());
Expand All @@ -24,7 +24,7 @@ function configureXaxis(chart, scope, attrs){
chart.xAxis.tickFormat(scope.xaxistickformat());
}
if(attrs.xaxislabel){
chart.xAxis.axisLabel(scope.xaxislabel());
chart.xAxis.axisLabel(attrs.xaxislabel);
}
if(attrs.xaxisscale){
chart.xAxis.xScale(scope.xaxisscale());
Expand All @@ -42,29 +42,32 @@ function configureXaxis(chart, scope, attrs){
chart.xAxis.rangeBands(scope.xaxisrangebands());
}
if(attrs.xaxisshowmaxmin){
chart.xAxis.showMaxMin((scope.xaxisshowmaxmin === "true"));
chart.xAxis.showMaxMin((attrs.xaxisshowmaxmin === "true"));
}
if(attrs.xaxishighlightzero){
chart.xAxis.highlightZero((scope.xaxishighlightzero === "true"));
chart.xAxis.highlightZero((attrs.xaxishighlightzero === "true"));
}
if(attrs.xaxisrotatelables){
chart.xAxis.highlightZero(scope.xaxisrotatelables);
}
if(attrs.xaxisrotateylabel){
chart.xAxis.rotateYLabel((scope.xaxisrotateylabel === "true"));
chart.xAxis.rotateYLabel((attrs.xaxisrotateylabel === "true"));
}
if(attrs.xaxisstaggerlabels){
chart.xAxis.staggerlabels((scope.xaxisstaggerlabels === "true"));
chart.xAxis.staggerlabels((attrs.xaxisstaggerlabels === "true"));
}
}

function configureYaxis(chart, scope, attrs){
"use strict";
if(attrs.yaxisorient){
chart.yAxis.orient(attrs.yaxisorient);
}
if(attrs.yaxisticks){
chart.yAxis.ticks(scope.yaxisticks());
}
if(attrs.yaxistickvalues){
chart.yAxis.tickValues(scope.yaxistickvalues());
chart.yAxis.tickValues(scope.$eval(attrs.yaxistickvalues));
}
if(attrs.yaxisticksubdivide){
chart.yAxis.tickSubdivide(scope.yaxisticksubdivide());
Expand All @@ -79,7 +82,7 @@ function configureYaxis(chart, scope, attrs){
chart.yAxis.tickFormat(scope.yaxistickformat());
}
if(attrs.yaxislabel){
chart.yAxis.axisLabel(scope.yaxislabel());
chart.yAxis.axisLabel(attrs.yaxislabel);
}
if(attrs.yaxisscale){
chart.yAxis.yScale(scope.yaxisscale());
Expand All @@ -97,19 +100,19 @@ function configureYaxis(chart, scope, attrs){
chart.yAxis.rangeBands(scope.yaxisrangebands());
}
if(attrs.yaxisshowmaxmin){
chart.yAxis.showMaxMin((scope.yaxisshowmaxmin === "true"));
chart.yAxis.showMaxMin((attrs.yaxisshowmaxmin === "true"));
}
if(attrs.yaxishighlightzero){
chart.yAxis.highlightZero((scope.yaxishighlightzero === "true"));
chart.yAxis.highlightZero((attrs.yaxishighlightzero === "true"));
}
if(attrs.yaxisrotatelables){
chart.yAxis.highlightZero(scope.yaxisrotatelables);
}
if(attrs.yaxisrotateylabel){
chart.yAxis.rotateYLabel((scope.yaxisrotateylabel === "true"));
chart.yAxis.rotateYLabel((attrs.yaxisrotateylabel === "true"));
}
if(attrs.yaxisstaggerlabels){
chart.yAxis.staggerlabels((scope.yaxisstaggerlabels === "true"));
chart.yAxis.staggerlabels((attrs.yaxisstaggerlabels === "true"));
}
}

Expand All @@ -135,7 +138,7 @@ function configureY1axis(chart, scope, attrs){
chart.y1Axis.tickFormat(scope.y1axistickformat());
}
if(attrs.y1axislabel){
chart.y1Axis.axisLabel(scope.y1axislabel());
chart.y1Axis.axisLabel(attrs.y1axislabel);
}
if(attrs.y1axisscale){
chart.y1Axis.yScale(scope.y1axisscale());
Expand All @@ -153,19 +156,19 @@ function configureY1axis(chart, scope, attrs){
chart.y1Axis.rangeBands(scope.y1axisrangebands());
}
if(attrs.y1axisshowmaxmin){
chart.y1Axis.showMaxMin((scope.y1axisshowmaxmin === "true"));
chart.y1Axis.showMaxMin((attrs.y1axisshowmaxmin === "true"));
}
if(attrs.y1axishighlightzero){
chart.y1Axis.highlightZero((scope.y1axishighlightzero === "true"));
chart.y1Axis.highlightZero((attrs.y1axishighlightzero === "true"));
}
if(attrs.y1axisrotatelables){
chart.y1Axis.highlightZero(scope.y1axisrotatelables);
}
if(attrs.y1axisrotateylabel){
chart.y1Axis.rotateYLabel((scope.y1axisrotateylabel === "true"));
chart.y1Axis.rotateYLabel((attrs.y1axisrotateylabel === "true"));
}
if(attrs.y1axisstaggerlabels){
chart.y1Axis.staggerlabels((scope.y1axisstaggerlabels === "true"));
chart.y1Axis.staggerlabels((attrs.y1axisstaggerlabels === "true"));
}
}

Expand All @@ -191,7 +194,7 @@ function configureY2axis(chart, scope, attrs){
chart.y2Axis.tickFormat(scope.y2axistickformat());
}
if(attrs.y2axislabel){
chart.y2Axis.axisLabel(scope.y2axislabel());
chart.y2Axis.axisLabel(attrs.y2axislabel);
}
if(attrs.y2axisscale){
chart.y2Axis.yScale(scope.y2axisscale());
Expand All @@ -209,19 +212,19 @@ function configureY2axis(chart, scope, attrs){
chart.y2Axis.rangeBands(scope.y2axisrangebands());
}
if(attrs.y2axisshowmaxmin){
chart.y2Axis.showMaxMin((scope.y2axisshowmaxmin === "true"));
chart.y2Axis.showMaxMin((attrs.y2axisshowmaxmin === "true"));
}
if(attrs.y2axishighlightzero){
chart.y2Axis.highlightZero((scope.y2axishighlightzero === "true"));
chart.y2Axis.highlightZero((attrs.y2axishighlightzero === "true"));
}
if(attrs.y2axisrotatelables){
chart.y2Axis.highlightZero(scope.y2axisrotatelables);
}
if(attrs.y2axisrotateylabel){
chart.y2Axis.rotateYLabel((scope.y2axisrotateylabel === "true"));
chart.y2Axis.rotateYLabel((attrs.y2axisrotateylabel === "true"));
}
if(attrs.y2axisstaggerlabels){
chart.y2Axis.staggerlabels((scope.y2axisstaggerlabels === "true"));
chart.y2Axis.staggerlabels((attrs.y2axisstaggerlabels === "true"));
}
}
angular.module('nvd3ChartDirectives', [])
Expand Down Expand Up @@ -1369,7 +1372,6 @@ angular.module('nvd3ChartDirectives', [])
var chart = nv.models.pieChart()
.x(attrs.x === undefined ? function(d){ return d[0]; } : scope.x())
.y(attrs.y === undefined ? function(d){ return d[1]; } : scope.y())
.values(attrs.values === undefined ? function(d) { return d; } : scope.values())
.width(width)
.height(height)
.noData(attrs.nodata === undefined ? 'No Data Available.' : scope.nodata)
Expand Down
4 changes: 3 additions & 1 deletion examples/liveData.example.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
tooltips="true"
interactive="true"
xAxisTickFormat="xAxisTickFormatFunction()"
margin="{left:50,top:50,bottom:50,right:50}"
margin="{left:100,top:20,bottom:20,right:10}"
yAxisLabel="Temperature (F)"
xAxisLabel="Date"
>
<svg></svg>
</nvd3-line-chart>
Expand Down
6 changes: 2 additions & 4 deletions examples/pieChart.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
var app = angular.module("nvd3TestApp", ['nvd3ChartDirectives']);

function ExampleCtrl($scope){
$scope.exampleData =[
[
$scope.exampleData = [
{
key: "One",
y: 5
Expand Down Expand Up @@ -42,7 +41,6 @@
key: "Seven",
y: 9
}
]
];

$scope.xFunction = function(){
Expand Down Expand Up @@ -70,7 +68,7 @@
height="400"
x="xFunction()"
y="yFunction()"
><svg></svg></nvd3-pie-chart>
><svg height="300"></svg></nvd3-pie-chart>
</div>

</body>
Expand Down
49 changes: 26 additions & 23 deletions src/directives/nvD3AxisConfiguration.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
function configureXaxis(chart, scope, attrs){
"use strict";
if(attrs.xaxisorient){
chart.xAxis.orient(scope.xaxisorient());
chart.xAxis.orient(attrs.xaxisorient);
}
if(attrs.xaxisticks){
chart.xAxis.ticks(scope.xaxisticks());
}
if(attrs.xaxistickvalues){
chart.xAxis.tickValues(scope.xaxistickvalues());
chart.xAxis.tickValues(scope.$eval(attrs.xaxistickvalues));
}
if(attrs.xaxisticksubdivide){
chart.xAxis.tickSubdivide(scope.xaxisticksubdivide());
Expand All @@ -22,7 +22,7 @@ function configureXaxis(chart, scope, attrs){
chart.xAxis.tickFormat(scope.xaxistickformat());
}
if(attrs.xaxislabel){
chart.xAxis.axisLabel(scope.xaxislabel());
chart.xAxis.axisLabel(attrs.xaxislabel);
}
if(attrs.xaxisscale){
chart.xAxis.xScale(scope.xaxisscale());
Expand All @@ -40,29 +40,32 @@ function configureXaxis(chart, scope, attrs){
chart.xAxis.rangeBands(scope.xaxisrangebands());
}
if(attrs.xaxisshowmaxmin){
chart.xAxis.showMaxMin((scope.xaxisshowmaxmin === "true"));
chart.xAxis.showMaxMin((attrs.xaxisshowmaxmin === "true"));
}
if(attrs.xaxishighlightzero){
chart.xAxis.highlightZero((scope.xaxishighlightzero === "true"));
chart.xAxis.highlightZero((attrs.xaxishighlightzero === "true"));
}
if(attrs.xaxisrotatelables){
chart.xAxis.highlightZero(scope.xaxisrotatelables);
}
if(attrs.xaxisrotateylabel){
chart.xAxis.rotateYLabel((scope.xaxisrotateylabel === "true"));
chart.xAxis.rotateYLabel((attrs.xaxisrotateylabel === "true"));
}
if(attrs.xaxisstaggerlabels){
chart.xAxis.staggerlabels((scope.xaxisstaggerlabels === "true"));
chart.xAxis.staggerlabels((attrs.xaxisstaggerlabels === "true"));
}
}

function configureYaxis(chart, scope, attrs){
"use strict";
if(attrs.yaxisorient){
chart.yAxis.orient(attrs.yaxisorient);
}
if(attrs.yaxisticks){
chart.yAxis.ticks(scope.yaxisticks());
}
if(attrs.yaxistickvalues){
chart.yAxis.tickValues(scope.yaxistickvalues());
chart.yAxis.tickValues(scope.$eval(attrs.yaxistickvalues));
}
if(attrs.yaxisticksubdivide){
chart.yAxis.tickSubdivide(scope.yaxisticksubdivide());
Expand All @@ -77,7 +80,7 @@ function configureYaxis(chart, scope, attrs){
chart.yAxis.tickFormat(scope.yaxistickformat());
}
if(attrs.yaxislabel){
chart.yAxis.axisLabel(scope.yaxislabel());
chart.yAxis.axisLabel(attrs.yaxislabel);
}
if(attrs.yaxisscale){
chart.yAxis.yScale(scope.yaxisscale());
Expand All @@ -95,19 +98,19 @@ function configureYaxis(chart, scope, attrs){
chart.yAxis.rangeBands(scope.yaxisrangebands());
}
if(attrs.yaxisshowmaxmin){
chart.yAxis.showMaxMin((scope.yaxisshowmaxmin === "true"));
chart.yAxis.showMaxMin((attrs.yaxisshowmaxmin === "true"));
}
if(attrs.yaxishighlightzero){
chart.yAxis.highlightZero((scope.yaxishighlightzero === "true"));
chart.yAxis.highlightZero((attrs.yaxishighlightzero === "true"));
}
if(attrs.yaxisrotatelables){
chart.yAxis.highlightZero(scope.yaxisrotatelables);
}
if(attrs.yaxisrotateylabel){
chart.yAxis.rotateYLabel((scope.yaxisrotateylabel === "true"));
chart.yAxis.rotateYLabel((attrs.yaxisrotateylabel === "true"));
}
if(attrs.yaxisstaggerlabels){
chart.yAxis.staggerlabels((scope.yaxisstaggerlabels === "true"));
chart.yAxis.staggerlabels((attrs.yaxisstaggerlabels === "true"));
}
}

Expand All @@ -133,7 +136,7 @@ function configureY1axis(chart, scope, attrs){
chart.y1Axis.tickFormat(scope.y1axistickformat());
}
if(attrs.y1axislabel){
chart.y1Axis.axisLabel(scope.y1axislabel());
chart.y1Axis.axisLabel(attrs.y1axislabel);
}
if(attrs.y1axisscale){
chart.y1Axis.yScale(scope.y1axisscale());
Expand All @@ -151,19 +154,19 @@ function configureY1axis(chart, scope, attrs){
chart.y1Axis.rangeBands(scope.y1axisrangebands());
}
if(attrs.y1axisshowmaxmin){
chart.y1Axis.showMaxMin((scope.y1axisshowmaxmin === "true"));
chart.y1Axis.showMaxMin((attrs.y1axisshowmaxmin === "true"));
}
if(attrs.y1axishighlightzero){
chart.y1Axis.highlightZero((scope.y1axishighlightzero === "true"));
chart.y1Axis.highlightZero((attrs.y1axishighlightzero === "true"));
}
if(attrs.y1axisrotatelables){
chart.y1Axis.highlightZero(scope.y1axisrotatelables);
}
if(attrs.y1axisrotateylabel){
chart.y1Axis.rotateYLabel((scope.y1axisrotateylabel === "true"));
chart.y1Axis.rotateYLabel((attrs.y1axisrotateylabel === "true"));
}
if(attrs.y1axisstaggerlabels){
chart.y1Axis.staggerlabels((scope.y1axisstaggerlabels === "true"));
chart.y1Axis.staggerlabels((attrs.y1axisstaggerlabels === "true"));
}
}

Expand All @@ -189,7 +192,7 @@ function configureY2axis(chart, scope, attrs){
chart.y2Axis.tickFormat(scope.y2axistickformat());
}
if(attrs.y2axislabel){
chart.y2Axis.axisLabel(scope.y2axislabel());
chart.y2Axis.axisLabel(attrs.y2axislabel);
}
if(attrs.y2axisscale){
chart.y2Axis.yScale(scope.y2axisscale());
Expand All @@ -207,18 +210,18 @@ function configureY2axis(chart, scope, attrs){
chart.y2Axis.rangeBands(scope.y2axisrangebands());
}
if(attrs.y2axisshowmaxmin){
chart.y2Axis.showMaxMin((scope.y2axisshowmaxmin === "true"));
chart.y2Axis.showMaxMin((attrs.y2axisshowmaxmin === "true"));
}
if(attrs.y2axishighlightzero){
chart.y2Axis.highlightZero((scope.y2axishighlightzero === "true"));
chart.y2Axis.highlightZero((attrs.y2axishighlightzero === "true"));
}
if(attrs.y2axisrotatelables){
chart.y2Axis.highlightZero(scope.y2axisrotatelables);
}
if(attrs.y2axisrotateylabel){
chart.y2Axis.rotateYLabel((scope.y2axisrotateylabel === "true"));
chart.y2Axis.rotateYLabel((attrs.y2axisrotateylabel === "true"));
}
if(attrs.y2axisstaggerlabels){
chart.y2Axis.staggerlabels((scope.y2axisstaggerlabels === "true"));
chart.y2Axis.staggerlabels((attrs.y2axisstaggerlabels === "true"));
}
}
1 change: 0 additions & 1 deletion src/directives/nvd3Directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,6 @@ angular.module('nvd3ChartDirectives', [])
var chart = nv.models.pieChart()
.x(attrs.x === undefined ? function(d){ return d[0]; } : scope.x())
.y(attrs.y === undefined ? function(d){ return d[1]; } : scope.y())
.values(attrs.values === undefined ? function(d) { return d; } : scope.values())
.width(width)
.height(height)
.noData(attrs.nodata === undefined ? 'No Data Available.' : scope.nodata)
Expand Down

0 comments on commit 671a40b

Please sign in to comment.