Skip to content

Instantly share code, notes, and snippets.

@fogonwater
Last active March 13, 2019 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fogonwater/ae29e52915efd5e352bae9260a9c02b9 to your computer and use it in GitHub Desktop.
Save fogonwater/ae29e52915efd5e352bae9260a9c02b9 to your computer and use it in GitHub Desktop.
DNZ stuff
license: mit
height: 3200
border: no
cat content_partner primary_collection count
sound and vision SOUNZ SOUNZ 15351
sound and vision NZ On Screen NZ On Screen 4940
sound and vision Ngā Taonga Sound & Vision Ngā Taonga Sound & Vision 2254
sound and vision AudioCulture AudioCulture 1136
sound and vision Play It Strange Play It Strange 754
sound and vision NZ Musician NZ Musician 726
sound and vision Audio Foundation Audio Foundation 144
sound and vision Audio Foundation Audio Foundation YouTube 123
science NatureWatch NZ NatureWatch NZ 482010
science Manaaki Whenua – Landcare Research NZFUNGI 8674
science New Zealand Plant Conservation Network New Zealand Plant Conservation Network 3892
science Science Learning Hub Science Learning Hub 3888
science New Zealand Plant Conservation Network New Zealand Regional Botanical Society Journals 2834
science Manaaki Whenua – Landcare Research Landcare Research Digital Library 2176
science Manaaki Whenua – Landcare Research Flora of New Zealand 1475
science LERNZdb LERNZ Freshwater Database 1193
science Manaaki Whenua – Landcare Research Moths of New Zealand 1192
science Manaaki Whenua – Landcare Research Weevils of New Zealand 541
science NIWA NIWA YouTube 482
science Manaaki Whenua – Landcare Research Landcare Research YouTube 257
science Forest and Bird Forest and Bird YouTube 215
science Manaaki Whenua – Landcare Research Flax Collection 189
science New Zealand Plant Conservation Network NZPCN E-Newsletters 183
science Plant & Food Research Plant & Food Research YouTube 130
science Forest and Bird Forest and Bird 108
science Manaaki Whenua – Landcare Research Fauna of New Zealand 71
online Wikipedia Wikipedia 14020
online FigShare FigShare 4006
online Tusk - Emergent Culture Tusk - Emergent Culture 250
online Christchurch uncovered Christchurch uncovered 177
museum Auckland War Memorial Museum Tamaki Paenga Hira Auckland Museum Collections 215439
museum Museum of New Zealand Te Papa Tongarewa Te Papa Collections Online 172134
museum Nelson Provincial Museum Nelson Provincial Museum 142857
museum Auckland War Memorial Museum Tamaki Paenga Hira Cenotaph Database 129603
museum Canterbury Museum Canterbury Museum 17167
museum MTG Hawke's Bay MTG Hawke's Bay 12869
museum South Canterbury Museum South Canterbury Museum 9240
museum Mataura Museum Mataura Museum NZMuseums 3132
museum Museum Victoria Museum Victoria 2405
museum New Zealand Fashion Museum New Zealand Fashion Museum 1732
museum Waikato Museum Te Whare Taonga o Waikato Waikato Museum Te Whare Taonga o Waikato 1354
museum Howick Historical Village Howick Historical Village NZMuseums 1208
museum Auckland War Memorial Museum Tamaki Paenga Hira Auckland War Memorial Museum Tamaki Paenga Hira Flickr 728
museum Museum of New Zealand Te Papa Tongarewa Museum of New Zealand Te Papa Tongarewa YouTube 626
museum Auckland War Memorial Museum Tamaki Paenga Hira Auckland War Memorial Museum Tamaki Paenga Hira YouTube 547
museum Powerhouse Museum Powerhouse Museum 300
museum Rotorua Museum of Art & History Te Whare Taonga o Te Arawa Rotorua Museum of Art & History Te Whare Taonga o Te Arawa NZMuseums 290
museum Toitū Otago Settlers Museum Toitū Otago Settlers Museum 275
museum Waimate Historical Museum and Archives Waimate Historical Museum and Archives NZMuseums 254
museum Wanganui Collegiate School Museum Wanganui Collegiate School Museum NZMuseums 242
museum Raglan and District Museum Raglan and District Museum NZMuseums 210
museum Toitū Otago Settlers Museum Toitū Otago Settlers Museum NZMuseums 150
museum Nelson Provincial Museum WW1 Profiles 73
media Radio New Zealand Radio New Zealand 642433
media Television New Zealand TVNZ 65299
science Antarctica New Zealand Antarctica NZ Digital Asset Manager 54732
media Gisborne Photo News Gisborne Photo News 14190
media Science Media Centre Sciblogs 11946
media The Spinoff The Spinoff 11295
media 95bFM 95bFM 6202
media Television New Zealand TVNZ OnDemand 5794
media Public Address Public Address 5680
media Radio New Zealand Radio New Zealand YouTube 5244
media Radio New Zealand The Wireless 3652
media 95bFM 95bFM YouTube 645
media Radio New Zealand The Wireless YouTube 479
media Science Media Centre Science Media Centre 476
media Paul Spain NZ Tech Podcast 461
media Paul Spain NZ Business Podcast 33
media Paul Spain NZ Digital Podcast 10
library National Library of New Zealand Papers Past 26577755
library Alexander Turnbull Library TAPUHI 308770
library Auckland Libraries Auckland Libraries Heritage Images Collection 193597
library Puke Ariki Puke Ariki 132288
library National Library of New Zealand National Library of New Zealand Catalogue 111658
library Trove Trove 93984
library Upper Hutt City Library Upper Hutt Newspaper Archive 51184
library Alexander Turnbull Library Transactions and Proceedings of the Royal Society of New Zealand 1868-1961 37625
library Christchurch City Libraries Christchurch City Libraries Flickr 33502
library Upper Hutt City Library Upper Hutt City Library Heritage Collections 25445
library Auckland Libraries NZ Chinese Journals先驅者之聲 15632
library Tauranga City Libraries Tauranga Memories 14836
library Palmerston North City Library Manawatū Heritage 10000
library Auckland Libraries Local History Online 9301
library John Kinder Theological Library John Kinder Theological Library 7974
library Auckland Libraries Auckland Libraries Manuscripts Collection 7876
library Christchurch City Libraries Christchurch City Libraries Heritage Images Collection 7756
library Digital Public Library of America Digital Public Library of America 7747
library Auckland Libraries Footprints 7410
library Alexander Turnbull Library Te Ao Hou 7066
library National Library of New Zealand AtoJsOnline 6747
library DigitalNZ DigitalNZ Sets 5105
library Upper Hutt City Library Historic Graffiti at Trentham Ranges 4483
library Alexander Turnbull Library Alexander Turnbull Library Flickr 4300
library Feilding Library Feilding Library 3545
library Europeana Europeana 3539
library Hamilton City Libraries Hamilton Heritage Collections 2390
library The British Library The British Library Flickr 2081
library HathiTrust HathiTrust Digital Library 1827
library National Library of Australia Digital Collections (Pictures) 1762
library State Library of Victoria State Library of Victoria 1229
library Hutt City Libraries The Hutt City Libraries Online Heritage Collection 794
library Deutsche Digitale Bibliothek Deutsche Digitale Bibliothek 558
library Wellington City Libraries The Cuba Street Memories Project 250
library DigitalNZ DigitalNZ Blog 192
library National Library of New Zealand Canterbury Earthquake and Rebuild - Archived websites 135
library National Library of New Zealand AnyQuestions 128
library National Library of New Zealand National Library of New Zealand YouTube 119
library Auckland Libraries Our Boys 62
library DigitalNZ DigitalNZ Website 53
library Auckland Libraries Grey Collection - The Gift 53
library DigitalNZ Make it Digital 23
government Department of Internal Affairs New Zealand Gazette 208770
government Ministry for Culture and Heritage Te Ara - The Encyclopedia of New Zealand 39259
government Ministry for Culture and Heritage NZHistory - Suffrage petition signatories 24423
government Ministry for Culture and Heritage NZHistory 17799
government Ministry for Culture and Heritage Ministry for Culture and Heritage Te Ara Flickr 17515
government Hutt City Council Hutt City Council Archives 15899
government Ministry for Culture and Heritage Dictionary of New Zealand Biography 7278
government data.govt.nz data.govt.nz 6531
government Ministry for Culture and Heritage NZHistory - South African War soldiers 6370
government Ministry for Culture and Heritage The Encyclopedia of New Zealand 1966 6086
government Ministry for Culture and Heritage 28th Māori Battalion Te Ope Taua 28 4172
government Ministry for Culture and Heritage Ministry for Culture and Heritage Manatu Taonga Flickr 2300
government Ministry of Health Ministry of Health Publications 1522
government Dunedin City Council Archives Dunedin City Council Archives Flickr 1500
government Reserve Bank of New Zealand Reserve Bank of New Zealand 1431
government Ministry for the Environment Ministry for the Environment Publications 1159
government Ministry for Culture and Heritage QuakeStories 717
government Ministry of Fisheries Te Tautiaki i nga tini a Tangaroa NABIS 652
government The Treasury The Treasury 535
government Department of Labour Department of Labour 520
government Department of Conservation Te Papa Atawhai Department of Conservation Te Papa Atawhai YouTube 424
government Tourism New Zealand Tourism New Zealand YouTube 323
government Reserve Bank of New Zealand Reserve Bank of New Zealand NZMuseums 289
government Ministry of Health Public Health Surveillance reports 262
government Te Puni Kōkiri Te Puni Kōkiri 260
government Waitangi Tribunal Waitangi Tribunal 161
government Ministry for Culture and Heritage Roadside Stories 158
government Ministry of Tourism Te Manatū Tāpoi Tourism Research 105
government Ministry for Culture and Heritage WW100 YouTube 56
government Tourism New Zealand Tourism New Zealand 55
government Ministry for Culture and Heritage Ministry for Culture and Heritage History Group Flickr 50
government Ministry of Health HealthEd Health Resources 1
government Ministry for Culture and Heritage Perspectives 1
government The Treasury National Infrastructure Unit 1
gallery Auckland Art Gallery Toi o Tāmaki Auckland Art Gallery Toi o Tāmaki 16986
gallery Dunedin Public Art Gallery Dunedin Public Art Gallery 15807
gallery Wallace Arts Trust The James Wallace Arts Trust 8442
gallery Sarjeant Gallery Te Whare o Rehua Whanganui Sarjeant Gallery Te Whare o Rehua Whanganui 3061
gallery Auckland Art Gallery Toi o Tāmaki Auckland Art Gallery Toi o Tāmaki YouTube 217
education Victoria University of Wellington New Zealand Electronic Text Collection 180284
education The University of Auckland Library Anthropology Photographic Archive 54026
education University of Otago Hocken Snapshop 33020
education The University of Auckland Library ResearchSpace@Auckland 29057
education Lincoln University Lincoln University Living Heritage: Tikaka Tōku Iho 22883
education The University of Auckland Library History of the University of Auckland 16756
education University of Canterbury Library UC Research Repository 16138
education Massey University Massey Research Online 12897
education University of Waikato ResearchCommons@Waikato 11169
education Victoria University of Wellington VUW ResearchArchive 7784
education University of Otago Otago University Research Archive 7671
education The University of Auckland Library Early New Zealand Statutes 7476
education Auckland University of Technology ScholarlyCommons@AUT 6868
education Lincoln University Lincoln University Research Archive 5727
education The University of Auckland Library Early New Zealand Books 5313
education NZEI Te Riu Roa (New Zealand Educational Institute) NZEI Heritage 5119
education The University of Auckland Library Journal of the Polynesian Society 4745
education University of Otago Otago University Research Heritage 4664
education The University of Auckland Library The Bookshelf 4195
education Massey University Tāmiro 3243
education Unitec Unitec Research Bank 3146
education The University of Auckland Library New Zealand Journal of History 2135
education University of Waikato Māori Niupepa Collection 1816
education Open Polytechnic Open Polytechnic Repository 1279
education CORE Education EDtalks 777
education The University of Auckland Library Archive of Māori and Pacific Music 662
education University of Waikato Historical Photos of the Waikato and New Zealand 618
education University of Otago Marsden Online Archive 599
education The New Zealand Nursing Education and Research Foundation Nursing Education and Research Foundation - Nursing Oral Histories in NZ 308
education Ara Institute of Canterbury Ara Institute of Canterbury Repository 291
education Lincoln University Lincoln University Resources for Education 244
education University of Waikato Historical Maps of the Waikato Region 243
education Victoria University of Wellington Archives@Victoria 224
education New Zealand Tertiary College He Kupu 205
education University of Waikato University Campus Photos 1964 - 2014 184
education University of Waikato Māori Postcards ca. 1890-1940 155
education University of Waikato Waikato Region Postcards 155
education University of Canterbury Library University of Canterbury Digital Library 124
education University of Waikato Illustrated London News: New Zealand 121
education University of Waikato Historical Photos of Waikato Rugby 75
education University of Waikato Māori Art: Canoes 68
education University of Otago Hocken Collections YouTube 53
education University of Otago Media Studies 101 49
education University of Otago Special Collection's Incunabula 38
education University of Otago University of Otago Library Exhibitions 25
education University of Waikato British Parliamentary Papers 22
education University of Waikato Collotype views of Hamilton, Waikato 9
education University of Otago Patterns for Fabric Anatomy Teaching Models 6
education Auckland University of Technology Auckland University of Technology 1
education University of Waikato Hamilton Architecture: Looking back from 1965 1
community Kete Christchurch Kete Christchurch 44177
community Kete New Plymouth Kete New Plymouth 31909
community Kete Horowhenua Kete Horowhenua 28868
community Hamilton City Libraries Kete Hamilton 7769
community Kete Rotorua Kete Rotorua 4204
community Buller, Grey and Westland District Libraries Kete West Coast 3532
community Kete Selwyn Kete Selwyn 2797
community Aotearoa People's Network Kaharoa Aotearoa People's Network Kaharoa Flickr 2553
community Kete Tasman Kete Tasman 1781
community Hurunui District Libraries Hurunui Kete 1478
community AttitudeLive AttitudeLive YouTube 1416
community Central Otago Memory Bank Central Otago Memory Bank 1115
community Kete Hauraki Coromandel Kete Hauraki Coromandel 925
community Nga Manu Nature Reserve Nga Manu Nature Reserve Flickr 800
community Carterton District Library Carterton Kete 723
community Kawerau District Library Kete Kawerau 588
community Waimakariri District Libraries Kete Waimakariri 560
community Kete Taupo Kete Taupo 551
community Kete Central Hawke's Bay Kete Central Hawke's Bay 406
community Kete Tararua Kete Tararua 405
community Kete Masterton Kete Masterton 366
community Kete King Country Kete King Country 261
community Te Awamutu Online Te Awamutu TV YouTube 163
community Canterbury 100 Canterbury 100 107
archive Archives New Zealand Te Rua Mahara o te Kāwanatanga Archway 140914
archive UC QuakeStudies QuakeStudies Repository 128962
archive V.C. Browne & Son V.C. Browne & Son NZ Aerial Photograph Collection 31461
archive Wairarapa Archive Picture Wairarapa 15248
archive UC QuakeStudies Becker Fraser Earthquake Photographs 12564
archive Nelson Photo News Nelson Photo News 8222
archive Archives Central Archives Central 7832
archive eqnz.chch.2010 Flickr 6210
archive Archives New Zealand Te Rua Mahara o te Kāwanatanga Archives New Zealand Te Rua Mahara o te Kāwanatanga Flickr 4100
archive Archives New Zealand Te Rua Mahara o te Kāwanatanga War Art Online 1000
archive Archives New Zealand Te Rua Mahara o te Kāwanatanga Archives New Zealand YouTube 679
archive British Pathé British Pathé 604
archive The Prow: ngā kōrero o te tau ihu TheProw.org.nz 593
archive E-Tangata E-Tangata 564
archive New Zealand Cricket Museum New Zealand Cricket Museum 372
archive Laurie Family WRD Laurie World War One Photographs 163
archive Lost Christchurch Lost Christchurch 131
archive Archives New Zealand Te Rua Mahara o te Kāwanatanga Archives New Zealand Historical Film Footage 47
archive Archives New Zealand Te Rua Mahara o te Kāwanatanga Archives New Zealand Te Rua Mahara o te Kāwanatanga 13
archive Archives New Zealand Te Rua Mahara o te Kāwanatanga Archives New Zealand Audio Visual Wiki 6
archive Archives New Zealand Te Rua Mahara o te Kāwanatanga Shared Repository 2
???? mychillybin mychillybin.co.nz 30553
???? Directory of Open Access Journals Directory of Open Access Journals 4104
???? Social Investment Agency The Hub 3796
???? New Zealand Medical Association The New Zealand Medical Journal 2571
???? PSA Journal PSA Journal 1044
???? BRANZ BRANZ 1037
???? Motu Economic and Public Policy Research Motu Economic and Public Policy Research 751
???? New Zealand Taxation New Zealand Taxation 723
???? AgEcon Search AgEcon Search 599
???? New Zealand Book Council New Zealand Book Council 505
???? Beacon Pathway Ltd Beacon 308
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<meta charset="utf-8">
<style>
body {text-align:center; font-family: sans-serif;}
svg { overflow:visible;}
</style>
<body>
<h1>dnz tree viz</h1>
<svg width="800" height="3000"></svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
console.clear()
const svg = d3.select("svg"),
width = +svg.attr("width"),
height= +svg.attr("height"),
margin= 20,
formatComma = d3.format(",")
// Set up a size scale
const radius = d3.scaleLinear()
.range( [0.5, 50])
.domain([1,10000000])
.clamp(true)
// Declare a D3 layout
const tree = d3.tree()
.size([height, width * 0.8])
// Load our external data
d3.csv("data.csv", function(data) {
data.sort(function(x, y){
return d3.descending(+x.count, +y.count);
})
// Build our hierarchy from a series of levels
// change/reorder the level elements for a different tree
const levels = ["cat", "content_partner"],
hierarchy = flatToHierarchy(data, levels, 'primary_collection', 'count'),
nodes = hierarchy.descendants(),
leaves=hierarchy.leaves(),
links = tree(hierarchy).links()
// Draw on screen
svg.selectAll('path')
.data(links)
.enter().append('path')
.attr('d', d3.linkHorizontal()
.x(function(d) { return d.y; })
.y(function(d) { return d.x; }))
.style('fill', 'none')
.style('opacity', 0.5)
.style('stroke', '#aaa')
.style('stroke-width',(d) => radius(d.target.value) * 2)
svg.selectAll('circle')
.data(nodes)
.enter().append('circle')
.style('r', (d) => radius(d.value))
.style('fill', 'white')
.style('stroke', '#444')
.style('stroke-width',1)
// TODO - make clearer
.attr('transform', function (d) {
return 'translate(' + d.y + ',' + d.x + ')'
})
svg.selectAll(".labels")
.data(nodes)
.enter().append("text")
.attr('text-anchor', 'start')
//.attr('ignore', function(d) {console.log(d.data); return ''})
.text((d) => d.depth == 3 ? d.data.name + ' (' + formatComma(d.data.count) + ')' : d.data.name)
.attr('font-size', '8px')
.attr('transform', function (d) {
return 'translate(' + (d.y + 3) + ',' + (d.x + 2) + ')'
})
})
// Helper function for converting flat data to a hierarchy
// with a name and count field on each node.
// TODO - probably shouldn't name the value field "count"
function flatToHierarchy(flatData, levels, nameField, countField) {
// Adapted from https://stackoverflow.com/a/19317823
var nestedData = { name :"root", children : [] }
// For each data row, loop through the expected levels traversing the output tree
flatData.forEach(function(d){
// Keep this as a reference to the current level
var depthCursor = nestedData.children;
// Go down one level at a time
levels.forEach(function( property, depth ){
// See if a branch has already been created
var index;
depthCursor.forEach(function(child,i){
if ( d[property] == child.name ) index = i;
});
// Add a branch if it isn't there
if ( isNaN(index) ) {
depthCursor.push({ name : d[property], children : []});
index = depthCursor.length - 1;
}
// Reference the new child array as we go deeper into the tree
depthCursor = depthCursor[index].children;
// This is a leaf, so add last element to specified branch
if ( depth === levels.length - 1 ) {
depthCursor.push({
'name':d[nameField],
'count':+d[countField]
});
}
})
})
// sum up the leaves / branches and return the hierarchy
return d3.hierarchy(nestedData).sum(function(d){ return d.count; })
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment