请参阅随附的带有焦点图表的nvd3线的屏幕截图。我在滑块中选择的日期范围与主图表中显示的日期范围不匹配。在nvd3线上有焦点图表是否有任何错误,或者我是否有任何错误?
以下是我将数据返回给控制器的服务:
angular.module('myApp').service(
'DashboardsDataService',
function() {
this.getNetSpendOverTimeData = function(selectedAccount,
carriesList, fDate, tDate) {
var selectedCarriers = null;
if (carriesList == null) {
alert("Please select Carriers from the Filters.");
return false;
}
var selectedAccountId = selectedAccount.value;
var selectedAccTd = null;
var prefixForSelectedAccount = selectedAccountId.substr(0, 2);
if (prefixForSelectedAccount = "CU") {
selectedCustomerId = selectedAccountId.replace("CU", "");
selectedCustomerId = selectedCustomerId.trim();
selectedAccTd = selectedCustomerId;
} else {
if (prefixForSelectedAccount = "SG") {
selectedShipperGroup = selectedAccountId.replace("SG",
"");
selectedShipperGroup = selectedShipperGroup.trim();
selectedAccTd = selectedShipperGroup;
}
}
for (var i = 0; i < carriesList.length; i++) {
if (selectedCarriers !== null
|| typeof selectedCarriers !== "undefined"
|| selectedCarriers !== '') {
selectedCarriers = selectedCarriers + ","
+ carriesList[i].catgId;
} else {
selectedCarriers = carriesList[i].catgId;
}
}
var formattedFromDate = this.convertDateObjToStringFormat(fDate);
var formattedToDate = this.convertDateObjToStringFormat(tDate);
var originalRequest = $.ajax({
async : false,
url : "/dash/dashboard2ajax.do",
type : "POST",
data : {
action : 'getNetSpendOverTime',
customerId : selectedAccTd,
carriersId : selectedCarriers,
fromDate : formattedFromDate,
toDate : formattedToDate
},
dataType : "json",
success : function(originalRequest) {
var res = originalRequest;
data = res.ResultSet.Response;
// alert("data" + data);
}
});
/* data = [
{
"values": [
{
"series": 0,
"y": 1181,
"x": 1391299200000
},
{
"series": 0,
"y": 1183,
"x": 1391385600000
},
{
"series": 0,
"y": 977,
"x": 1391472000000
},
{
"series": 0,
"y": 1136,
"x": 1391558400000
},
{
"series": 0,
"y": 994,
"x": 1391644800000
},
{
"series": 0,
"y": 944,
"x": 1391731200000
},
{
"series": 0,
"y": 568,
"x": 1391817600000
},
{
"series": 0,
"y": 1025,
"x": 1391904000000
},
{
"series": 0,
"y": 1314,
"x": 1391990400000
},
{
"series": 0,
"y": 882,
"x": 1392076800000
},
{
"series": 0,
"y": 1160,
"x": 1392163200000
},
{
"series": 0,
"y": 1143,
"x": 1392249600000
},
{
"series": 0,
"y": 1048,
"x": 1392336000000
},
{
"series": 0,
"y": 752,
"x": 1392422400000
},
{
"series": 0,
"y": 753,
"x": 1392508800000
},
{
"series": 0,
"y": 972,
"x": 1392595200000
},
{
"series": 0,
"y": 1027,
"x": 1392681600000
},
{
"series": 0,
"y": 1176,
"x": 1392768000000
},
{
"series": 0,
"y": 1689,
"x": 1392854400000
},
{
"series": 0,
"y": 1188,
"x": 1392940800000
},
{
"series": 0,
"y": 897,
"x": 1393027200000
},
{
"series": 0,
"y": 2579,
"x": 1393200000000
},
{
"series": 0,
"y": 1212,
"x": 1393286400000
},
{
"series": 0,
"y": 1324,
"x": 1393372800000
},
{
"series": 0,
"y": 1476,
"x": 1393459200000
},
{
"series": 0,
"y": 1036,
"x": 1393545600000
},
{
"series": 0,
"y": 923,
"x": 1393632000000
},
{
"series": 0,
"y": 1587,
"x": 1393718400000
},
{
"series": 0,
"y": 285,
"x": 1393804800000
},
{
"series": 0,
"y": 1809,
"x": 1393891200000
},
{
"series": 0,
"y": 1742,
"x": 1393977600000
},
{
"series": 0,
"y": 2233,
"x": 1394064000000
},
{
"series": 0,
"y": 761,
"x": 1394150400000
},
{
"series": 0,
"y": 2727,
"x": 1394323200000
},
{
"series": 0,
"y": 1214,
"x": 1394409600000
},
{
"series": 0,
"y": 1664,
"x": 1394496000000
},
{
"series": 0,
"y": 1790,
"x": 1394582400000
},
{
"series": 0,
"y": 1496,
"x": 1394668800000
},
{
"series": 0,
"y": 1291,
"x": 1394755200000
},
{
"series": 0,
"y": 1428,
"x": 1394841600000
},
{
"series": 0,
"y": 744,
"x": 1394928000000
},
{
"series": 0,
"y": 1391,
"x": 1395014400000
},
{
"series": 0,
"y": 1438,
"x": 1395100800000
},
{
"series": 0,
"y": 1801,
"x": 1395187200000
},
{
"series": 0,
"y": 1840,
"x": 1395273600000
},
{
"series": 0,
"y": 931,
"x": 1395360000000
},
{
"series": 0,
"y": 987,
"x": 1395446400000
},
{
"series": 0,
"y": 1012,
"x": 1395532800000
},
{
"series": 0,
"y": 1404,
"x": 1395619200000
},
{
"series": 0,
"y": 1776,
"x": 1395705600000
},
{
"series": 0,
"y": 1593,
"x": 1395792000000
},
{
"series": 0,
"y": 1746,
"x": 1395878400000
},
{
"series": 0,
"y": 1377,
"x": 1395964800000
},
{
"series": 0,
"y": 991,
"x": 1396051200000
},
{
"series": 0,
"y": 1036,
"x": 1396137600000
},
{
"series": 0,
"y": 1239,
"x": 1396220400000
},
{
"series": 0,
"y": 1482,
"x": 1396306800000
},
{
"series": 0,
"y": 1533,
"x": 1396393200000
},
{
"series": 0,
"y": 1558,
"x": 1396479600000
},
{
"series": 0,
"y": 1267,
"x": 1396566000000
},
{
"series": 0,
"y": 1463,
"x": 1396652400000
},
{
"series": 0,
"y": 1339,
"x": 1396738800000
},
{
"series": 0,
"y": 1482,
"x": 1396825200000
},
{
"series": 0,
"y": 2011,
"x": 1396911600000
},
{
"series": 0,
"y": 1836,
"x": 1396998000000
},
{
"series": 0,
"y": 2090,
"x": 1397084400000
},
{
"series": 0,
"y": 1531,
"x": 1397170800000
},
{
"series": 0,
"y": 906,
"x": 1397257200000
},
{
"series": 0,
"y": 1207,
"x": 1397343600000
},
{
"series": 0,
"y": 1860,
"x": 1397430000000
},
{
"series": 0,
"y": 1276,
"x": 1397516400000
},
{
"series": 0,
"y": 1802,
"x": 1397602800000
},
{
"series": 0,
"y": 1808,
"x": 1397689200000
},
{
"series": 0,
"y": 1647,
"x": 1397775600000
},
{
"series": 0,
"y": 609,
"x": 1397862000000
},
{
"series": 0,
"y": 1820,
"x": 1397948400000
},
{
"series": 0,
"y": 1379,
"x": 1398034800000
},
{
"series": 0,
"y": 1801,
"x": 1398121200000
},
{
"series": 0,
"y": 1894,
"x": 1398207600000
},
{
"series": 0,
"y": 1533,
"x": 1398294000000
},
{
"series": 0,
"y": 925,
"x": 1398380400000
},
{
"series": 0,
"y": 860,
"x": 1398466800000
},
{
"series": 0,
"y": 977,
"x": 1398553200000
},
{
"series": 0,
"y": 1373,
"x": 1398639600000
},
{
"series": 0,
"y": 1557,
"x": 1398726000000
},
{
"series": 0,
"y": 1245,
"x": 1398812400000
},
{
"series": 0,
"y": 1538,
"x": 1398898800000
},
{
"series": 0,
"y": 1321,
"x": 1398985200000
},
{
"series": 0,
"y": 698,
"x": 1399071600000
},
{
"series": 0,
"y": 1035,
"x": 1399158000000
},
{
"series": 0,
"y": 1542,
"x": 1399244400000
},
{
"series": 0,
"y": 1613,
"x": 1399330800000
},
{
"series": 0,
"y": 1695,
"x": 1399417200000
},
{
"series": 0,
"y": 1742,
"x": 1399503600000
},
{
"series": 0,
"y": 1336,
"x": 1399590000000
},
{
"series": 0,
"y": 617,
"x": 1399676400000
},
{
"series": 0,
"y": 790,
"x": 1399762800000
},
{
"series": 0,
"y": 1589,
"x": 1399849200000
},
{
"series": 0,
"y": 1236,
"x": 1399935600000
}
],
"key": "USPS"
}
];
*/
return data;
}
});
以下是我的控制器中的代码:
$scope.netspendovertime_data = DashboardsDataService.getNetSpendOverTimeData(selectedAccount, selectedCarrierList, fromDate, toDate);
在我的jsp页面中,当我显示使用时,即使使用Ajax请求,也会显示完整的json数据:
<div>
<pre class="code">{{ netspendovertime_data | json }}</pre>
</div>