我想在我的图表上获得适当的可视化数据,但是因为有 1000 个数组元素,所以它搞砸了。我不想减少数据,但实际上是为了获得适当的可视化,因为在图形的 x 轴中它显示的是 NaN 值。
fetch("./data.json")
.then((res) => {
return res.json();
})
.then((data) => {
console.log(data);
for (const dataObj of data) {
empSal.push(parseInt(dataObj.intensity));
empAge.push(parseInt(dataObj.start_year));
}.catch((err) => {
console.log(err);
});
(1000) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, …]
样本数据(data.json):
[
{
"end_year": "",
"intensity": 6,
"sector": "Energy",
"topic": "gas",
"insight": "Annual Energy Outlook",
"url": "http://www.eia.gov/outlooks/aeo/pdf/0383(2017).pdf",
"region": "Northern America",
"start_year": "",
"impact": "",
"added": "January, 20 2017 03:51:25",
"published": "January, 09 2017 00:00:00",
"country": "United States of America",
"relevance": 2,
"pestle": "Industries",
"source": "EIA",
"title": "U.S. natural gas consumption is expected to increase during much of the projection period.",
"likelihood": 3
},
……