возвращаемое значение функции (в миллисекундах даты)
Код: Выделить всё
function toDate(value) {
var dateRegExp = /^\/Date\((.*?)\)\/$/;
var date = dateRegExp.exec(value);
return new Date(parseInt(date[1]));
}
Код: Выделить всё
var testSurveyCalculationsDataSource = new kendo.data.DataSource({
transport: {
read: {
url: function () {
return '@Url.Action("GetCalculations", "Dashboard")';
},
dataType: "json",
cache: false,
sort: { field: "year", dir: "asc" },
type: "POST"
},
parameterMap: dataSourceParameterMap
},
requestStart: function () {
calculationsLoading = true;
requestStart();
},
requestEnd: function () {
calculationsLoading = false;
onRequestEnd();
},
group: {
field: "Name"
},
schema: {
parse: function (response) {
$.each(response, function (i, v) {
v.TimeStamp = toDate(v.TimeStamp);
});
return response;
}
},
error: function(e) {
onError("#tempChart ");
}
});
var tempChart = $("#tempChart ").kendoChart({
title: {
text: "Temp",
visible: false
},
legend: {
position: "top"
},
dataBound: function (e) {
setColors("#tempChart");
onNoData(e, "#tempChart");
},
dataSource: testSurveyCalculationsDataSource ,
sort: { field: "TimeStamp", dir: "desc" },
autoBind: false,
series: [
{
type: "line",
categoryField: "TimeStamp",
field: "Temp",
name: "#= group.value #",
axis: "temp",
tooltip: {
visible: true,
template: "${ kendo.toString(value, 'n0')}" + "" + " ${ kendo.toString(category, 'MM/dd/yyyy')}"
}
}
],
categoryAxis: [{
baseUnit: "months",
baseUnitStep: 1,
type:"date",
labels: {
step: 3,
template: '#= kendo.toString(value, "MMM yy" ) #',
dateFormats: {
months: "MMM yy"
},
visible: true
}
}],
valueAxis: [
{
name: "temp",
autoScale: true,
min: 0,
plotBands: [
{
color: "#ff0",
opacity: 0.2
},
{
color: "#ff0000",
opacity: 0.2
}
]
}
],
tooltip: { visible: true }
}).data('tempChart ');
Но он возвращает 1 апреля 2024 г.
Подробнее здесь: https://stackoverflow.com/questions/785 ... -the-speci