【发布时间】:2016-10-11 19:27:01
【问题描述】:
我有 dataset1.grants,其中包含表单中的对象
正如您在下面看到的,主对象称为 grants,其中有一个称为 Value 的重要字段和一个 嵌套 的对象在 grants 中称为“组织”,其中包含重要的国家字段。
我想计算按国家/地区划分的所有值的总和。并且有 500 多个对象和 5 个以上的国家。我想创建一个数组对象,它的 {country:"england", Total_value: 23455623} 是这样的:
我如何继续比较我拥有的 CountryList 数组与名为 Organisation.Country 的嵌套对象,并将 ++ 值添加到一个国家/地区的总数中。
到目前为止的代码:
var countries = {};
dataset1.organisations.forEach(function(org)
{
countries[org.Country]=true //gets all the countries from dataset and sets it to true in countries object
})
var countryList = []; //has list of countries in array
for (var key in countries)
{
countryList.push(key);
}
对象
{
"grant": 0,
"ID": "EP/E027261/1",
"Title": "Semiconductor Research at the Materials-Device Interface",
"PIID": "6674",
"Scheme": "Platform Grants",
"StartDate": "01/05/2007",
"EndDate": "31/10/2012",
"Value": "800579",
"ResearchArea": "Non CMOS Device Technology",
"Theme": "Information and Communication Technologies",
"Department": "Electrical and Electronic Engineering",
"OrgID": "93",
"Investigators": [
{
"ID": "6674",
"Role": "Principal Investigator"
},
{
"ID": "29195",
"Role": "Co Investigator"
},
{
"ID": "90639",
"Role": "Co Investigator"
},
{
"ID": "101342",
"Role": "Co Investigator"
},
{
"ID": "12223",
"Role": "Co Investigator"
},
{
"ID": "45348",
"Role": "Co Investigator"
},
{
"ID": "96538",
"Role": "Co Investigator"
},
{
"ID": "10965",
"Role": "Co Investigator"
}
],
"Collaborators": [],
"Summary": "This proposal concerns research into electronic materials, and the development of experimental methods designed to improve our measurement capability on the nm scale. Semiconductor materials and devices are central to manufacturing, healthcare, security, administration and leisure. This pivotal position in our lives has developed gradually but is due in the main to dramatic changes that have occurred quite recently. Over the last decade semiconductor technology has begun to experience a revolution in terms of functionality based on decreased size and increased complexity, and this trend will define the future for the entire manufacturing sector. This presents immense challenges to both researchers and to manufacturers of semiconductors because the key issues are no longer the properties of bulk materials or even two-dimensional structures but the properties of small heterogeneous clusters of atoms (semiconductor, dielectric and metal) that constitute today's functional device. To put this into context, the next generation silicon NMOS transistor (45nm node) is only half the size of an influenza virus and for most applications will work in conjunction with tens of millions of similar devices. For research, development and control in manufacture the electronic and physical properties of small atomic clusters need to be probed and interactions with structures in close proximity understood.As materials and device sub-structures become more complex the experimental task of obtaining precise information becomes ever more challenging. In particular the atomic organisation and local chemistry can have a profound effect on electronic behaviour and there is a growing need to develop measurement methods which can both image structures and link shape with local spectroscopic information. In our work we are pushing forward such methods by combining x-ray spectroscopy with scanning probe imaging, using both national and international synchrotron radiation sources. In a complementary approach, we are extending electron energy loss techniques in scanning transmission electron microscopy to link chemical and structural information. Optical spectroscopy is an invaluable tool for characterising condensed matter and we are developing free electron laser pumped Raman spectroscopy in order to directly probe electron states in ultra small semiconductors.Almost all emerging device technologies are limited by these materials issues and much of our work is guided by measuring and understanding these. For example, ultra high speed, low noise detectors and amplifiers are desperately needed by radio-astronomers for the next generation of telescopes. Such devices demand near perfect material and interface properties and form part of our programme. Similarly future THz emitters are hugely challenging in terms of materials physics. One of the key developments in electronic materials in the last decade is the ability to synthesise quantum dots which give three dimensional control over quantum size effects and hold the promise of highly tuneable materials. Measuring the collective electrical properties has proved a major task and the information required to build many devices is missing. We are extending and adapting point defect measurement methods to close this gap. The increasing complexity of materials raises many issues for the device and circuit designer. An important feature of our proposed work is that we aim to include device design concepts at the materials level, and will use this work to guide our experimental programme.",
"organisation": {
"organisation": 93,
"OrgID": "93",
"Name": "The University of Manchester",
"City": "Manchester",
"Region": "Greater Manchester",
"Country": "England",
"Postcode": "M13 9PL",
"Latitude": "53.4668498",
"Longitude": "-2.2338837"
}
}
【问题讨论】:
-
将对象粘贴为文本,而不是图像。
console.log(JSON.stringify(obj, null, 4)) -
根据您的要求,我已添加该对象。请帮忙,我不太了解javascript。我来自java语言背景
标签: javascript arrays object d3.js