gpt4 book ai didi

javascript - 在 D3 中绑定(bind)大数组

转载 作者:行者123 更新时间:2023-11-30 15:56:23 25 4
gpt4 key购买 nike

我正在使用 D3 可视化绑定(bind)到 map 的数据,但我不知道应该处理多大的列表。

如果我使用行业数据,大约有 20 个左右的 NAICS,这很容易。

例如,我使用以下代码绑定(bind)来自 geojson 的数据:

 var values = feature.properties;              
var data = [
{key: "Agric.,forestry., fishing.,hunting.", name:"N11",value:values["N11"]},
{key: "Mining.,quar., oil,gas", name:"N21",value:values["N21"]},
{key: "Utilities", name:"N22",value:values["N22"]},
{key: "Constr.", name:"N23OL",value:values["N23"]},
{key: "Manuf.", name:"N31_33OL",value:values["N31-33"]},
{key: "Wholesale trade", name:"N41OL",value:values["N41"]},
{key: "Retail trade", name:"N44-45",value:values["N44-45"]},
{key: "Transportation, warehousing", name:"N48-49",value:values["N48-49"]},
{key: "Information, cultur.industries", name:"N51",value:values["N51"]},
{key: "Finance, insurance", name:"N52",value:values["N52"]},
{key: "Real estate, rental,leasing", name:"N53",value:values["N53"]},
{key: "Prof.scientific, techn.services", name:"N54",value:values["N54"]},
{key: "Management companies,enterprises", name:"N55",value:values["N55"]},
{key: "Admin.support, waste.manag., remed.services", name:"N56",value:values["N56"]},
{key: "Educational services", name:"N61",value:values["N61"]},
{key: "Health.care, social.assistance", name:"N62",value:values["N62"]},
{key: "Arts,entertainment, recreation", name:"N71",value:values["N71"]},
{key: "Accommodation, food.services", name:"N72",value:values["N72"]},
{key: "Other.services (except.pub. admin.)", name:"N81",value:values["N81"]},
{key: "Public administration", name:"N91",value:values["N91"]}
];

现在,如果我想使用职业数据,它会变得很棘手,因为它们大约有 800 个。显然,像这样手动输入它们是不切实际的。这将如何处理?使用 d3.csv 导入 CSV 并加入 geojson 数据对象?我不知道从哪里开始。

这是我对较小集合所做的一个例子:https://jsfiddle.net/Monduiz/tr5pxv1s/

最佳答案

听起来您很清楚自己在做什么,只是错过了最好的学习示例:

Example visualisation mapping reasonably large data-set loaded from tab-separated-values .

该示例中容易忽略的是它如何使用 d3.queue()defer()await() 来确保数据以正确的顺序加载和处理。

另见 documentation for other CSV-related functions .

关于javascript - 在 D3 中绑定(bind)大数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38463601/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com