Hello I am getting a bad request when attempting to use angular.js with nvd3 for data visualisation.
My web2py controller passes a json to its view. This view code is shown below. It extends the layout.html which is the standard layout.html apart from I have added the javascript libraries angular.js, d3.min.js, nv.d3.js, angular-nvd.js and the css file nv.d3.min.css, all of which are required to use angular and nvd3 to generate data visualisations. I have tested the nvd3 and angular parts outside of web2py and the data visualisation works fine.
{{ extend 'layout.html' }}
<script type='text/javascript'>
var funnel_app = angular.module("funnel_app", ['nvd3']);
funnel_app.config(function($interpolateProvider) {
$interpolateProvider.startSymbol('<?');
$interpolateProvider.endSymbol('?>');
});
funnel_app.controller('mainCtrl', function($scope) {
$scope.data = {{=XML(response.json(report_data))}};
$scope.options = {
chart: {
type: 'multiChart',
height: 450,
margin : {
top: 30,
right: 60,
bottom: 50,
left: 70
},
color: d3.scale.category10().range(),
//useInteractiveGuideline: true,
transitionDuration: 500,
xAxis: {
tickFormat: function(d){
return d3.format(',f')(d);
}
},
yAxis1: {
tickFormat: function(d){
return d3.format(',.1f')(d);
}
},
yAxis2: {
tickFormat: function(d){
return d3.format(',.1f')(d);
}
}
}
}
});
</script>
<div data-ng-app="funnel_app">
<div data-ng-controller="mainCtrl">
<nvd3 options="options" data="data"></nvd3>
</div>
</div>
The json looks like it is passing from the controller to the view fine - I have looked at the source generated by web2py and nothing looks strange. But I am getting this favicon.ico bad request error. I am not getting this error from any other view within the same web2py app and they all extend layout.html where favicon.ico is listed. It seems to be pointing at favicon at root rather than .../static/images/favicon.ico and I can't see why. Having spent a long time trying to work out what the issue is I thought I would post a question here - has anyone else had similar issue?
Many thanks in advance!