我正在尝试添加如下所示的数据:
{ "_id" : "jK7o8qnWzgpZzzB3s", "createdAt" : ISODate("2017-01-23T03:31:02.619Z"), "productId" : "rgKEMvDD9BnJCzPHJ", "productOwnerId" : "mEWFCknMFydfxowhf" }
{ "_id" : "NgwntGwSYq6RqiXXq", "createdAt" : ISODate("2017-01-23T03:31:04.488Z"), "productId" : "rgKEMvDD9BnJCzPHJ", "productOwnerId" : "mEWFCknMFydfxowhf" }
{ "_id" : "MSTJGeFvgtkHr6rs8", "createdAt" : ISODate("2017-01-23T03:31:05.793Z"), "productId" : "rgKEMvDD9BnJCzPHJ", "productOwnerId" : "mEWFCknMFydfxowhf" }
{ "_id" : "h76hpE9ATuTSqvMpp", "createdAt" : ISODate("2017-01-23T03:31:06.668Z"), "productId" : "rgKEMvDD9BnJCzPHJ", "productOwnerId" : "mEWFCknMFydfxowhf" }
{ "_id" : "hXNt6SNGDn3zKHMhH", "createdAt" : ISODate("2017-01-23T05:11:51.688Z"), "productId" : "rgKEMvDD9BnJCzPHJ", "productOwnerId" : "mEWFCknMFydfxowhf" }
{ "_id" : "k4WMxQDSPhiAhY2eK", "createdAt" : ISODate("2017-01-23T05:11:52.737Z"), "productId" : "rgKEMvDD9BnJCzPHJ", "productOwnerId" : "mEWFCknMFydfxowhf" }
{ "_id" : "2NBziCevCxC739Wte", "createdAt" : ISODate("2017-01-23T05:11:53.048Z"), "productId" : "rgKEMvDD9BnJCzPHJ", "productOwnerId" : "mEWFCknMFydfxowhf" }
{ "_id" : "b8ZTYmvowtNWEGQaE", "createdAt" : ISODate("2017-01-23T05:11:53.257Z"), "productId" : "rgKEMvDD9BnJCzPHJ", "productOwnerId" : "mEWFCknMFydfxowhf" }
{ "_id" : "Z7RsZzvrkntmRnGrG", "createdAt" : ISODate("2017-01-23T05:11:53.472Z"), "productId" : "rgKEMvDD9BnJCzPHJ", "productOwnerId" : "mEWFCknMFydfxowhf" }
{ "_id" : "aWwoypfDscqfXxWtY", "createdAt" : ISODate("2017-01-23T05:11:53.676Z"), "productId" : "rgKEMvDD9BnJCzPHJ", "productOwnerId" : "mEWFCknMFydfxowhf" }
{ "_id" : "9pC9zmqJRL6Qybfor", "createdAt" : ISODate("2017-01-23T05:11:54.031Z"), "productId" : "rgKEMvDD9BnJCzPHJ", "productOwnerId" : "mEWFCknMFydfxowhf" }
我需要使用createdAt字段作为x轴(对于每天加起来)以及所有这些作为y轴的总和。
有没有办法用反应d3做这个或者我是否需要每天加起来?
现在我正在添加它,因为图表上没有数据显示。
这是我正在使用的图表系列和x函数:
var chartSeries = [
{
field: 'y',
name: 'Number of Downloads For Day',
color: '#ff7f0e'
}
]
tickFormatter = function(d) {
console.log("what is d");
console.log(d);
return new Date(d.x);
}
这就是我显示图表的方式:
<LineChart data={downloadChartDataPoints} chartSeries={chartSeries} x={tickFormatter} />