将对象数组映射到另一个对象数组中

时间:2017-05-06 16:49:58

标签: javascript arrays object mapping lodash

我想从时间序列数据库中映射这些数据:

[{
    "time": "2017-05-06T14:51:52.000Z",
    "section": "section-1.1",
    "spot": "mid-mid",
    "moisture": 32.29042774940741,
    "temp": 9.831621647958139,
    "light": 41.63243295916276,
    "tempF": 49.696918966324645
}, {
    "time": "2017-05-06T14:51:53.000Z",
    "section": "section-1.1",
    "spot": "mid-right",
    "moisture": 61.58342622984698,
    "temp": 9.242330770565856,
    "light": 29.846615411317096,
    "tempF": 48.63619538701854
}, {
    "time": "2017-05-06T14:51:55.000Z",
    "section": "section-1.2",
    "spot": "mid-left",
    "moisture": 41.18061223214005,
    "temp": 8.950196176767273,
    "light": 24.003923535345457,
    "tempF": 48.110353118181095
}, {
    "time": "2017-05-06T14:51:57.000Z",
    "section": "section-1.1",
    "spot": "mid-right",
    "moisture": 63.70980718623251,
    "temp": 9.206026133587395,
    "light": 29.120522671747903,
    "tempF": 48.57084704045731
}, {
    "time": "2017-05-06T14:51:57.000Z",
    "section": "section-1.1",
    "spot": "mid-mid",
    "moisture": 30.85714405713664,
    "temp": 9.803760958788422,
    "light": 41.075219175768424,
    "tempF": 49.646769725819155
}]

进入这种格式(伪)

[{
        "section": "section-1.1",
        "points": [{
            "x": 1241,
            "mid-mid-temp": 1231,
            "mid-left-temp": 1241
        }, {
            "x": 1241,
            "mid-mid-temp": 1231,
            "mid-left-temp": 1241
        }]
    },
    {
        "section": "section-1.2",
        "points": [{
            "x": 1241,
            "mid-right-temp": 1231
        }, {
            "x": 1241,
            "mid-right-temp": 1231
        }]
    }
]

可以绘制不同的测量值,按部分和点划分。任何想法如何提出这个?

我只需要将每个测量值绘制成图形。我不需要全部3次测量。

0 个答案:

没有答案