でオフになっている、私の次元とグループがd3.time/crossfilter日は、私は一日あたりの統計を示すdc.js rowchartを作成しようとしてきた1
var dayNameFormat = d3.time.format("%A");
var weekDayFormat = d3.time.format('%w'); //weekday as a decimal number [0(Sunday),6].
var dayOfWeek = ndx.dimension(function(d) {
return weekDayFormat(d.date) + '.' + dayNameFormat(d.date);
});
var dayOfWeekGroup = dayOfWeek.group().reduce(
function(p, d) {
++p.count;
p.totalPoints += +d.points_per_date;
p.averagePoints = (p.totalPoints/p.count);
if (d.student_name in p.studentNames) {
p.studentNames[d.student_name] += 1
} else {
p.studentNames[d.student_name] = 1;
p.studentCount++;
}
return p;
},
function(p, d) {
--p.count;
p.totalPoints -= +d.points_per_date;
p.averagePoints = (p.totalPoints/p.count);
if (p.studentNames[d.student_name] === 0) {
delete p.studentNames[d.student_name];
p.studentCount--;
}
return p;
},
function() {
return {
count: 0,
totalPoints: 0,
averagePoints: 0,
studentNames: {},
studentCount: 0
};
});
あると
dayOfWeekChart
.width(250)
.height(180)
.margins({
top: 20,
left: 20,
right: 10,
bottom: 20
})
.dimension(dayOfWeek)
.group(dayOfWeekGroup)
.valueAccessor(function(d) {
return d.value.totalPoints
})
.renderLabel(true)
.label(function(d) {
return d.key.split('.')[1] + '(' + d.value.totalPoints + ' points)';
})
.renderTitle(true)
.title(function(d) {
return d.key.split('.')[1];
})
.elasticX(true);
をグラフ化
私は私のデータベースクエリのものと一致する結果を期待
へ私はこの権利、任意のヘルプの意志を取得しようとしている中で、私の頭をやってきた私のフィドルhttps://jsfiddle.net/santoshsewlal/txrLw9Lc/
(日曜日は月曜日の合計を持っている)TAL値は正しいですが、日が日によって相殺されています偉大になる。 ありがとう
ありがとう@Gordon。 d3.time.format.utc(「%Y-%m-%dT%H:%M:%S.%LZ」)を使用して、このトリックが実行されました。私はそれをここで見つけました。http://stackoverflow.com/questions/33755972/d3-datetime-parser-takes-into-account-timezone –
ああ、私は '.utc'変種について言及するのを忘れました、それは良い点です。 – Gordon