1

我正在尝试添加如下所示的数据:

{ "_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 轴。

有没有办法通过 react 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} />
4

0 回答 0