├── .Rbuildignore ├── .block ├── .gitignore ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── R └── treebar.R ├── README-unnamed-chunk-2-1.png ├── README-unnamed-chunk-4-1.png ├── README.Rmd ├── README.md ├── inst ├── example │ ├── data.json │ ├── example_date.R │ ├── example_legend.R │ ├── example_nestd3.R │ ├── example_portfolio.R │ ├── example_replicate.R │ ├── example_shiny.R │ └── example_treemap.R └── htmlwidgets │ ├── lib │ ├── d3 │ │ ├── CHANGES.md │ │ ├── LICENSE │ │ ├── README.md │ │ └── d3.min.js │ ├── d3kit │ │ ├── CHANGELOG.md │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── dist │ │ │ ├── d3kit.js │ │ │ └── d3kit.min.js │ │ └── package.json │ └── treebard3 │ │ ├── README.md │ │ ├── data.json │ │ ├── treebard3.css │ │ └── treebard3.js │ ├── treebar.js │ └── treebar.yaml ├── man ├── treebar-shiny.Rd └── treebar.Rd ├── thumbnail.png └── treebar.Rproj /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^README\.Rmd$ 2 | ^README-.*\.png$ 3 | ^.*\.Rproj$ 4 | ^\.Rproj\.user$ 5 | -------------------------------------------------------------------------------- /.block: -------------------------------------------------------------------------------- 1 | license: mit 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: treebar 2 | Title: Interactive 'd3.js' Treemap Bar 3 | Version: 0.1.1 4 | Date: 2016-08-24 5 | Authors@R: c( 6 | person( 7 | "Mike", "Bostock" 8 | , role = c("aut", "cph") 9 | , comment = "d3.js library in htmlwidgets/lib, http://d3js.org" 10 | ), 11 | person( 12 | "Chris", "Given" 13 | , role = c("aut", "cph") 14 | , comment = "stacked treemap bar library in htmlwidgets/lib, https://gist.github.com/cmgiven/4541f6de7b6fbef482aaa43f3a71f8d4" 15 | ), 16 | person( 17 | "Krist", "Wongsuphasawat" 18 | , role = c("aut", "cph") 19 | , comment = "d3kit library in htmlwidgets/lib, https://github.com/twitter/d3kit" 20 | ), 21 | person( 22 | "Robert", "Harris" 23 | , role = c("aut", "cph") 24 | , comment = "d3kit library in htmlwidgets/lib, https://github.com/twitter/d3kit" 25 | ), 26 | person( 27 | "Kent", "Russell" 28 | , role = c("aut", "cre") 29 | , comment = "R interface" 30 | , email = "kent.russell@timelyportfolio.com" 31 | ) 32 | ) 33 | Description: What the package does (one paragraph). 34 | Depends: 35 | R (>= 3.2.0) 36 | License: MIT + file LICENSE 37 | Encoding: UTF-8 38 | LazyData: true 39 | Imports: 40 | htmlwidgets, 41 | htmltools 42 | Suggests: 43 | jsonlite, 44 | knitr, 45 | stringr 46 | Remotes: 47 | timelyportfolio/d3r 48 | RoxygenNote: 5.0.1 49 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2016 2 | COPYRIGHT HOLDER: Your name goes here 3 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(renderTreebar) 4 | export(treebar) 5 | export(treebarOutput) 6 | import(htmlwidgets) 7 | -------------------------------------------------------------------------------- /R/treebar.R: -------------------------------------------------------------------------------- 1 | #' Interactive Zoomable Treemap Bar Charts 2 | #' 3 | #' htmlwidget based off Chris Given's 4 | #' \href{http://bl.ocks.org/cmgiven/4541f6de7b6fbef482aaa43f3a71f8d4}{Treemap Bar} 5 | #' 6 | #' @param data \code{string} json data of a four level d3.js hierarchy. 7 | #' inflexible now but will improve 8 | #' @param ... additional arguments currently supports 9 | #' id, name, and tile for customizing your chart 10 | #' 11 | #' @example ./inst/example/example_replicate.R 12 | #' @example ./inst/example/example_portfolio.R 13 | #' @example ./inst/example/example_shiny.R 14 | #' 15 | #' @import htmlwidgets 16 | #' 17 | #' @export 18 | treebar <- function(data=NULL, ..., width = NULL, height = NULL, elementId = NULL) { 19 | 20 | # forward options using x 21 | x = list( 22 | data = data, 23 | options = list(...) 24 | ) 25 | 26 | # create widget 27 | htmlwidgets::createWidget( 28 | name = 'treebar', 29 | x = x, 30 | width = width, 31 | height = height, 32 | package = 'treebar', 33 | elementId = elementId 34 | ) 35 | 36 | } 37 | 38 | #' Shiny bindings for treebar 39 | #' 40 | #' Output and render functions for using treebar within Shiny 41 | #' applications and interactive Rmd documents. 42 | #' 43 | #' @param outputId output variable to read from 44 | #' @param width,height Must be a valid CSS unit (like \code{'100\%'}, 45 | #' \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a 46 | #' string and have \code{'px'} appended. 47 | #' @param expr An expression that generates a treebar 48 | #' @param env The environment in which to evaluate \code{expr}. 49 | #' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This 50 | #' is useful if you want to save an expression in a variable. 51 | #' 52 | #' @name treebar-shiny 53 | #' 54 | #' @export 55 | treebarOutput <- function(outputId, width = '100%', height = '400px'){ 56 | htmlwidgets::shinyWidgetOutput(outputId, 'treebar', width, height, package = 'treebar') 57 | } 58 | 59 | #' @rdname treebar-shiny 60 | #' @export 61 | renderTreebar <- function(expr, env = parent.frame(), quoted = FALSE) { 62 | if (!quoted) { expr <- substitute(expr) } # force quoted 63 | htmlwidgets::shinyRenderWidget(expr, treebarOutput, env, quoted = TRUE) 64 | } 65 | 66 | #' @keywords internal 67 | treebar_html <- function(id, style, class, ...){ 68 | htmltools::attachDependencies( 69 | htmltools::tagList( 70 | htmltools::tags$div(id=id, style=style, class=class, ...) 71 | ), 72 | d3r::d3_dep_v4() 73 | ) 74 | } 75 | -------------------------------------------------------------------------------- /README-unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timelyportfolio/treebar/06d8aed34bc2632580ea9818b1512e8a8d8e6c9a/README-unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /README-unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timelyportfolio/treebar/06d8aed34bc2632580ea9818b1512e8a8d8e6c9a/README-unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | always_allow_html: yes 4 | --- 5 | 6 | 7 | 8 | ```{r, echo = FALSE} 9 | knitr::opts_chunk$set( 10 | collapse = TRUE, 11 | comment = "#>", 12 | fig.path = "README-", 13 | warning = FALSE, 14 | message = FALSE 15 | ) 16 | ``` 17 | 18 | based off of [Chris Given](https://twitter.com/cmgiven) [`d3.js`](http://d3js.org) zoomable interactive [treemap bar](http://bl.ocks.org/cmgiven/4541f6de7b6fbef482aaa43f3a71f8d4) 19 | 20 | ### basic example 21 | 22 | ```{r} 23 | #devtools::install_github("timelyportfolio/treebar") 24 | 25 | library(stringr) 26 | library(treebar) 27 | library(jsonlite) 28 | 29 | ## make it a more generic hierarchy 30 | ## normally this step is not necessary 31 | json <- str_replace_all( 32 | readLines(system.file("example/data.json",package="treebar")), 33 | "(country)|(continent)|(year)|(type)", 34 | "id" 35 | ) 36 | 37 | data <- fromJSON(json, simplifyDataFrame=FALSE) 38 | 39 | treebar(data) 40 | ``` 41 | 42 | ### explore tiling options 43 | ```{r} 44 | # also allows different treemap tiling options 45 | library(htmltools) 46 | 47 | browsable( 48 | tagList( 49 | lapply( 50 | c("Squarify", "Binary", "SliceDice", "Slice", "Dice"), 51 | function(tile){ 52 | tags$div( 53 | style = "float:left; display:inline;", 54 | tags$h3(tile), 55 | treebar( 56 | data, 57 | tile = tile, 58 | height = 250, 59 | width = 400 60 | ) 61 | ) 62 | } 63 | ) 64 | ) 65 | ) 66 | ``` 67 | 68 | ### exploring id and value options 69 | 70 | ```{r} 71 | # use different key for id and value 72 | json <- str_replace_all( 73 | readLines("./inst/example/data.json"), 74 | "(country)|(continent)|(year)|(type)", 75 | "name" 76 | ) 77 | 78 | json <- str_replace_all( 79 | json, 80 | "(value)", 81 | "size" 82 | ) 83 | 84 | data <- fromJSON(json, simplifyDataFrame=FALSE) 85 | 86 | treebar(data, value="size", id="name") 87 | ``` 88 | 89 | 90 | ### shiny 91 | 92 | ``` 93 | #devtools::install_github("timelyportfolio/treebar") 94 | 95 | library(stringr) 96 | library(treebar) 97 | library(jsonlite) 98 | library(shiny) 99 | 100 | ## make it a more generic hierarchy 101 | ## normally this step is not necessary 102 | json <- str_replace_all( 103 | readLines(system.file("example/data.json",package="treebar")), 104 | "(country)|(continent)|(year)|(type)", 105 | "id" 106 | ) 107 | 108 | data <- fromJSON(json, simplifyDataFrame=FALSE) 109 | 110 | shinyApp( 111 | ui = htmlwidgets::onRender( 112 | treebar(data), 113 | htmlwidgets::JS( 114 | ' 115 | function(el, x){ 116 | var chart = HTMLWidgets.getInstance(el).instance.treebar; 117 | chart.on("nodeMouseover", function(d,i){ 118 | Shiny.onInputChange("treebar_mouseover", d.data); 119 | }); 120 | } 121 | ' 122 | ) 123 | ), 124 | server = function(input, output, session){ 125 | observeEvent(input$treebar_mouseover,{ 126 | print(input$treebar_mouseover) 127 | }) 128 | } 129 | ) 130 | ``` 131 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | based off of [Chris Given](https://twitter.com/cmgiven) [`d3.js`](http://d3js.org) zoomable interactive [treemap bar](http://bl.ocks.org/cmgiven/4541f6de7b6fbef482aaa43f3a71f8d4) 4 | 5 | ### basic example 6 | 7 | ``` r 8 | #devtools::install_github("timelyportfolio/treebar") 9 | 10 | library(stringr) 11 | library(treebar) 12 | library(jsonlite) 13 | 14 | ## make it a more generic hierarchy 15 | ## normally this step is not necessary 16 | json <- str_replace_all( 17 | readLines(system.file("example/data.json",package="treebar")), 18 | "(country)|(continent)|(year)|(type)", 19 | "id" 20 | ) 21 | 22 | data <- fromJSON(json, simplifyDataFrame=FALSE) 23 | 24 | treebar(data) 25 | ``` 26 | 27 | ![](README-unnamed-chunk-2-1.png) 28 | 29 | ### explore tiling options 30 | 31 | ``` r 32 | # also allows different treemap tiling options 33 | library(htmltools) 34 | 35 | browsable( 36 | tagList( 37 | lapply( 38 | c("Squarify", "Binary", "SliceDice", "Slice", "Dice"), 39 | function(tile){ 40 | tags$div( 41 | style = "float:left; display:inline;", 42 | tags$h3(tile), 43 | treebar( 44 | data, 45 | tile = tile, 46 | height = 250, 47 | width = 400 48 | ) 49 | ) 50 | } 51 | ) 52 | ) 53 | ) 54 | ``` 55 | 56 | ![](README-unnamed-chunk-4-1.png) 57 | 58 | 59 | ### exploring id and value options 60 | 61 | ``` r 62 | # use different key for id and value 63 | json <- str_replace_all( 64 | readLines("./inst/example/data.json"), 65 | "(country)|(continent)|(year)|(type)", 66 | "name" 67 | ) 68 | #> Warning in readLines("./inst/example/data.json"): incomplete final line 69 | #> found on './inst/example/data.json' 70 | 71 | json <- str_replace_all( 72 | json, 73 | "(value)", 74 | "size" 75 | ) 76 | 77 | data <- fromJSON(json, simplifyDataFrame=FALSE) 78 | 79 | treebar(data, value="size", id="name") 80 | ``` 81 | 82 | ### shiny 83 | 84 | ``` 85 | #devtools::install_github("timelyportfolio/treebar") 86 | 87 | library(stringr) 88 | library(treebar) 89 | library(jsonlite) 90 | library(shiny) 91 | 92 | ## make it a more generic hierarchy 93 | ## normally this step is not necessary 94 | json <- str_replace_all( 95 | readLines(system.file("example/data.json",package="treebar")), 96 | "(country)|(continent)|(year)|(type)", 97 | "id" 98 | ) 99 | 100 | data <- fromJSON(json, simplifyDataFrame=FALSE) 101 | 102 | shinyApp( 103 | ui = htmlwidgets::onRender( 104 | treebar(data), 105 | htmlwidgets::JS( 106 | ' 107 | function(el, x){ 108 | var chart = HTMLWidgets.getInstance(el).instance.treebar; 109 | chart.on("nodeMouseover", function(d,i){ 110 | Shiny.onInputChange("treebar_mouseover", d.data); 111 | }); 112 | } 113 | ' 114 | ) 115 | ), 116 | server = function(input, output, session){ 117 | observeEvent(input$treebar_mouseover,{ 118 | print(input$treebar_mouseover) 119 | }) 120 | } 121 | ) 122 | ``` 123 | -------------------------------------------------------------------------------- /inst/example/data.json: -------------------------------------------------------------------------------- 1 | {"children":[{"year":"1995","children":[{"type":"Imports","children":[{"continent":"North America","children":[{"country":"Greenland","value":7.6,"adj_value":11.81952},{"country":"Canada","value":144369.9,"adj_value":224524.0685},{"country":"St Pierre and Miquelon","value":3.4,"adj_value":5.28768},{"country":"Mexico","value":62100.4,"adj_value":96578.54208},{"country":"Guatemala","value":1526.8,"adj_value":2374.47936},{"country":"Belize","value":52.1,"adj_value":81.02592},{"country":"El Salvador","value":812.2,"adj_value":1263.13344},{"country":"Honduras","value":1441.2,"adj_value":2241.35424},{"country":"Nicaragua","value":238.8,"adj_value":371.38176},{"country":"Costa Rica","value":1843.2,"adj_value":2866.54464},{"country":"Panama","value":307.1,"adj_value":477.60192},{"country":"Bermuda","value":10.4,"adj_value":16.17408},{"country":"Bahamas","value":156.7,"adj_value":243.69984},{"country":"Cuba","value":0,"adj_value":0},{"country":"Jamaica","value":846.9,"adj_value":1317.09888},{"country":"Turks and Caicos Islands","value":5,"adj_value":7.776},{"country":"Cayman Islands","value":18.2,"adj_value":28.30464},{"country":"Haiti","value":129.9,"adj_value":202.02048},{"country":"Dominican Republic","value":3398.9,"adj_value":5285.96928},{"country":"Anguilla","value":0,"adj_value":0},{"country":"British Virgin Islands","value":11.2,"adj_value":17.41824},{"country":"St Kitts and Nevis","value":22.3,"adj_value":34.68096},{"country":"Antigua and Barbuda","value":2.8,"adj_value":4.35456},{"country":"Montserrat","value":2,"adj_value":3.1104},{"country":"Dominica","value":6.6,"adj_value":10.26432},{"country":"St Lucia","value":35.1,"adj_value":54.58752},{"country":"St Vincent and the Grenadines","value":7.9,"adj_value":12.28608},{"country":"Grenada","value":5.3,"adj_value":8.24256},{"country":"Barbados","value":37.7,"adj_value":58.63104},{"country":"Trinidad and Tobago","value":1089.2,"adj_value":1693.92384},{"country":"Netherlands Antilles","value":289.8,"adj_value":450.69696},{"country":"Aruba","value":420.7,"adj_value":654.27264},{"country":"Guadeloupe","value":1.2,"adj_value":1.86624},{"country":"Martinique","value":1.9,"adj_value":2.95488}]},{"continent":"South America","children":[{"country":"Colombia","value":3791,"adj_value":5895.7632},{"country":"Venezuela","value":9764,"adj_value":15184.9728},{"country":"Guyana","value":107.4,"adj_value":167.02848},{"country":"Suriname","value":100,"adj_value":155.52},{"country":"French Guiana","value":5.2,"adj_value":8.08704},{"country":"Ecuador","value":1939.7,"adj_value":3016.62144},{"country":"Peru","value":1034.4,"adj_value":1608.69888},{"country":"Bolivia","value":262.5,"adj_value":408.24},{"country":"Chile","value":1930.8,"adj_value":3002.78016},{"country":"Brazil","value":8832.9,"adj_value":13736.92608},{"country":"Paraguay","value":55,"adj_value":85.536},{"country":"Uruguay","value":167.2,"adj_value":260.02944},{"country":"Argentina","value":1760.8,"adj_value":2738.39616},{"country":"Falkland Islands(Islas Malvin","value":0.5,"adj_value":0.7776}]},{"continent":"Europe","children":[{"country":"Iceland","value":232.8,"adj_value":362.05056},{"country":"Sweden","value":6256.4,"adj_value":9729.95328},{"country":"Svalbard, Jan Mayen Island","value":0.2,"adj_value":0.31104},{"country":"Norway","value":3086.7,"adj_value":4800.43584},{"country":"Finland","value":2269.9,"adj_value":3530.14848},{"country":"Faroe Islands","value":8.4,"adj_value":13.06368},{"country":"Denmark","value":1944.9,"adj_value":3024.70848},{"country":"United Kingdom","value":26929.7,"adj_value":41881.06944},{"country":"Ireland","value":4078.7,"adj_value":6343.19424},{"country":"Netherlands","value":6404.9,"adj_value":9960.90048},{"country":"Belgium","value":6053.9,"adj_value":9415.02528},{"country":"Luxembourg","value":233.8,"adj_value":363.60576},{"country":"Andorra","value":0.2,"adj_value":0.31104},{"country":"Monaco","value":12.2,"adj_value":18.97344},{"country":"France","value":17209.4,"adj_value":26764.05888},{"country":"Germany","value":36843.9,"adj_value":57299.63328},{"country":"Austria","value":1963.2,"adj_value":3053.16864},{"country":"Czechoslovakia","value":0,"adj_value":0},{"country":"Czech Republic","value":363.3,"adj_value":565.00416},{"country":"Slovakia","value":129.5,"adj_value":201.3984},{"country":"Hungary","value":547,"adj_value":850.6944},{"country":"Liechtenstein","value":126.2,"adj_value":196.26624},{"country":"Switzerland","value":7593.9,"adj_value":11810.03328},{"country":"Estonia","value":62.1,"adj_value":96.57792},{"country":"Latvia","value":82,"adj_value":127.5264},{"country":"Lithuania","value":26.5,"adj_value":41.2128},{"country":"Poland","value":663.6,"adj_value":1032.03072},{"country":"USSR","value":0,"adj_value":0},{"country":"Russia","value":4030.1,"adj_value":6267.61152},{"country":"Belarus","value":45,"adj_value":69.984},{"country":"Ukraine","value":405.7,"adj_value":630.94464},{"country":"Armenia","value":16.3,"adj_value":25.34976},{"country":"Azerbaijan","value":0.7,"adj_value":1.08864},{"country":"Georgia","value":10.7,"adj_value":16.64064},{"country":"Kazakhstan","value":122.9,"adj_value":191.13408},{"country":"Kyrgyzstan","value":8.4,"adj_value":13.06368},{"country":"Moldova","value":24.8,"adj_value":38.56896},{"country":"Tajikistan","value":40.9,"adj_value":63.60768},{"country":"Turkmenistan","value":1.3,"adj_value":2.02176},{"country":"Uzbekistan","value":18.8,"adj_value":29.23776},{"country":"Spain","value":3879.7,"adj_value":6033.70944},{"country":"Portugal","value":1056.7,"adj_value":1643.37984},{"country":"Gibraltar","value":4.8,"adj_value":7.46496},{"country":"Malta","value":132.5,"adj_value":206.064},{"country":"San Marino","value":1,"adj_value":1.5552},{"country":"Vatican City","value":0.7,"adj_value":1.08864},{"country":"Italy","value":16348.4,"adj_value":25425.03168},{"country":"Yugoslavia (former)","value":0,"adj_value":0},{"country":"Croatia","value":93.8,"adj_value":145.87776},{"country":"Slovenia","value":289.5,"adj_value":450.2304},{"country":"Bosnia and Herzegovina","value":3.5,"adj_value":5.4432},{"country":"Macedonia","value":88.8,"adj_value":138.10176},{"country":"Serbia and Montenegro","value":0,"adj_value":0},{"country":"Albania","value":9.4,"adj_value":14.61888},{"country":"Greece","value":397.1,"adj_value":617.56992},{"country":"Romania","value":222.3,"adj_value":345.72096},{"country":"Bulgaria","value":188.5,"adj_value":293.1552}]},{"continent":"Asia","children":[{"country":"Turkey","value":1797.9,"adj_value":2796.09408},{"country":"Cyprus","value":13.1,"adj_value":20.37312},{"country":"Syria","value":61.1,"adj_value":95.02272},{"country":"Lebanon","value":35,"adj_value":54.432},{"country":"Iraq","value":0,"adj_value":0},{"country":"Iran","value":0.2,"adj_value":0.31104},{"country":"Israel","value":0,"adj_value":0},{"country":"Israel","value":5708.7,"adj_value":8878.17024},{"country":"Gaza Strip admin. by Israel","value":0,"adj_value":0},{"country":"West Bank admin. by Israel","value":0,"adj_value":0},{"country":"Jordan","value":28.9,"adj_value":44.94528},{"country":"Kuwait","value":1335.5,"adj_value":2076.9696},{"country":"Iraq-Saudi Arabia Neutral Zone","value":0,"adj_value":0},{"country":"Saudi Arabia","value":8376.6,"adj_value":13027.28832},{"country":"Qatar","value":90.9,"adj_value":141.36768},{"country":"United Arab Emirates","value":459.1,"adj_value":713.99232},{"country":"Republic of Yemen","value":41.5,"adj_value":64.5408},{"country":"Oman","value":294.9,"adj_value":458.62848},{"country":"Bahrain","value":134.3,"adj_value":208.86336},{"country":"Afghanistan","value":5.4,"adj_value":8.39808},{"country":"India","value":5726.3,"adj_value":8905.54176},{"country":"Pakistan","value":1197,"adj_value":1861.5744},{"country":"Nepal","value":96.1,"adj_value":149.45472},{"country":"Bangladesh","value":1257.2,"adj_value":1955.19744},{"country":"Sri Lanka","value":1259.7,"adj_value":1959.08544},{"country":"Burma","value":81,"adj_value":125.9712},{"country":"Thailand","value":11348.1,"adj_value":17648.56512},{"country":"Vietnam","value":199,"adj_value":309.4848},{"country":"Laos","value":10.2,"adj_value":15.86304},{"country":"Cambodia","value":5.1,"adj_value":7.93152},{"country":"Malaysia","value":17454.9,"adj_value":27145.86048},{"country":"Singapore","value":18560.4,"adj_value":28865.13408},{"country":"Indonesia","value":7435.3,"adj_value":11563.37856},{"country":"Brunei","value":38.4,"adj_value":59.71968},{"country":"Philippines","value":7006.5,"adj_value":10896.5088},{"country":"Macau","value":895.3,"adj_value":1392.37056},{"country":"Bhutan","value":0.1,"adj_value":0.15552},{"country":"Maldives","value":12,"adj_value":18.6624},{"country":"China","value":45543.2,"adj_value":70828.78464},{"country":"Mongolia","value":23.2,"adj_value":36.08064},{"country":"Korea, North","value":0,"adj_value":0},{"country":"Korea, South","value":24184,"adj_value":37610.9568},{"country":"Hong Kong","value":10291.3,"adj_value":16005.02976},{"country":"Taiwan","value":28971.9,"adj_value":45057.09888},{"country":"Japan","value":123479.3,"adj_value":192035.0074}]},{"continent":"Australia","children":[{"country":"Australia","value":3323,"adj_value":5167.9296},{"country":"Norfolk Island","value":78.6,"adj_value":122.23872},{"country":"Cocos (Keeling) Islands","value":0,"adj_value":0},{"country":"Christmas Island","value":0,"adj_value":0},{"country":"Heard and McDonald Islands","value":0.3,"adj_value":0.46656},{"country":"Papua New Guinea","value":50.2,"adj_value":78.07104},{"country":"New Zealand","value":1451.8,"adj_value":2257.83936},{"country":"Cook Islands","value":0.8,"adj_value":1.24416},{"country":"Tokelau","value":6.1,"adj_value":9.48672},{"country":"Niue","value":0.1,"adj_value":0.15552},{"country":"Samoa","value":0.3,"adj_value":0.46656},{"country":"Solomon Islands","value":4.3,"adj_value":6.68736},{"country":"Vanuatu","value":0,"adj_value":0},{"country":"Pitcairn Islands","value":0,"adj_value":0},{"country":"Kiribati","value":1.4,"adj_value":2.17728},{"country":"Tuvalu","value":0,"adj_value":0},{"country":"New Caledonia","value":40.2,"adj_value":62.51904},{"country":"Wallis and Futuna","value":0,"adj_value":0},{"country":"French Polynesia","value":14.4,"adj_value":22.39488},{"country":"Marshall Islands","value":11.1,"adj_value":17.26272},{"country":"Micronesia","value":13.2,"adj_value":20.52864},{"country":"Palau","value":5.8,"adj_value":9.02016},{"country":"Nauru","value":0,"adj_value":0},{"country":"Fiji","value":78.1,"adj_value":121.46112},{"country":"Tonga","value":6.2,"adj_value":9.64224}]},{"continent":"Africa","children":[{"country":"Morocco","value":239.4,"adj_value":372.31488},{"country":"Algeria","value":1749.5,"adj_value":2720.8224},{"country":"Tunisia","value":70.4,"adj_value":109.48608},{"country":"Libya","value":0,"adj_value":0},{"country":"Egypt","value":606.3,"adj_value":942.91776},{"country":"Sudan","value":22.6,"adj_value":35.14752},{"country":"Western Sahara","value":0,"adj_value":0},{"country":"Equatorial Guinea","value":31,"adj_value":48.2112},{"country":"Mauritania","value":5.4,"adj_value":8.39808},{"country":"Cameroon","value":57.3,"adj_value":89.11296},{"country":"Senegal","value":4.9,"adj_value":7.62048},{"country":"Mali","value":3.6,"adj_value":5.59872},{"country":"Guinea","value":98.8,"adj_value":153.65376},{"country":"Sierra Leone","value":28.4,"adj_value":44.16768},{"country":"Cote d'Ivoire","value":214.1,"adj_value":332.96832},{"country":"Ghana","value":196.1,"adj_value":304.97472},{"country":"Gambia","value":2.2,"adj_value":3.42144},{"country":"Niger","value":1.4,"adj_value":2.17728},{"country":"Togo","value":3.3,"adj_value":5.13216},{"country":"Nigeria","value":4930.5,"adj_value":7667.9136},{"country":"Central African Republic","value":0.4,"adj_value":0.62208},{"country":"Gabon","value":1463.9,"adj_value":2276.65728},{"country":"Chad","value":3.3,"adj_value":5.13216},{"country":"St Helena","value":0,"adj_value":0},{"country":"Burkina Faso","value":0.4,"adj_value":0.62208},{"country":"Benin","value":10,"adj_value":15.552},{"country":"Angola","value":2232.3,"adj_value":3471.67296},{"country":"Congo (Brazzaville)","value":206.8,"adj_value":321.61536},{"country":"Guinea-Bissau","value":0,"adj_value":0},{"country":"Cabo Verde","value":0.2,"adj_value":0.31104},{"country":"Sao Tome and Principe","value":0.1,"adj_value":0.15552},{"country":"Liberia","value":9.9,"adj_value":15.39648},{"country":"Congo (Kinshasa)","value":267,"adj_value":415.2384},{"country":"Burundi","value":20.5,"adj_value":31.8816},{"country":"Rwanda","value":1.8,"adj_value":2.79936},{"country":"Somalia","value":0,"adj_value":0},{"country":"Ethiopia","value":0,"adj_value":0},{"country":"Eritrea","value":0.4,"adj_value":0.62208},{"country":"Ethiopia","value":32.9,"adj_value":51.16608},{"country":"Djibouti","value":0,"adj_value":0},{"country":"Uganda","value":13.4,"adj_value":20.83968},{"country":"Kenya","value":101.5,"adj_value":157.8528},{"country":"Seychelles","value":2.5,"adj_value":3.888},{"country":"British Indian Ocean Terr.","value":1.9,"adj_value":2.95488},{"country":"Tanzania","value":22.4,"adj_value":34.83648},{"country":"Mauritius","value":229.5,"adj_value":356.9184},{"country":"Mozambique","value":27.5,"adj_value":42.768},{"country":"Madagascar","value":57.4,"adj_value":89.26848},{"country":"Comoros","value":2.2,"adj_value":3.42144},{"country":"Reunion","value":0.4,"adj_value":0.62208},{"country":"French Southern and Antarctic","value":0.4,"adj_value":0.62208},{"country":"South Africa","value":2208,"adj_value":3433.8816},{"country":"Namibia","value":11.5,"adj_value":17.8848},{"country":"Botswana","value":21.3,"adj_value":33.12576},{"country":"Zambia","value":32.8,"adj_value":51.01056},{"country":"Swaziland","value":32.4,"adj_value":50.38848},{"country":"Zimbabwe","value":97.5,"adj_value":151.632},{"country":"Malawi","value":41.1,"adj_value":63.91872},{"country":"Lesotho","value":62.3,"adj_value":96.88896}]}]},{"type":"Exports","children":[{"continent":"North America","children":[{"country":"Greenland","value":2.4,"adj_value":3.73248},{"country":"Canada","value":127226,"adj_value":197861.8752},{"country":"St Pierre and Miquelon","value":0.5,"adj_value":0.7776},{"country":"Mexico","value":46292.1,"adj_value":71993.47392},{"country":"Guatemala","value":1646.6,"adj_value":2560.79232},{"country":"Belize","value":99.7,"adj_value":155.05344},{"country":"El Salvador","value":1110.4,"adj_value":1726.89408},{"country":"Honduras","value":1278.9,"adj_value":1988.94528},{"country":"Nicaragua","value":249.8,"adj_value":388.48896},{"country":"Costa Rica","value":1736.6,"adj_value":2700.76032},{"country":"Panama","value":1389.6,"adj_value":2161.10592},{"country":"Bermuda","value":298.5,"adj_value":464.2272},{"country":"Bahamas","value":661.2,"adj_value":1028.29824},{"country":"Cuba","value":5.4,"adj_value":8.39808},{"country":"Jamaica","value":1420.2,"adj_value":2208.69504},{"country":"Turks and Caicos Islands","value":33.6,"adj_value":52.25472},{"country":"Cayman Islands","value":180.1,"adj_value":280.09152},{"country":"Haiti","value":550.1,"adj_value":855.51552},{"country":"Dominican Republic","value":3014.9,"adj_value":4688.77248},{"country":"Anguilla","value":14.6,"adj_value":22.70592},{"country":"British Virgin Islands","value":49.2,"adj_value":76.51584},{"country":"St Kitts and Nevis","value":43.6,"adj_value":67.80672},{"country":"Antigua and Barbuda","value":97,"adj_value":150.8544},{"country":"Montserrat","value":4.4,"adj_value":6.84288},{"country":"Dominica","value":26.6,"adj_value":41.36832},{"country":"St Lucia","value":80.8,"adj_value":125.66016},{"country":"St Vincent and the Grenadines","value":42.2,"adj_value":65.62944},{"country":"Grenada","value":26.9,"adj_value":41.83488},{"country":"Barbados","value":185.6,"adj_value":288.64512},{"country":"Trinidad and Tobago","value":689.2,"adj_value":1071.84384},{"country":"Netherlands Antilles","value":503.9,"adj_value":783.66528},{"country":"Aruba","value":247.6,"adj_value":385.06752},{"country":"Guadeloupe","value":69.1,"adj_value":107.46432},{"country":"Martinique","value":38.5,"adj_value":59.8752}]},{"continent":"South America","children":[{"country":"Colombia","value":4624.4,"adj_value":7191.86688},{"country":"Venezuela","value":4640.4,"adj_value":7216.75008},{"country":"Guyana","value":141.3,"adj_value":219.74976},{"country":"Suriname","value":189.7,"adj_value":295.02144},{"country":"French Guiana","value":441.8,"adj_value":687.08736},{"country":"Ecuador","value":1538.3,"adj_value":2392.36416},{"country":"Peru","value":1775.4,"adj_value":2761.10208},{"country":"Bolivia","value":213.5,"adj_value":332.0352},{"country":"Chile","value":3614.7,"adj_value":5621.58144},{"country":"Brazil","value":11439.4,"adj_value":17790.55488},{"country":"Paraguay","value":992.4,"adj_value":1543.38048},{"country":"Uruguay","value":395.8,"adj_value":615.54816},{"country":"Argentina","value":4189.2,"adj_value":6515.04384},{"country":"Falkland Islands(Islas Malvin","value":0.3,"adj_value":0.46656}]},{"continent":"Europe","children":[{"country":"Iceland","value":170.5,"adj_value":265.1616},{"country":"Sweden","value":3079.7,"adj_value":4789.54944},{"country":"Svalbard, Jan Mayen Island","value":1.1,"adj_value":1.71072},{"country":"Norway","value":1292.9,"adj_value":2010.71808},{"country":"Finland","value":1249.7,"adj_value":1943.53344},{"country":"Faroe Islands","value":0.4,"adj_value":0.62208},{"country":"Denmark","value":1517.7,"adj_value":2360.32704},{"country":"United Kingdom","value":28856.5,"adj_value":44877.6288},{"country":"Ireland","value":4108.7,"adj_value":6389.85024},{"country":"Netherlands","value":16557.6,"adj_value":25750.37952},{"country":"Belgium","value":12465.6,"adj_value":19386.50112},{"country":"Luxembourg","value":374.2,"adj_value":581.95584},{"country":"Andorra","value":16.5,"adj_value":25.6608},{"country":"Monaco","value":9.6,"adj_value":14.92992},{"country":"France","value":14245.2,"adj_value":22154.13504},{"country":"Germany","value":22394.3,"adj_value":34827.61536},{"country":"Austria","value":2017,"adj_value":3136.8384},{"country":"Czechoslovakia","value":0,"adj_value":0},{"country":"Czech Republic","value":362.8,"adj_value":564.22656},{"country":"Slovakia","value":61,"adj_value":94.8672},{"country":"Hungary","value":295.2,"adj_value":459.09504},{"country":"Liechtenstein","value":15.1,"adj_value":23.48352},{"country":"Switzerland","value":6227.4,"adj_value":9684.85248},{"country":"Estonia","value":139.1,"adj_value":216.32832},{"country":"Latvia","value":89.5,"adj_value":139.1904},{"country":"Lithuania","value":52.2,"adj_value":81.18144},{"country":"Poland","value":776.1,"adj_value":1206.99072},{"country":"USSR","value":0,"adj_value":0},{"country":"Russia","value":2823.4,"adj_value":4390.95168},{"country":"Belarus","value":47.9,"adj_value":74.49408},{"country":"Ukraine","value":223.4,"adj_value":347.43168},{"country":"Armenia","value":70.3,"adj_value":109.33056},{"country":"Azerbaijan","value":35.6,"adj_value":55.36512},{"country":"Georgia","value":95.2,"adj_value":148.05504},{"country":"Kazakhstan","value":80.9,"adj_value":125.81568},{"country":"Kyrgyzstan","value":24.6,"adj_value":38.25792},{"country":"Moldova","value":10.2,"adj_value":15.86304},{"country":"Tajikistan","value":17.6,"adj_value":27.37152},{"country":"Turkmenistan","value":34.3,"adj_value":53.34336},{"country":"Uzbekistan","value":63.4,"adj_value":98.59968},{"country":"Spain","value":5526,"adj_value":8594.0352},{"country":"Portugal","value":898.1,"adj_value":1396.72512},{"country":"Gibraltar","value":18.4,"adj_value":28.61568},{"country":"Malta","value":106.7,"adj_value":165.93984},{"country":"San Marino","value":5.7,"adj_value":8.86464},{"country":"Vatican City","value":0.3,"adj_value":0.46656},{"country":"Italy","value":8861.6,"adj_value":13781.56032},{"country":"Yugoslavia (former)","value":0,"adj_value":0},{"country":"Croatia","value":140,"adj_value":217.728},{"country":"Slovenia","value":109.6,"adj_value":170.44992},{"country":"Bosnia and Herzegovina","value":28.3,"adj_value":44.01216},{"country":"Macedonia","value":21.2,"adj_value":32.97024},{"country":"Serbia and Montenegro","value":2.1,"adj_value":3.26592},{"country":"Albania","value":13.5,"adj_value":20.9952},{"country":"Greece","value":1518.7,"adj_value":2361.88224},{"country":"Romania","value":253.2,"adj_value":393.77664},{"country":"Bulgaria","value":131.8,"adj_value":204.97536}]},{"continent":"Asia","children":[{"country":"Turkey","value":2768,"adj_value":4304.7936},{"country":"Cyprus","value":257.8,"adj_value":400.93056},{"country":"Syria","value":223.4,"adj_value":347.43168},{"country":"Lebanon","value":592.2,"adj_value":920.98944},{"country":"Iraq","value":0.2,"adj_value":0.31104},{"country":"Iran","value":277.4,"adj_value":431.41248},{"country":"Israel","value":0,"adj_value":0},{"country":"Israel","value":5621,"adj_value":8741.7792},{"country":"Gaza Strip admin. by Israel","value":0.1,"adj_value":0.15552},{"country":"West Bank admin. by Israel","value":0.3,"adj_value":0.46656},{"country":"Jordan","value":335.3,"adj_value":521.45856},{"country":"Kuwait","value":1437.4,"adj_value":2235.44448},{"country":"Iraq-Saudi Arabia Neutral Zone","value":0,"adj_value":0},{"country":"Saudi Arabia","value":6155,"adj_value":9572.256},{"country":"Qatar","value":226,"adj_value":351.4752},{"country":"United Arab Emirates","value":2006.3,"adj_value":3120.19776},{"country":"Republic of Yemen","value":185.3,"adj_value":288.17856},{"country":"Oman","value":222,"adj_value":345.2544},{"country":"Bahrain","value":255.1,"adj_value":396.73152},{"country":"Afghanistan","value":4,"adj_value":6.2208},{"country":"India","value":3295.8,"adj_value":5125.62816},{"country":"Pakistan","value":941.3,"adj_value":1463.90976},{"country":"Nepal","value":9.8,"adj_value":15.24096},{"country":"Bangladesh","value":325,"adj_value":505.44},{"country":"Sri Lanka","value":279.1,"adj_value":434.05632},{"country":"Burma","value":16.2,"adj_value":25.19424},{"country":"Thailand","value":6665,"adj_value":10365.408},{"country":"Vietnam","value":252.3,"adj_value":392.37696},{"country":"Laos","value":1.6,"adj_value":2.48832},{"country":"Cambodia","value":26.9,"adj_value":41.83488},{"country":"Malaysia","value":8816.1,"adj_value":13710.79872},{"country":"Singapore","value":15333,"adj_value":23845.8816},{"country":"Indonesia","value":3359.6,"adj_value":5224.84992},{"country":"Brunei","value":190.1,"adj_value":295.64352},{"country":"Philippines","value":5294.8,"adj_value":8234.47296},{"country":"Macau","value":29.9,"adj_value":46.50048},{"country":"Bhutan","value":0.5,"adj_value":0.7776},{"country":"Maldives","value":1.1,"adj_value":1.71072},{"country":"China","value":11753.7,"adj_value":18279.35424},{"country":"Mongolia","value":13.9,"adj_value":21.61728},{"country":"Korea, North","value":11.6,"adj_value":18.04032},{"country":"Korea, South","value":25379.9,"adj_value":39470.82048},{"country":"Hong Kong","value":14231.5,"adj_value":22132.8288},{"country":"Taiwan","value":19289.6,"adj_value":29999.18592},{"country":"Japan","value":64342.7,"adj_value":100065.767}]},{"continent":"Australia","children":[{"country":"Australia","value":10789.1,"adj_value":16779.20832},{"country":"Norfolk Island","value":1.2,"adj_value":1.86624},{"country":"Cocos (Keeling) Islands","value":0.5,"adj_value":0.7776},{"country":"Christmas Island","value":4.5,"adj_value":6.9984},{"country":"Heard and McDonald Islands","value":0,"adj_value":0},{"country":"Papua New Guinea","value":50.8,"adj_value":79.00416},{"country":"New Zealand","value":1691.3,"adj_value":2630.30976},{"country":"Cook Islands","value":0.9,"adj_value":1.39968},{"country":"Tokelau","value":0.1,"adj_value":0.15552},{"country":"Niue","value":31.5,"adj_value":48.9888},{"country":"Samoa","value":7.3,"adj_value":11.35296},{"country":"Solomon Islands","value":2.7,"adj_value":4.19904},{"country":"Vanuatu","value":1.1,"adj_value":1.71072},{"country":"Pitcairn Islands","value":2.2,"adj_value":3.42144},{"country":"Kiribati","value":2.3,"adj_value":3.57696},{"country":"Tuvalu","value":0.3,"adj_value":0.46656},{"country":"New Caledonia","value":22.3,"adj_value":34.68096},{"country":"Wallis and Futuna","value":0,"adj_value":0},{"country":"French Polynesia","value":82.3,"adj_value":127.99296},{"country":"Marshall Islands","value":31.8,"adj_value":49.45536},{"country":"Micronesia","value":23.3,"adj_value":36.23616},{"country":"Palau","value":8.3,"adj_value":12.90816},{"country":"Nauru","value":0.5,"adj_value":0.7776},{"country":"Fiji","value":31.8,"adj_value":49.45536},{"country":"Tonga","value":7.5,"adj_value":11.664}]},{"continent":"Africa","children":[{"country":"Morocco","value":517.4,"adj_value":804.66048},{"country":"Algeria","value":774.1,"adj_value":1203.88032},{"country":"Tunisia","value":214.9,"adj_value":334.21248},{"country":"Libya","value":0,"adj_value":0},{"country":"Egypt","value":2985.1,"adj_value":4642.42752},{"country":"Sudan","value":43.5,"adj_value":67.6512},{"country":"Western Sahara","value":0,"adj_value":0},{"country":"Equatorial Guinea","value":5.2,"adj_value":8.08704},{"country":"Mauritania","value":43.2,"adj_value":67.18464},{"country":"Cameroon","value":45.6,"adj_value":70.91712},{"country":"Senegal","value":67.9,"adj_value":105.59808},{"country":"Mali","value":23.1,"adj_value":35.92512},{"country":"Guinea","value":66.5,"adj_value":103.4208},{"country":"Sierra Leone","value":18.1,"adj_value":28.14912},{"country":"Cote d'Ivoire","value":173.3,"adj_value":269.51616},{"country":"Ghana","value":167.2,"adj_value":260.02944},{"country":"Gambia","value":6.1,"adj_value":9.48672},{"country":"Niger","value":39.6,"adj_value":61.58592},{"country":"Togo","value":18.5,"adj_value":28.7712},{"country":"Nigeria","value":602.9,"adj_value":937.63008},{"country":"Central African Republic","value":6.3,"adj_value":9.79776},{"country":"Gabon","value":54.5,"adj_value":84.7584},{"country":"Chad","value":10.8,"adj_value":16.79616},{"country":"St Helena","value":0.3,"adj_value":0.46656},{"country":"Burkina Faso","value":14.7,"adj_value":22.86144},{"country":"Benin","value":34,"adj_value":52.8768},{"country":"Angola","value":259.7,"adj_value":403.88544},{"country":"Congo (Brazzaville)","value":54.8,"adj_value":85.22496},{"country":"Guinea-Bissau","value":0.8,"adj_value":1.24416},{"country":"Cabo Verde","value":7.5,"adj_value":11.664},{"country":"Sao Tome and Principe","value":1.8,"adj_value":2.79936},{"country":"Liberia","value":41.7,"adj_value":64.85184},{"country":"Congo (Kinshasa)","value":77.1,"adj_value":119.90592},{"country":"Burundi","value":2.9,"adj_value":4.51008},{"country":"Rwanda","value":38.3,"adj_value":59.56416},{"country":"Somalia","value":8.1,"adj_value":12.59712},{"country":"Ethiopia","value":0,"adj_value":0},{"country":"Eritrea","value":16.5,"adj_value":25.6608},{"country":"Ethiopia","value":147.7,"adj_value":229.70304},{"country":"Djibouti","value":8.5,"adj_value":13.2192},{"country":"Uganda","value":22.1,"adj_value":34.36992},{"country":"Kenya","value":114,"adj_value":177.2928},{"country":"Seychelles","value":7.2,"adj_value":11.19744},{"country":"British Indian Ocean Terr.","value":1.8,"adj_value":2.79936},{"country":"Tanzania","value":66.2,"adj_value":102.95424},{"country":"Mauritius","value":24.6,"adj_value":38.25792},{"country":"Mozambique","value":49.3,"adj_value":76.67136},{"country":"Madagascar","value":9.8,"adj_value":15.24096},{"country":"Comoros","value":0.6,"adj_value":0.93312},{"country":"Reunion","value":3.7,"adj_value":5.75424},{"country":"French Southern and Antarctic","value":0,"adj_value":0},{"country":"South Africa","value":2750.5,"adj_value":4277.5776},{"country":"Namibia","value":26.5,"adj_value":41.2128},{"country":"Botswana","value":35.7,"adj_value":55.52064},{"country":"Zambia","value":48.9,"adj_value":76.04928},{"country":"Swaziland","value":3.2,"adj_value":4.97664},{"country":"Zimbabwe","value":122.1,"adj_value":189.88992},{"country":"Malawi","value":17.8,"adj_value":27.68256},{"country":"Lesotho","value":1.8,"adj_value":2.79936}]}]}]},{"year":"2005","children":[{"type":"Imports","children":[{"continent":"North America","children":[{"country":"Greenland","value":17.255599,"adj_value":20.94139495},{"country":"Canada","value":290384.2932,"adj_value":352410.3782},{"country":"St Pierre and Miquelon","value":1.094378,"adj_value":1.328137141},{"country":"Mexico","value":170108.6141,"adj_value":206443.8141},{"country":"Guatemala","value":3137.382263,"adj_value":3807.527114},{"country":"Belize","value":98.265102,"adj_value":119.2545278},{"country":"El Salvador","value":1988.765718,"adj_value":2413.566075},{"country":"Honduras","value":3749.243099,"adj_value":4550.081425},{"country":"Nicaragua","value":1180.787602,"adj_value":1433.003834},{"country":"Costa Rica","value":3415.279262,"adj_value":4144.782912},{"country":"Panama","value":327.060069,"adj_value":396.9200997},{"country":"Bermuda","value":87.276753,"adj_value":105.9190674},{"country":"Bahamas","value":699.936003,"adj_value":849.4423332},{"country":"Cuba","value":0.009079,"adj_value":0.011018274},{"country":"Jamaica","value":375.57236,"adj_value":455.7946161},{"country":"Turks and Caicos Islands","value":9.434412,"adj_value":11.4496024},{"country":"Cayman Islands","value":53.497875,"adj_value":64.9250211},{"country":"Haiti","value":447.217315,"adj_value":542.7429335},{"country":"Dominican Republic","value":4603.684143,"adj_value":5587.031076},{"country":"Anguilla","value":3.754737,"adj_value":4.556748823},{"country":"British Virgin Islands","value":33.579607,"adj_value":40.75221106},{"country":"St Kitts and Nevis","value":49.718541,"adj_value":60.33842136},{"country":"Antigua and Barbuda","value":4.414365,"adj_value":5.357273364},{"country":"Montserrat","value":0.953906,"adj_value":1.157660322},{"country":"Dominica","value":3.344243,"adj_value":4.058573305},{"country":"St Lucia","value":32.396909,"adj_value":39.31688876},{"country":"St Vincent and the Grenadines","value":15.650342,"adj_value":18.99325505},{"country":"Grenada","value":5.852881,"adj_value":7.103056382},{"country":"Barbados","value":31.903789,"adj_value":38.71843833},{"country":"Trinidad and Tobago","value":7890.88378,"adj_value":9576.376555},{"country":"Netherlands Antilles","value":922.413941,"adj_value":1119.441559},{"country":"Aruba","value":2919.735672,"adj_value":3543.391212},{"country":"Guadeloupe","value":2.128806,"adj_value":2.583518962},{"country":"Martinique","value":22.236488,"adj_value":26.98620184}]},{"continent":"South America","children":[{"country":"Colombia","value":8849.380048,"adj_value":10739.60763},{"country":"Venezuela","value":33978.13481,"adj_value":41235.8644},{"country":"Guyana","value":119.931261,"adj_value":145.5485783},{"country":"Suriname","value":165.346376,"adj_value":200.6643619},{"country":"French Guiana","value":0.121285,"adj_value":0.147191476},{"country":"Ecuador","value":5758.679346,"adj_value":6988.733254},{"country":"Peru","value":5119.15577,"adj_value":6212.607442},{"country":"Bolivia","value":293.216045,"adj_value":355.8469922},{"country":"Chile","value":6664.333836,"adj_value":8087.835543},{"country":"Brazil","value":24435.51938,"adj_value":29654.94632},{"country":"Paraguay","value":51.645596,"adj_value":62.67709531},{"country":"Uruguay","value":732.311644,"adj_value":888.7334112},{"country":"Argentina","value":4583.613305,"adj_value":5562.673107},{"country":"Falkland Islands(Islas Malvin","value":9.261546,"adj_value":11.23981223}]},{"continent":"Europe","children":[{"country":"Iceland","value":268.97508,"adj_value":326.4281571},{"country":"Sweden","value":13820.97724,"adj_value":16773.13798},{"country":"Svalbard, Jan Mayen Island","value":0.039576,"adj_value":0.048029434},{"country":"Norway","value":6776.30892,"adj_value":8223.728505},{"country":"Finland","value":4341.679942,"adj_value":5269.062778},{"country":"Faroe Islands","value":4.276273,"adj_value":5.189684913},{"country":"Denmark","value":5144.20165,"adj_value":6243.003122},{"country":"United Kingdom","value":51032.62111,"adj_value":61933.18897},{"country":"Ireland","value":28733.08026,"adj_value":34870.4662},{"country":"Netherlands","value":14862.04151,"adj_value":18036.57358},{"country":"Belgium","value":13022.90274,"adj_value":15804.59477},{"country":"Luxembourg","value":388.834493,"adj_value":471.8895407},{"country":"Andorra","value":0.673148,"adj_value":0.816932413},{"country":"Monaco","value":37.485881,"adj_value":45.49286518},{"country":"France","value":33842.05751,"adj_value":41070.721},{"country":"Germany","value":84750.87138,"adj_value":102853.6575},{"country":"Austria","value":6102.944725,"adj_value":7406.533718},{"country":"Czech Republic","value":2192.863031,"adj_value":2661.258574},{"country":"Slovakia","value":960.730063,"adj_value":1165.942004},{"country":"Hungary","value":2561.172978,"adj_value":3108.239526},{"country":"Liechtenstein","value":295.705721,"adj_value":358.868463},{"country":"Switzerland","value":12999.88108,"adj_value":15776.65568},{"country":"Estonia","value":511.379949,"adj_value":620.6107061},{"country":"Latvia","value":362.159252,"adj_value":439.5164682},{"country":"Lithuania","value":633.912046,"adj_value":769.315659},{"country":"Poland","value":1948.58625,"adj_value":2364.804273},{"country":"Russia","value":15306.67384,"adj_value":18576.17937},{"country":"Belarus","value":345.161433,"adj_value":418.8879151},{"country":"Ukraine","value":1098.029235,"adj_value":1332.56828},{"country":"Armenia","value":46.191425,"adj_value":56.05791338},{"country":"Azerbaijan","value":45.361225,"adj_value":55.05038266},{"country":"Georgia","value":194.384289,"adj_value":235.9047731},{"country":"Kazakhstan","value":1101.145431,"adj_value":1336.350095},{"country":"Kyrgyzstan","value":4.618689,"adj_value":5.60524097},{"country":"Moldova","value":50.224656,"adj_value":60.95264252},{"country":"Tajikistan","value":241.029155,"adj_value":292.5129825},{"country":"Turkmenistan","value":135.325351,"adj_value":164.230846},{"country":"Uzbekistan","value":95.627811,"adj_value":116.0539114},{"country":"Spain","value":8614.64214,"adj_value":10454.7297},{"country":"Portugal","value":2328.674933,"adj_value":2826.079899},{"country":"Gibraltar","value":4.637081,"adj_value":5.627561502},{"country":"Malta","value":282.653662,"adj_value":343.0284842},{"country":"San Marino","value":1.389972,"adj_value":1.686870019},{"country":"Vatican City","value":0.282286,"adj_value":0.34258229},{"country":"Italy","value":31009.26008,"adj_value":37632.83803},{"country":"Croatia","value":364.277603,"adj_value":442.087299},{"country":"Slovenia","value":413.019469,"adj_value":501.2404276},{"country":"Bosnia and Herzegovina","value":70.462111,"adj_value":85.51281791},{"country":"Macedonia","value":48.149502,"adj_value":58.43423563},{"country":"Serbia and Montenegro","value":54.632827,"adj_value":66.30239885},{"country":"Albania","value":37.18875,"adj_value":45.132267},{"country":"Greece","value":883.73016,"adj_value":1072.494922},{"country":"Romania","value":1207.584718,"adj_value":1465.524814},{"country":"Bulgaria","value":454.262612,"adj_value":551.2931059}]},{"continent":"Asia","children":[{"country":"Turkey","value":5182.052179,"adj_value":6288.938524},{"country":"Cyprus","value":30.536194,"adj_value":37.05872504},{"country":"Syria","value":323.599119,"adj_value":392.7198908},{"country":"Lebanon","value":86.370988,"adj_value":104.819831},{"country":"Iraq","value":9053.695686,"adj_value":10987.56508},{"country":"Iran","value":174.457417,"adj_value":211.7215213},{"country":"Israel","value":16830.46608,"adj_value":20425.45364},{"country":"Gaza Strip admin. by Israel","value":1.443661,"adj_value":1.75202699},{"country":"West Bank admin. by Israel","value":1.604198,"adj_value":1.946854693},{"country":"Jordan","value":1266.84986,"adj_value":1537.44899},{"country":"Kuwait","value":4334.781445,"adj_value":5260.690762},{"country":"Saudi Arabia","value":27192.64204,"adj_value":33000.99038},{"country":"Qatar","value":447.861094,"adj_value":543.5242237},{"country":"United Arab Emirates","value":1468.316627,"adj_value":1781.949059},{"country":"Republic of Yemen","value":278.635079,"adj_value":338.1515319},{"country":"Oman","value":555.043525,"adj_value":673.6008219},{"country":"Bahrain","value":431.61192,"adj_value":523.8042261},{"country":"Afghanistan","value":67.310191,"adj_value":81.6876478},{"country":"India","value":18804.16965,"adj_value":22820.74029},{"country":"Pakistan","value":3253.181975,"adj_value":3948.061645},{"country":"Nepal","value":111.212077,"adj_value":134.9669766},{"country":"Bangladesh","value":2693.035035,"adj_value":3268.267318},{"country":"Sri Lanka","value":2082.938898,"adj_value":2527.854647},{"country":"Burma","value":0.0615,"adj_value":0.0746364},{"country":"Thailand","value":19889.75578,"adj_value":24138.20761},{"country":"Vietnam","value":6631.158734,"adj_value":8047.57424},{"country":"Laos","value":4.166156,"adj_value":5.056046922},{"country":"Cambodia","value":1766.956953,"adj_value":2144.378958},{"country":"Malaysia","value":33685.15957,"adj_value":40880.30965},{"country":"Singapore","value":15110.08962,"adj_value":18337.60477},{"country":"Indonesia","value":12014.34419,"adj_value":14580.6081},{"country":"East Timor","value":0.084963,"adj_value":0.103111097},{"country":"Brunei","value":562.742346,"adj_value":682.9441111},{"country":"Philippines","value":9250.433389,"adj_value":11226.32596},{"country":"Macau","value":1249.02212,"adj_value":1515.813245},{"country":"Bhutan","value":0.615516,"adj_value":0.746990218},{"country":"Maldives","value":5.496456,"adj_value":6.670499002},{"country":"China","value":243470.1048,"adj_value":295475.3192},{"country":"Mongolia","value":143.645404,"adj_value":174.3280623},{"country":"Korea, North","value":0.003252,"adj_value":0.003946627},{"country":"Korea, South","value":43781.44106,"adj_value":53133.15687},{"country":"Hong Kong","value":8891.705575,"adj_value":10790.97389},{"country":"Taiwan","value":34825.82882,"adj_value":42264.62586},{"country":"Japan","value":138003.6962,"adj_value":167481.2857}]},{"continent":"Australia","children":[{"country":"Australia","value":7342.17895,"adj_value":8910.468374},{"country":"Norfolk Island","value":0.17315,"adj_value":0.21013484},{"country":"Cocos (Keeling) Islands","value":0.484315,"adj_value":0.587764684},{"country":"Christmas Island","value":0.417613,"adj_value":0.506815137},{"country":"Heard and McDonald Islands","value":0.016396,"adj_value":0.019898186},{"country":"Papua New Guinea","value":58.451246,"adj_value":70.93643215},{"country":"New Zealand","value":3155.239797,"adj_value":3829.199018},{"country":"Cook Islands","value":1.744825,"adj_value":2.11751962},{"country":"Tokelau","value":10.800762,"adj_value":13.10780476},{"country":"Niue","value":0.138878,"adj_value":0.168542341},{"country":"Samoa","value":7.937575,"adj_value":9.63304102},{"country":"Solomon Islands","value":1.351564,"adj_value":1.64025807},{"country":"Vanuatu","value":2.489141,"adj_value":3.020821518},{"country":"Pitcairn Islands","value":1.040512,"adj_value":1.262765363},{"country":"Kiribati","value":1.104581,"adj_value":1.340519502},{"country":"Tuvalu","value":0.056868,"adj_value":0.069015005},{"country":"New Caledonia","value":27.174251,"adj_value":32.97867101},{"country":"Wallis and Futuna","value":0.022469,"adj_value":0.027268378},{"country":"French Polynesia","value":60.124235,"adj_value":72.9667716},{"country":"Marshall Islands","value":17.205126,"adj_value":20.88014091},{"country":"Micronesia","value":1.557731,"adj_value":1.890462342},{"country":"Palau","value":0.484544,"adj_value":0.588042598},{"country":"Nauru","value":0.148786,"adj_value":0.18056669},{"country":"Fiji","value":169.460711,"adj_value":205.6575189},{"country":"Tonga","value":5.350431,"adj_value":6.493283062}]},{"continent":"Africa","children":[{"country":"Morocco","value":445.793996,"adj_value":541.0155935},{"country":"Algeria","value":10446.43785,"adj_value":12677.79698},{"country":"Tunisia","value":263.768113,"adj_value":320.1089819},{"country":"Libya","value":1590.341099,"adj_value":1930.037958},{"country":"Egypt","value":2091.236887,"adj_value":2537.925086},{"country":"Sudan","value":13.574271,"adj_value":16.47373529},{"country":"Western Sahara","value":0,"adj_value":0},{"country":"Equatorial Guinea","value":1561.137497,"adj_value":1894.596466},{"country":"Mauritania","value":0.825319,"adj_value":1.001607138},{"country":"Cameroon","value":158.161864,"adj_value":191.9452382},{"country":"Senegal","value":3.662962,"adj_value":4.445370683},{"country":"Mali","value":3.649953,"adj_value":4.429582961},{"country":"Guinea","value":74.733573,"adj_value":90.69666419},{"country":"Sierra Leone","value":9.312822,"adj_value":11.30204078},{"country":"Cote d'Ivoire","value":1197.97516,"adj_value":1453.862654},{"country":"Ghana","value":158.409617,"adj_value":192.2459112},{"country":"Gambia","value":0.427153,"adj_value":0.518392881},{"country":"Niger","value":65.51339,"adj_value":79.5070501},{"country":"Togo","value":6.439273,"adj_value":7.814701713},{"country":"Nigeria","value":24239.35673,"adj_value":29416.88333},{"country":"Central African Republic","value":5.696947,"adj_value":6.913814879},{"country":"Gabon","value":2815.602273,"adj_value":3417.014919},{"country":"Chad","value":1498.086294,"adj_value":1818.077526},{"country":"St Helena","value":3.269267,"adj_value":3.967582431},{"country":"Burkina Faso","value":2.084203,"adj_value":2.529388761},{"country":"Benin","value":0.513184,"adj_value":0.622800102},{"country":"Angola","value":8484.361601,"adj_value":10296.62124},{"country":"Congo (Brazzaville)","value":1622.90154,"adj_value":1969.553309},{"country":"Guinea-Bissau","value":0.120677,"adj_value":0.146453607},{"country":"Cabo Verde","value":2.62425,"adj_value":3.1847898},{"country":"Sao Tome and Principe","value":0.216017,"adj_value":0.262158231},{"country":"Liberia","value":90.827263,"adj_value":110.2279664},{"country":"Congo (Kinshasa)","value":263.558216,"adj_value":319.8542509},{"country":"Burundi","value":4.423229,"adj_value":5.368030714},{"country":"Rwanda","value":6.301468,"adj_value":7.647461565},{"country":"Somalia","value":0.307638,"adj_value":0.373349477},{"country":"Eritrea","value":1.269401,"adj_value":1.540545054},{"country":"Ethiopia","value":61.802253,"adj_value":75.00321424},{"country":"Djibouti","value":1.101206,"adj_value":1.336423602},{"country":"Uganda","value":25.769069,"adj_value":31.27334214},{"country":"Kenya","value":348.019269,"adj_value":422.3561849},{"country":"Seychelles","value":5.883749,"adj_value":7.140517786},{"country":"British Indian Ocean Terr.","value":0.432984,"adj_value":0.525469382},{"country":"Tanzania","value":33.695475,"adj_value":40.89282846},{"country":"Mauritius","value":221.85071,"adj_value":269.2380217},{"country":"Mozambique","value":11.905754,"adj_value":14.44882305},{"country":"Madagascar","value":323.631165,"adj_value":392.7587818},{"country":"Comoros","value":1.447044,"adj_value":1.756132598},{"country":"Reunion","value":5.835528,"adj_value":7.081996781},{"country":"French Southern and Antarctic","value":0.05164,"adj_value":0.062670304},{"country":"South Africa","value":5885.639948,"adj_value":7142.812641},{"country":"Namibia","value":129.590672,"adj_value":157.2712395},{"country":"Botswana","value":178.164424,"adj_value":216.220345},{"country":"Zambia","value":31.70289,"adj_value":38.4746273},{"country":"Swaziland","value":198.886296,"adj_value":241.3684088},{"country":"Zimbabwe","value":94.328983,"adj_value":114.4776538},{"country":"Malawi","value":115.50192,"adj_value":140.1731301},{"country":"Lesotho","value":403.608048,"adj_value":489.8187271}]}]},{"type":"Exports","children":[{"continent":"North America","children":[{"country":"Greenland","value":5.085009,"adj_value":6.171166922},{"country":"Canada","value":211898.6894,"adj_value":257160.2494},{"country":"St Pierre and Miquelon","value":0.980031,"adj_value":1.189365622},{"country":"Mexico","value":120247.5801,"adj_value":145932.4633},{"country":"Guatemala","value":2835.38039,"adj_value":3441.017641},{"country":"Belize","value":217.562773,"adj_value":264.0341813},{"country":"El Salvador","value":1854.286657,"adj_value":2250.362287},{"country":"Honduras","value":3253.813808,"adj_value":3948.828437},{"country":"Nicaragua","value":625.460463,"adj_value":759.0588179},{"country":"Costa Rica","value":3598.560177,"adj_value":4367.212631},{"country":"Panama","value":2162.020485,"adj_value":2623.828061},{"country":"Bermuda","value":490.497944,"adj_value":595.2683048},{"country":"Bahamas","value":1786.740047,"adj_value":2168.387721},{"country":"Cuba","value":369.034678,"adj_value":447.8604852},{"country":"Jamaica","value":1700.769277,"adj_value":2064.053595},{"country":"Turks and Caicos Islands","value":237.752693,"adj_value":288.5366682},{"country":"Cayman Islands","value":680.670387,"adj_value":826.0615817},{"country":"Haiti","value":709.620597,"adj_value":861.1955565},{"country":"Dominican Republic","value":4718.733392,"adj_value":5726.654845},{"country":"Anguilla","value":32.186758,"adj_value":39.06184951},{"country":"British Virgin Islands","value":124.856685,"adj_value":151.5260729},{"country":"St Kitts and Nevis","value":94.069439,"adj_value":114.1626712},{"country":"Antigua and Barbuda","value":190.447421,"adj_value":231.1269901},{"country":"Montserrat","value":4.848606,"adj_value":5.884268242},{"country":"Dominica","value":61.540001,"adj_value":74.68494521},{"country":"St Lucia","value":135.389135,"adj_value":164.3082542},{"country":"St Vincent and the Grenadines","value":45.411401,"adj_value":55.11127625},{"country":"Grenada","value":82.440305,"adj_value":100.0495541},{"country":"Barbados","value":394.92009,"adj_value":479.2750212},{"country":"Trinidad and Tobago","value":1416.748479,"adj_value":1719.365954},{"country":"Netherlands Antilles","value":1137.633614,"adj_value":1380.632154},{"country":"Aruba","value":558.924451,"adj_value":678.3107137},{"country":"Guadeloupe","value":54.512655,"adj_value":66.15655811},{"country":"Martinique","value":34.95999,"adj_value":42.42744386}]},{"continent":"South America","children":[{"country":"Colombia","value":5462.357164,"adj_value":6629.116654},{"country":"Venezuela","value":6420.897723,"adj_value":7792.401477},{"country":"Guyana","value":176.704601,"adj_value":214.4487038},{"country":"Suriname","value":245.701079,"adj_value":298.1828295},{"country":"French Guiana","value":26.993942,"adj_value":32.75984801},{"country":"Ecuador","value":1963.825872,"adj_value":2383.299078},{"country":"Peru","value":2309.446378,"adj_value":2802.744124},{"country":"Bolivia","value":219.479092,"adj_value":266.3598261},{"country":"Chile","value":5133.523351,"adj_value":6230.043939},{"country":"Brazil","value":15371.71785,"adj_value":18655.11678},{"country":"Paraguay","value":895.819607,"adj_value":1087.166675},{"country":"Uruguay","value":356.676188,"adj_value":432.8622218},{"country":"Argentina","value":4121.861182,"adj_value":5002.29073},{"country":"Falkland Islands(Islas Malvin","value":9.049418,"adj_value":10.98237368}]},{"continent":"Europe","children":[{"country":"Iceland","value":512.019513,"adj_value":621.386881},{"country":"Sweden","value":3715.36862,"adj_value":4508.971357},{"country":"Svalbard, Jan Mayen Island","value":5.677609,"adj_value":6.890346282},{"country":"Norway","value":1941.882004,"adj_value":2356.668},{"country":"Finland","value":2254.052992,"adj_value":2735.518711},{"country":"Faroe Islands","value":2.528152,"adj_value":3.068165267},{"country":"Denmark","value":1918.423705,"adj_value":2328.199008},{"country":"United Kingdom","value":38568.08305,"adj_value":46806.22558},{"country":"Ireland","value":8446.771993,"adj_value":10251.00249},{"country":"Netherlands","value":26467.74458,"adj_value":32121.25482},{"country":"Belgium","value":18690.60657,"adj_value":22682.92013},{"country":"Luxembourg","value":711.38307,"adj_value":863.3344938},{"country":"Andorra","value":10.549473,"adj_value":12.80284043},{"country":"Monaco","value":16.776668,"adj_value":20.36016428},{"country":"France","value":22258.62805,"adj_value":27013.071},{"country":"Germany","value":34183.65627,"adj_value":41485.28525},{"country":"Austria","value":2544.481273,"adj_value":3087.982473},{"country":"Czech Republic","value":1053.557481,"adj_value":1278.597359},{"country":"Slovakia","value":149.800634,"adj_value":181.7980494},{"country":"Hungary","value":1023.258213,"adj_value":1241.826167},{"country":"Liechtenstein","value":19.7165,"adj_value":23.9279444},{"country":"Switzerland","value":10717.52806,"adj_value":13006.79206},{"country":"Estonia","value":145.425805,"adj_value":176.4887569},{"country":"Latvia","value":177.537085,"adj_value":215.4590064},{"country":"Lithuania","value":390.027824,"adj_value":473.3377672},{"country":"Poland","value":1267.748385,"adj_value":1538.53944},{"country":"Russia","value":3962.270261,"adj_value":4808.611189},{"country":"Belarus","value":34.942759,"adj_value":42.40653232},{"country":"Ukraine","value":532.954308,"adj_value":646.7933482},{"country":"Armenia","value":65.483218,"adj_value":79.47043336},{"country":"Azerbaijan","value":132.462798,"adj_value":160.7568517},{"country":"Georgia","value":213.886826,"adj_value":259.573052},{"country":"Kazakhstan","value":538.286932,"adj_value":653.2650207},{"country":"Kyrgyzstan","value":31.140901,"adj_value":37.79259745},{"country":"Moldova","value":40.069837,"adj_value":48.62875418},{"country":"Tajikistan","value":28.7867,"adj_value":34.93553912},{"country":"Turkmenistan","value":215.170092,"adj_value":261.1304237},{"country":"Uzbekistan","value":73.826609,"adj_value":89.59597268},{"country":"Spain","value":6839.116578,"adj_value":8299.951879},{"country":"Portugal","value":1131.865366,"adj_value":1373.631808},{"country":"Gibraltar","value":163.257568,"adj_value":198.1293845},{"country":"Malta","value":193.709217,"adj_value":235.0855058},{"country":"San Marino","value":4.676009,"adj_value":5.674804522},{"country":"Vatican City","value":24.181227,"adj_value":29.34633709},{"country":"Italy","value":11524.32529,"adj_value":13985.92117},{"country":"Croatia","value":158.621993,"adj_value":192.5036507},{"country":"Slovenia","value":233.830317,"adj_value":283.7764727},{"country":"Bosnia and Herzegovina","value":17.573793,"adj_value":21.32755518},{"country":"Macedonia","value":31.556267,"adj_value":38.29668563},{"country":"Serbia and Montenegro","value":132.49633,"adj_value":160.7975461},{"country":"Albania","value":18.513925,"adj_value":22.46849938},{"country":"Greece","value":1192.248494,"adj_value":1446.912772},{"country":"Romania","value":608.858767,"adj_value":738.9109996},{"country":"Bulgaria","value":267.93442,"adj_value":325.1652121}]},{"continent":"Asia","children":[{"country":"Turkey","value":4238.966194,"adj_value":5144.409373},{"country":"Cyprus","value":84.179247,"adj_value":102.1599342},{"country":"Syria","value":155.049379,"adj_value":188.1679264},{"country":"Lebanon","value":465.688546,"adj_value":565.1596194},{"country":"Iraq","value":1373.986265,"adj_value":1667.469731},{"country":"Iran","value":95.773068,"adj_value":116.2301953},{"country":"Israel","value":9737.340849,"adj_value":11817.23685},{"country":"Gaza Strip admin. by Israel","value":0.23112,"adj_value":0.280487232},{"country":"West Bank admin. by Israel","value":3.720993,"adj_value":4.515797105},{"country":"Jordan","value":644.195347,"adj_value":781.7954731},{"country":"Kuwait","value":1974.875551,"adj_value":2396.708969},{"country":"Saudi Arabia","value":6805.402418,"adj_value":8259.036374},{"country":"Qatar","value":986.642413,"adj_value":1197.389232},{"country":"United Arab Emirates","value":8119.527357,"adj_value":9853.8584},{"country":"Republic of Yemen","value":219.04852,"adj_value":265.8372839},{"country":"Oman","value":570.72512,"adj_value":692.6320056},{"country":"Bahrain","value":350.78451,"adj_value":425.7120813},{"country":"Afghanistan","value":262.153213,"adj_value":318.1491393},{"country":"India","value":7918.602428,"adj_value":9610.015907},{"country":"Pakistan","value":1251.63194,"adj_value":1518.980522},{"country":"Nepal","value":24.704668,"adj_value":29.98158508},{"country":"Bangladesh","value":319.769758,"adj_value":388.0725783},{"country":"Sri Lanka","value":197.631294,"adj_value":239.8453384},{"country":"Burma","value":5.464172,"adj_value":6.631319139},{"country":"Thailand","value":7256.616259,"adj_value":8806.629492},{"country":"Vietnam","value":1193.152202,"adj_value":1448.009512},{"country":"Laos","value":9.807849,"adj_value":11.90280555},{"country":"Cambodia","value":69.652929,"adj_value":84.53079463},{"country":"Malaysia","value":10460.83317,"adj_value":12695.26713},{"country":"Singapore","value":20466.07346,"adj_value":24837.62675},{"country":"Indonesia","value":3053.913961,"adj_value":3706.229983},{"country":"East Timor","value":8.685474,"adj_value":10.54069125},{"country":"Brunei","value":49.614155,"adj_value":60.21173851},{"country":"Philippines","value":6895.406023,"adj_value":8368.26475},{"country":"Macau","value":101.575899,"adj_value":123.272511},{"country":"Bhutan","value":3.05218,"adj_value":3.704125648},{"country":"Maldives","value":9.25555,"adj_value":11.23253548},{"country":"China","value":41192.01012,"adj_value":49990.62349},{"country":"Mongolia","value":21.879286,"adj_value":26.55270149},{"country":"Korea, North","value":5.757048,"adj_value":6.986753453},{"country":"Korea, South","value":27571.60598,"adj_value":33460.90101},{"country":"Hong Kong","value":16351.02861,"adj_value":19843.60832},{"country":"Taiwan","value":21614.49693,"adj_value":26231.35347},{"country":"Japan","value":54680.57985,"adj_value":66360.3517}]},{"continent":"Australia","children":[{"country":"Australia","value":15588.51968,"adj_value":18918.22748},{"country":"Norfolk Island","value":0.391532,"adj_value":0.475163235},{"country":"Cocos (Keeling) Islands","value":1.048051,"adj_value":1.271914694},{"country":"Christmas Island","value":2.00592,"adj_value":2.434384512},{"country":"Heard and McDonald Islands","value":0.160607,"adj_value":0.194912655},{"country":"Papua New Guinea","value":55.347872,"adj_value":67.17017746},{"country":"New Zealand","value":2592.076963,"adj_value":3145.744602},{"country":"Cook Islands","value":1.372809,"adj_value":1.666041002},{"country":"Tokelau","value":79.822527,"adj_value":96.87261877},{"country":"Niue","value":0.607643,"adj_value":0.737435545},{"country":"Samoa","value":14.538961,"adj_value":17.64448307},{"country":"Solomon Islands","value":2.297431,"adj_value":2.788162262},{"country":"Vanuatu","value":9.138578,"adj_value":11.09057826},{"country":"Pitcairn Islands","value":0.45629,"adj_value":0.553753544},{"country":"Kiribati","value":2.411608,"adj_value":2.926727469},{"country":"Tuvalu","value":0.04246,"adj_value":0.051529456},{"country":"New Caledonia","value":38.403106,"adj_value":46.60600944},{"country":"Wallis and Futuna","value":0.408737,"adj_value":0.496043223},{"country":"French Polynesia","value":111.838384,"adj_value":135.7270628},{"country":"Marshall Islands","value":75.48435,"adj_value":91.60780716},{"country":"Micronesia","value":25.349268,"adj_value":30.76387164},{"country":"Palau","value":12.22524,"adj_value":14.83655126},{"country":"Nauru","value":1.62475,"adj_value":1.9717966},{"country":"Fiji","value":28.177593,"adj_value":34.19632686},{"country":"Tonga","value":9.685131,"adj_value":11.75387498}]},{"continent":"Africa","children":[{"country":"Morocco","value":480.792527,"adj_value":583.4898108},{"country":"Algeria","value":1106.190448,"adj_value":1342.472728},{"country":"Tunisia","value":261.16652,"adj_value":316.9516887},{"country":"Libya","value":83.841985,"adj_value":101.750633},{"country":"Egypt","value":3159.259288,"adj_value":3834.077072},{"country":"Sudan","value":108.105454,"adj_value":131.196779},{"country":"Western Sahara","value":0.028656,"adj_value":0.034776922},{"country":"Equatorial Guinea","value":281.472431,"adj_value":341.5949423},{"country":"Mauritania","value":86.135221,"adj_value":104.5337042},{"country":"Cameroon","value":117.313887,"adj_value":142.3721333},{"country":"Senegal","value":141.499953,"adj_value":171.724343},{"country":"Mali","value":32.421928,"adj_value":39.34725182},{"country":"Guinea","value":93.59706,"adj_value":113.589392},{"country":"Sierra Leone","value":37.829353,"adj_value":45.9097028},{"country":"Cote d'Ivoire","value":124.242832,"adj_value":150.7811009},{"country":"Ghana","value":337.389713,"adj_value":409.4561557},{"country":"Gambia","value":30.604418,"adj_value":37.14152168},{"country":"Niger","value":78.511944,"adj_value":95.28209524},{"country":"Togo","value":27.928388,"adj_value":33.89389168},{"country":"Nigeria","value":1619.788459,"adj_value":1965.775274},{"country":"Central African Republic","value":14.781003,"adj_value":17.93822524},{"country":"Gabon","value":99.105857,"adj_value":120.2748681},{"country":"Chad","value":53.752155,"adj_value":65.23361531},{"country":"St Helena","value":2.732629,"adj_value":3.316318554},{"country":"Burkina Faso","value":25.11081,"adj_value":30.47447902},{"country":"Benin","value":72.278749,"adj_value":87.71748979},{"country":"Angola","value":929.046776,"adj_value":1127.491167},{"country":"Congo (Brazzaville)","value":104.056096,"adj_value":126.2824781},{"country":"Guinea-Bissau","value":2.100355,"adj_value":2.548990828},{"country":"Cabo Verde","value":9.871825,"adj_value":11.98044682},{"country":"Sao Tome and Principe","value":10.153283,"adj_value":12.32202425},{"country":"Liberia","value":69.32032,"adj_value":84.12714035},{"country":"Congo (Kinshasa)","value":64.968131,"adj_value":78.84532378},{"country":"Burundi","value":8.121178,"adj_value":9.855861621},{"country":"Rwanda","value":10.534162,"adj_value":12.784259},{"country":"Somalia","value":8.831504,"adj_value":10.71791325},{"country":"Eritrea","value":31.058711,"adj_value":37.69285167},{"country":"Ethiopia","value":455.635812,"adj_value":552.9596214},{"country":"Djibouti","value":47.571125,"adj_value":57.7323173},{"country":"Uganda","value":62.573652,"adj_value":75.93938407},{"country":"Kenya","value":573.365497,"adj_value":695.8363672},{"country":"Seychelles","value":17.912292,"adj_value":21.73835757},{"country":"British Indian Ocean Terr.","value":0.806112,"adj_value":0.978297523},{"country":"Tanzania","value":96.44391,"adj_value":117.0443292},{"country":"Mauritius","value":30.860179,"adj_value":37.45191323},{"country":"Mozambique","value":62.825299,"adj_value":76.24478287},{"country":"Madagascar","value":28.205237,"adj_value":34.22987562},{"country":"Comoros","value":0.295219,"adj_value":0.358277778},{"country":"Reunion","value":3.78591,"adj_value":4.594580376},{"country":"French Southern and Antarctic","value":0.273678,"adj_value":0.332135621},{"country":"South Africa","value":3906.946741,"adj_value":4741.470565},{"country":"Namibia","value":112.249178,"adj_value":136.2256024},{"country":"Botswana","value":67.272144,"adj_value":81.64147396},{"country":"Zambia","value":29.113109,"adj_value":35.33166908},{"country":"Swaziland","value":11.856893,"adj_value":14.38952534},{"country":"Zimbabwe","value":45.540976,"adj_value":55.26852847},{"country":"Malawi","value":28.049237,"adj_value":34.04055402},{"country":"Lesotho","value":4.015033,"adj_value":4.872644049}]}]}]},{"year":"2015","children":[{"type":"Imports","children":[{"continent":"North America","children":[{"country":"Greenland","value":3.800273,"adj_value":3.800273},{"country":"Canada","value":296155.599,"adj_value":296155.599},{"country":"St Pierre and Miquelon","value":0.18562,"adj_value":0.18562},{"country":"Mexico","value":296407.9011,"adj_value":296407.9011},{"country":"Guatemala","value":4120.351959,"adj_value":4120.351959},{"country":"Belize","value":75.287339,"adj_value":75.287339},{"country":"El Salvador","value":2531.699424,"adj_value":2531.699424},{"country":"Honduras","value":4755.934545,"adj_value":4755.934545},{"country":"Nicaragua","value":3188.301535,"adj_value":3188.301535},{"country":"Costa Rica","value":4488.341429,"adj_value":4488.341429},{"country":"Panama","value":408.293396,"adj_value":408.293396},{"country":"Bermuda","value":108.704684,"adj_value":108.704684},{"country":"Bahamas","value":452.744256,"adj_value":452.744256},{"country":"Cuba","value":0,"adj_value":0},{"country":"Jamaica","value":305.978402,"adj_value":305.978402},{"country":"Turks and Caicos Islands","value":14.710225,"adj_value":14.710225},{"country":"Cayman Islands","value":97.496341,"adj_value":97.496341},{"country":"Haiti","value":950.091535,"adj_value":950.091535},{"country":"Dominican Republic","value":4665.266745,"adj_value":4665.266745},{"country":"Anguilla","value":5.583883,"adj_value":5.583883},{"country":"British Virgin Islands","value":16.491398,"adj_value":16.491398},{"country":"St Kitts and Nevis","value":56.753359,"adj_value":56.753359},{"country":"Antigua and Barbuda","value":6.856395,"adj_value":6.856395},{"country":"Montserrat","value":2.271534,"adj_value":2.271534},{"country":"Dominica","value":1.683203,"adj_value":1.683203},{"country":"St Lucia","value":29.00446,"adj_value":29.00446},{"country":"St Vincent and the Grenadines","value":1.768076,"adj_value":1.768076},{"country":"Grenada","value":9.215032,"adj_value":9.215032},{"country":"Barbados","value":68.174291,"adj_value":68.174291},{"country":"Trinidad and Tobago","value":4314.344265,"adj_value":4314.344265},{"country":"Sint Maarten","value":51.873445,"adj_value":51.873445},{"country":"Curacao","value":335.229109,"adj_value":335.229109},{"country":"Aruba","value":54.90185,"adj_value":54.90185},{"country":"Guadeloupe","value":4.123528,"adj_value":4.123528},{"country":"Martinique","value":37.46278,"adj_value":37.46278}]},{"continent":"South America","children":[{"country":"Colombia","value":14074.81661,"adj_value":14074.81661},{"country":"Venezuela","value":15564.23275,"adj_value":15564.23275},{"country":"Guyana","value":431.099884,"adj_value":431.099884},{"country":"Suriname","value":146.224404,"adj_value":146.224404},{"country":"French Guiana","value":0.042924,"adj_value":0.042924},{"country":"Ecuador","value":7467.258698,"adj_value":7467.258698},{"country":"Peru","value":5053.337195,"adj_value":5053.337195},{"country":"Bolivia","value":1006.481438,"adj_value":1006.481438},{"country":"Chile","value":8772.414027,"adj_value":8772.414027},{"country":"Brazil","value":27468.23032,"adj_value":27468.23032},{"country":"Paraguay","value":162.023098,"adj_value":162.023098},{"country":"Uruguay","value":604.746068,"adj_value":604.746068},{"country":"Argentina","value":3950.849545,"adj_value":3950.849545},{"country":"Falkland Islands(Islas Malvin","value":14.273948,"adj_value":14.273948}]},{"continent":"Europe","children":[{"country":"Iceland","value":316.534176,"adj_value":316.534176},{"country":"Sweden","value":9878.966413,"adj_value":9878.966413},{"country":"Svalbard, Jan Mayen Island","value":0.028231,"adj_value":0.028231},{"country":"Norway","value":4760.200206,"adj_value":4760.200206},{"country":"Finland","value":4506.071121,"adj_value":4506.071121},{"country":"Faroe Islands","value":97.897991,"adj_value":97.897991},{"country":"Denmark","value":7760.022813,"adj_value":7760.022813},{"country":"United Kingdom","value":57962.25131,"adj_value":57962.25131},{"country":"Ireland","value":39336.18067,"adj_value":39336.18067},{"country":"Netherlands","value":16835.61486,"adj_value":16835.61486},{"country":"Belgium","value":19482.27263,"adj_value":19482.27263},{"country":"Luxembourg","value":639.038795,"adj_value":639.038795},{"country":"Andorra","value":4.863157,"adj_value":4.863157},{"country":"Monaco","value":58.818337,"adj_value":58.818337},{"country":"France","value":47815.32286,"adj_value":47815.32286},{"country":"Germany","value":124820.4692,"adj_value":124820.4692},{"country":"Austria","value":11311.97506,"adj_value":11311.97506},{"country":"Czech Republic","value":4497.634904,"adj_value":4497.634904},{"country":"Slovakia","value":2299.822999,"adj_value":2299.822999},{"country":"Hungary","value":5721.266311,"adj_value":5721.266311},{"country":"Liechtenstein","value":310.294941,"adj_value":310.294941},{"country":"Switzerland","value":31396.66041,"adj_value":31396.66041},{"country":"Estonia","value":503.50072,"adj_value":503.50072},{"country":"Latvia","value":302.969587,"adj_value":302.969587},{"country":"Lithuania","value":1059.366349,"adj_value":1059.366349},{"country":"Poland","value":5637.927607,"adj_value":5637.927607},{"country":"Russia","value":16366.16158,"adj_value":16366.16158},{"country":"Belarus","value":158.249733,"adj_value":158.249733},{"country":"Ukraine","value":850.788858,"adj_value":850.788858},{"country":"Armenia","value":62.46349,"adj_value":62.46349},{"country":"Azerbaijan","value":507.148173,"adj_value":507.148173},{"country":"Georgia","value":181.150349,"adj_value":181.150349},{"country":"Kazakhstan","value":816.099815,"adj_value":816.099815},{"country":"Kyrgyzstan","value":15.803561,"adj_value":15.803561},{"country":"Moldova","value":43.920552,"adj_value":43.920552},{"country":"Tajikistan","value":31.123801,"adj_value":31.123801},{"country":"Turkmenistan","value":55.976778,"adj_value":55.976778},{"country":"Uzbekistan","value":9.715446,"adj_value":9.715446},{"country":"Spain","value":14129.84151,"adj_value":14129.84151},{"country":"Portugal","value":3271.009123,"adj_value":3271.009123},{"country":"Gibraltar","value":1.82442,"adj_value":1.82442},{"country":"Malta","value":241.219869,"adj_value":241.219869},{"country":"San Marino","value":8.517198,"adj_value":8.517198},{"country":"Vatican City","value":1.218395,"adj_value":1.218395},{"country":"Italy","value":44159.01154,"adj_value":44159.01154},{"country":"Croatia","value":576.891578,"adj_value":576.891578},{"country":"Slovenia","value":678.110689,"adj_value":678.110689},{"country":"Bosnia and Herzegovina","value":78.282267,"adj_value":78.282267},{"country":"Macedonia","value":203.357353,"adj_value":203.357353},{"country":"Serbia","value":272.617662,"adj_value":272.617662},{"country":"Kosovo","value":2.38298,"adj_value":2.38298},{"country":"Montenegro","value":2.108687,"adj_value":2.108687},{"country":"Albania","value":160.081219,"adj_value":160.081219},{"country":"Greece","value":1356.447796,"adj_value":1356.447796},{"country":"Romania","value":2148.841567,"adj_value":2148.841567},{"country":"Bulgaria","value":597.694693,"adj_value":597.694693}]},{"continent":"Asia","children":[{"country":"Turkey","value":7880.91386,"adj_value":7880.91386},{"country":"Cyprus","value":31.98822,"adj_value":31.98822},{"country":"Syria","value":6.544106,"adj_value":6.544106},{"country":"Lebanon","value":93.219618,"adj_value":93.219618},{"country":"Iraq","value":4353.472677,"adj_value":4353.472677},{"country":"Iran","value":10.766314,"adj_value":10.766314},{"country":"Israel","value":24477.02161,"adj_value":24477.02161},{"country":"Gaza Strip admin. by Israel","value":0.012534,"adj_value":0.012534},{"country":"West Bank admin. by Israel","value":5.435229,"adj_value":5.435229},{"country":"Jordan","value":1491.618691,"adj_value":1491.618691},{"country":"Kuwait","value":4684.750276,"adj_value":4684.750276},{"country":"Saudi Arabia","value":22080.78482,"adj_value":22080.78482},{"country":"Qatar","value":1354.237789,"adj_value":1354.237789},{"country":"United Arab Emirates","value":2468.033306,"adj_value":2468.033306},{"country":"Republic of Yemen","value":48.270876,"adj_value":48.270876},{"country":"Oman","value":906.993161,"adj_value":906.993161},{"country":"Bahrain","value":902.425581,"adj_value":902.425581},{"country":"Afghanistan","value":23.454045,"adj_value":23.454045},{"country":"India","value":44791.64405,"adj_value":44791.64405},{"country":"Pakistan","value":3701.018609,"adj_value":3701.018609},{"country":"Nepal","value":86.959805,"adj_value":86.959805},{"country":"Bangladesh","value":5991.251839,"adj_value":5991.251839},{"country":"Sri Lanka","value":2889.92219,"adj_value":2889.92219},{"country":"Burma","value":143.796881,"adj_value":143.796881},{"country":"Thailand","value":28631.93281,"adj_value":28631.93281},{"country":"Vietnam","value":38019.69623,"adj_value":38019.69623},{"country":"Laos","value":45.189001,"adj_value":45.189001},{"country":"Cambodia","value":3025.433126,"adj_value":3025.433126},{"country":"Malaysia","value":33970.67872,"adj_value":33970.67872},{"country":"Singapore","value":18267.48494,"adj_value":18267.48494},{"country":"Indonesia","value":19601.54814,"adj_value":19601.54814},{"country":"East Timor","value":3.302038,"adj_value":3.302038},{"country":"Brunei","value":19.402766,"adj_value":19.402766},{"country":"Philippines","value":10233.69067,"adj_value":10233.69067},{"country":"Macau","value":121.919528,"adj_value":121.919528},{"country":"Bhutan","value":3.398158,"adj_value":3.398158},{"country":"Maldives","value":21.737873,"adj_value":21.737873},{"country":"China","value":483244.7019,"adj_value":483244.7019},{"country":"Mongolia","value":17.222375,"adj_value":17.222375},{"country":"Korea, North","value":0,"adj_value":0},{"country":"Korea, South","value":71758.69672,"adj_value":71758.69672},{"country":"Hong Kong","value":6795.630644,"adj_value":6795.630644},{"country":"Taiwan","value":40907.5936,"adj_value":40907.5936},{"country":"Japan","value":131364.1476,"adj_value":131364.1476}]},{"continent":"Australia","children":[{"country":"Australia","value":10894.02186,"adj_value":10894.02186},{"country":"Norfolk Island","value":1.217241,"adj_value":1.217241},{"country":"Cocos (Keeling) Islands","value":3.809085,"adj_value":3.809085},{"country":"Christmas Island","value":2.12084,"adj_value":2.12084},{"country":"Heard and McDonald Islands","value":0.006734,"adj_value":0.006734},{"country":"Papua New Guinea","value":90.809528,"adj_value":90.809528},{"country":"New Zealand","value":4292.770709,"adj_value":4292.770709},{"country":"Cook Islands","value":0.84788,"adj_value":0.84788},{"country":"Tokelau","value":1.848379,"adj_value":1.848379},{"country":"Niue","value":0.531806,"adj_value":0.531806},{"country":"Samoa","value":4.220542,"adj_value":4.220542},{"country":"Solomon Islands","value":3.521953,"adj_value":3.521953},{"country":"Vanuatu","value":3.67132,"adj_value":3.67132},{"country":"Pitcairn Islands","value":0.012162,"adj_value":0.012162},{"country":"Kiribati","value":2.728752,"adj_value":2.728752},{"country":"Tuvalu","value":0.228118,"adj_value":0.228118},{"country":"New Caledonia","value":47.038156,"adj_value":47.038156},{"country":"Wallis and Futuna","value":0.093303,"adj_value":0.093303},{"country":"French Polynesia","value":43.030557,"adj_value":43.030557},{"country":"Marshall Islands","value":29.067047,"adj_value":29.067047},{"country":"Micronesia","value":0.717108,"adj_value":0.717108},{"country":"Palau","value":0.544832,"adj_value":0.544832},{"country":"Nauru","value":0.52087,"adj_value":0.52087},{"country":"Fiji","value":202.639037,"adj_value":202.639037},{"country":"Tonga","value":2.442895,"adj_value":2.442895}]},{"continent":"Africa","children":[{"country":"Morocco","value":1011.85636,"adj_value":1011.85636},{"country":"Algeria","value":3371.552526,"adj_value":3371.552526},{"country":"Tunisia","value":546.271256,"adj_value":546.271256},{"country":"Libya","value":155.103895,"adj_value":155.103895},{"country":"Egypt","value":1405.853699,"adj_value":1405.853699},{"country":"Sudan","value":8.973253,"adj_value":8.973253},{"country":"South Sudan","value":0.192583,"adj_value":0.192583},{"country":"Western Sahara","value":0.044063,"adj_value":0.044063},{"country":"Equatorial Guinea","value":163.14305,"adj_value":163.14305},{"country":"Mauritania","value":1.173847,"adj_value":1.173847},{"country":"Cameroon","value":132.053379,"adj_value":132.053379},{"country":"Senegal","value":71.965108,"adj_value":71.965108},{"country":"Mali","value":4.504283,"adj_value":4.504283},{"country":"Guinea","value":79.616516,"adj_value":79.616516},{"country":"Sierra Leone","value":39.58921,"adj_value":39.58921},{"country":"Cote d'Ivoire","value":1027.88557,"adj_value":1027.88557},{"country":"Ghana","value":309.36766,"adj_value":309.36766},{"country":"Gambia","value":0.896754,"adj_value":0.896754},{"country":"Niger","value":4.184625,"adj_value":4.184625},{"country":"Togo","value":14.211452,"adj_value":14.211452},{"country":"Nigeria","value":1915.80016,"adj_value":1915.80016},{"country":"Central African Republic","value":3.12467,"adj_value":3.12467},{"country":"Gabon","value":337.024529,"adj_value":337.024529},{"country":"Chad","value":1303.322183,"adj_value":1303.322183},{"country":"St Helena","value":15.340188,"adj_value":15.340188},{"country":"Burkina Faso","value":3.592979,"adj_value":3.592979},{"country":"Benin","value":4.94488,"adj_value":4.94488},{"country":"Angola","value":2806.494883,"adj_value":2806.494883},{"country":"Congo (Brazzaville)","value":304.303884,"adj_value":304.303884},{"country":"Guinea-Bissau","value":0.05184,"adj_value":0.05184},{"country":"Cabo Verde","value":2.21905,"adj_value":2.21905},{"country":"Sao Tome and Principe","value":0.773369,"adj_value":0.773369},{"country":"Liberia","value":44.940717,"adj_value":44.940717},{"country":"Congo (Kinshasa)","value":153.738045,"adj_value":153.738045},{"country":"Burundi","value":8.427001,"adj_value":8.427001},{"country":"Rwanda","value":45.643909,"adj_value":45.643909},{"country":"Somalia","value":0.896112,"adj_value":0.896112},{"country":"Eritrea","value":0.106871,"adj_value":0.106871},{"country":"Ethiopia","value":310.269077,"adj_value":310.269077},{"country":"Djibouti","value":35.463684,"adj_value":35.463684},{"country":"Uganda","value":64.123855,"adj_value":64.123855},{"country":"Kenya","value":573.095415,"adj_value":573.095415},{"country":"Seychelles","value":5.83899,"adj_value":5.83899},{"country":"British Indian Ocean Terr.","value":15.818366,"adj_value":15.818366},{"country":"Tanzania","value":104.93518,"adj_value":104.93518},{"country":"Mauritius","value":395.664813,"adj_value":395.664813},{"country":"Mozambique","value":96.026702,"adj_value":96.026702},{"country":"Madagascar","value":319.783011,"adj_value":319.783011},{"country":"Mayotte","value":0.095927,"adj_value":0.095927},{"country":"Comoros","value":1.211821,"adj_value":1.211821},{"country":"Reunion","value":16.967288,"adj_value":16.967288},{"country":"French Southern and Antarctic","value":0.013953,"adj_value":0.013953},{"country":"South Africa","value":7314.612701,"adj_value":7314.612701},{"country":"Namibia","value":85.353831,"adj_value":85.353831},{"country":"Botswana","value":211.913954,"adj_value":211.913954},{"country":"Zambia","value":47.114386,"adj_value":47.114386},{"country":"Swaziland","value":21.49843,"adj_value":21.49843},{"country":"Zimbabwe","value":67.166669,"adj_value":67.166669},{"country":"Malawi","value":61.395881,"adj_value":61.395881},{"country":"Lesotho","value":331.955607,"adj_value":331.955607}]}]},{"type":"Exports","children":[{"continent":"North America","children":[{"country":"Greenland","value":8.076839,"adj_value":8.076839},{"country":"Canada","value":280609.0056,"adj_value":280609.0056},{"country":"St Pierre and Miquelon","value":0.227459,"adj_value":0.227459},{"country":"Mexico","value":235745.1375,"adj_value":235745.1375},{"country":"Guatemala","value":5806.713895,"adj_value":5806.713895},{"country":"Belize","value":285.240264,"adj_value":285.240264},{"country":"El Salvador","value":3240.284878,"adj_value":3240.284878},{"country":"Honduras","value":5214.668234,"adj_value":5214.668234},{"country":"Nicaragua","value":1267.532561,"adj_value":1267.532561},{"country":"Costa Rica","value":6079.415736,"adj_value":6079.415736},{"country":"Panama","value":7663.548283,"adj_value":7663.548283},{"country":"Bermuda","value":600.945255,"adj_value":600.945255},{"country":"Bahamas","value":2386.461864,"adj_value":2386.461864},{"country":"Cuba","value":180.215206,"adj_value":180.215206},{"country":"Jamaica","value":1716.030814,"adj_value":1716.030814},{"country":"Turks and Caicos Islands","value":279.728597,"adj_value":279.728597},{"country":"Cayman Islands","value":684.947958,"adj_value":684.947958},{"country":"Haiti","value":1140.574185,"adj_value":1140.574185},{"country":"Dominican Republic","value":7113.829302,"adj_value":7113.829302},{"country":"Anguilla","value":47.602633,"adj_value":47.602633},{"country":"British Virgin Islands","value":259.758571,"adj_value":259.758571},{"country":"St Kitts and Nevis","value":149.707108,"adj_value":149.707108},{"country":"Antigua and Barbuda","value":677.657633,"adj_value":677.657633},{"country":"Montserrat","value":6.640011,"adj_value":6.640011},{"country":"Dominica","value":67.312046,"adj_value":67.312046},{"country":"St Lucia","value":510.811024,"adj_value":510.811024},{"country":"St Vincent and the Grenadines","value":84.722498,"adj_value":84.722498},{"country":"Grenada","value":90.420149,"adj_value":90.420149},{"country":"Barbados","value":595.966307,"adj_value":595.966307},{"country":"Trinidad and Tobago","value":2511.195111,"adj_value":2511.195111},{"country":"Sint Maarten","value":741.201231,"adj_value":741.201231},{"country":"Curacao","value":522.079698,"adj_value":522.079698},{"country":"Aruba","value":1167.632524,"adj_value":1167.632524},{"country":"Guadeloupe","value":100.959536,"adj_value":100.959536},{"country":"Martinique","value":119.577165,"adj_value":119.577165}]},{"continent":"South America","children":[{"country":"Colombia","value":16286.7799,"adj_value":16286.7799},{"country":"Venezuela","value":8345.880233,"adj_value":8345.880233},{"country":"Guyana","value":368.129666,"adj_value":368.129666},{"country":"Suriname","value":443.643313,"adj_value":443.643313},{"country":"French Guiana","value":1073.642767,"adj_value":1073.642767},{"country":"Ecuador","value":5794.812688,"adj_value":5794.812688},{"country":"Peru","value":8725.607473,"adj_value":8725.607473},{"country":"Bolivia","value":931.431709,"adj_value":931.431709},{"country":"Chile","value":15445.13797,"adj_value":15445.13797},{"country":"Brazil","value":31650.62387,"adj_value":31650.62387},{"country":"Paraguay","value":1514.300292,"adj_value":1514.300292},{"country":"Uruguay","value":1295.148749,"adj_value":1295.148749},{"country":"Argentina","value":9341.210651,"adj_value":9341.210651},{"country":"Falkland Islands(Islas Malvin","value":2.917708,"adj_value":2.917708}]},{"continent":"Europe","children":[{"country":"Iceland","value":415.45785,"adj_value":415.45785},{"country":"Sweden","value":3940.8105,"adj_value":3940.8105},{"country":"Svalbard, Jan Mayen Island","value":0.380164,"adj_value":0.380164},{"country":"Norway","value":3570.63315,"adj_value":3570.63315},{"country":"Finland","value":1558.146898,"adj_value":1558.146898},{"country":"Faroe Islands","value":2.336863,"adj_value":2.336863},{"country":"Denmark","value":2202.093582,"adj_value":2202.093582},{"country":"United Kingdom","value":56114.61886,"adj_value":56114.61886},{"country":"Ireland","value":8930.773509,"adj_value":8930.773509},{"country":"Netherlands","value":40196.15629,"adj_value":40196.15629},{"country":"Belgium","value":34159.97966,"adj_value":34159.97966},{"country":"Luxembourg","value":1394.17473,"adj_value":1394.17473},{"country":"Andorra","value":3.336817,"adj_value":3.336817},{"country":"Monaco","value":71.128048,"adj_value":71.128048},{"country":"France","value":30103.5212,"adj_value":30103.5212},{"country":"Germany","value":49970.80411,"adj_value":49970.80411},{"country":"Austria","value":4024.435888,"adj_value":4024.435888},{"country":"Czech Republic","value":1976.037865,"adj_value":1976.037865},{"country":"Slovakia","value":379.469169,"adj_value":379.469169},{"country":"Hungary","value":1715.278037,"adj_value":1715.278037},{"country":"Liechtenstein","value":35.930552,"adj_value":35.930552},{"country":"Switzerland","value":22185.27991,"adj_value":22185.27991},{"country":"Estonia","value":288.143789,"adj_value":288.143789},{"country":"Latvia","value":294.787977,"adj_value":294.787977},{"country":"Lithuania","value":527.67763,"adj_value":527.67763},{"country":"Poland","value":3715.441301,"adj_value":3715.441301},{"country":"Russia","value":7087.111574,"adj_value":7087.111574},{"country":"Belarus","value":59.235752,"adj_value":59.235752},{"country":"Ukraine","value":862.088348,"adj_value":862.088348},{"country":"Armenia","value":50.24617,"adj_value":50.24617},{"country":"Azerbaijan","value":477.316108,"adj_value":477.316108},{"country":"Georgia","value":340.502111,"adj_value":340.502111},{"country":"Kazakhstan","value":510.479071,"adj_value":510.479071},{"country":"Kyrgyzstan","value":32.003481,"adj_value":32.003481},{"country":"Moldova","value":16.163682,"adj_value":16.163682},{"country":"Tajikistan","value":18.985373,"adj_value":18.985373},{"country":"Turkmenistan","value":80.839805,"adj_value":80.839805},{"country":"Uzbekistan","value":137.962928,"adj_value":137.962928},{"country":"Spain","value":10310.27052,"adj_value":10310.27052},{"country":"Portugal","value":942.466275,"adj_value":942.466275},{"country":"Gibraltar","value":1972.99261,"adj_value":1972.99261},{"country":"Malta","value":490.660579,"adj_value":490.660579},{"country":"San Marino","value":5.011879,"adj_value":5.011879},{"country":"Vatican City","value":2.226547,"adj_value":2.226547},{"country":"Italy","value":16204.22609,"adj_value":16204.22609},{"country":"Croatia","value":331.976272,"adj_value":331.976272},{"country":"Slovenia","value":346.040192,"adj_value":346.040192},{"country":"Bosnia and Herzegovina","value":27.586061,"adj_value":27.586061},{"country":"Macedonia","value":30.678977,"adj_value":30.678977},{"country":"Serbia","value":126.25142,"adj_value":126.25142},{"country":"Kosovo","value":19.743318,"adj_value":19.743318},{"country":"Montenegro","value":11.133957,"adj_value":11.133957},{"country":"Albania","value":30.952665,"adj_value":30.952665},{"country":"Greece","value":725.699147,"adj_value":725.699147},{"country":"Romania","value":753.718827,"adj_value":753.718827},{"country":"Bulgaria","value":289.09201,"adj_value":289.09201}]},{"continent":"Asia","children":[{"country":"Turkey","value":9502.498123,"adj_value":9502.498123},{"country":"Cyprus","value":101.831614,"adj_value":101.831614},{"country":"Syria","value":3.072304,"adj_value":3.072304},{"country":"Lebanon","value":1272.487166,"adj_value":1272.487166},{"country":"Iraq","value":1971.478767,"adj_value":1971.478767},{"country":"Iran","value":281.512074,"adj_value":281.512074},{"country":"Israel","value":13538.69482,"adj_value":13538.69482},{"country":"Gaza Strip admin. by Israel","value":0.183934,"adj_value":0.183934},{"country":"West Bank admin. by Israel","value":0.903282,"adj_value":0.903282},{"country":"Jordan","value":1358.977191,"adj_value":1358.977191},{"country":"Kuwait","value":2739.289578,"adj_value":2739.289578},{"country":"Saudi Arabia","value":19738.98459,"adj_value":19738.98459},{"country":"Qatar","value":4222.426394,"adj_value":4222.426394},{"country":"United Arab Emirates","value":23003.59562,"adj_value":23003.59562},{"country":"Republic of Yemen","value":158.039977,"adj_value":158.039977},{"country":"Oman","value":2355.271013,"adj_value":2355.271013},{"country":"Bahrain","value":1270.662445,"adj_value":1270.662445},{"country":"Afghanistan","value":478.851271,"adj_value":478.851271},{"country":"India","value":21451.87992,"adj_value":21451.87992},{"country":"Pakistan","value":1837.506933,"adj_value":1837.506933},{"country":"Nepal","value":36.405446,"adj_value":36.405446},{"country":"Bangladesh","value":942.540067,"adj_value":942.540067},{"country":"Sri Lanka","value":361.920786,"adj_value":361.920786},{"country":"Burma","value":227.140755,"adj_value":227.140755},{"country":"Thailand","value":11230.56974,"adj_value":11230.56974},{"country":"Vietnam","value":7087.524038,"adj_value":7087.524038},{"country":"Laos","value":24.584007,"adj_value":24.584007},{"country":"Cambodia","value":391.045876,"adj_value":391.045876},{"country":"Malaysia","value":12277.22614,"adj_value":12277.22614},{"country":"Singapore","value":28472.07098,"adj_value":28472.07098},{"country":"Indonesia","value":7120.940688,"adj_value":7120.940688},{"country":"East Timor","value":2.690584,"adj_value":2.690584},{"country":"Brunei","value":133.449998,"adj_value":133.449998},{"country":"Philippines","value":7907.893167,"adj_value":7907.893167},{"country":"Macau","value":542.354584,"adj_value":542.354584},{"country":"Bhutan","value":2.64104,"adj_value":2.64104},{"country":"Maldives","value":35.143208,"adj_value":35.143208},{"country":"China","value":116071.7696,"adj_value":116071.7696},{"country":"Mongolia","value":69.161103,"adj_value":69.161103},{"country":"Korea, North","value":4.751721,"adj_value":4.751721},{"country":"Korea, South","value":43445.54748,"adj_value":43445.54748},{"country":"Hong Kong","value":37167.02295,"adj_value":37167.02295},{"country":"Taiwan","value":25860.08634,"adj_value":25860.08634},{"country":"Japan","value":62442.64646,"adj_value":62442.64646}]},{"continent":"Australia","children":[{"country":"Australia","value":25035.79015,"adj_value":25035.79015},{"country":"Norfolk Island","value":0.350312,"adj_value":0.350312},{"country":"Cocos (Keeling) Islands","value":0.55762,"adj_value":0.55762},{"country":"Christmas Island","value":1.551179,"adj_value":1.551179},{"country":"Heard and McDonald Islands","value":0.913419,"adj_value":0.913419},{"country":"Papua New Guinea","value":207.793894,"adj_value":207.793894},{"country":"New Zealand","value":3631.061903,"adj_value":3631.061903},{"country":"Cook Islands","value":4.249826,"adj_value":4.249826},{"country":"Tokelau","value":0.341222,"adj_value":0.341222},{"country":"Niue","value":0.071371,"adj_value":0.071371},{"country":"Samoa","value":22.71966,"adj_value":22.71966},{"country":"Solomon Islands","value":5.861309,"adj_value":5.861309},{"country":"Vanuatu","value":5.867876,"adj_value":5.867876},{"country":"Pitcairn Islands","value":0.017405,"adj_value":0.017405},{"country":"Kiribati","value":7.320835,"adj_value":7.320835},{"country":"Tuvalu","value":0.625636,"adj_value":0.625636},{"country":"New Caledonia","value":88.651277,"adj_value":88.651277},{"country":"Wallis and Futuna","value":0.376841,"adj_value":0.376841},{"country":"French Polynesia","value":120.047865,"adj_value":120.047865},{"country":"Marshall Islands","value":53.912135,"adj_value":53.912135},{"country":"Micronesia","value":40.032614,"adj_value":40.032614},{"country":"Palau","value":25.693198,"adj_value":25.693198},{"country":"Nauru","value":1.73365,"adj_value":1.73365},{"country":"Fiji","value":56.904585,"adj_value":56.904585},{"country":"Tonga","value":13.817538,"adj_value":13.817538}]},{"continent":"Africa","children":[{"country":"Morocco","value":1625.204959,"adj_value":1625.204959},{"country":"Algeria","value":1875.734479,"adj_value":1875.734479},{"country":"Tunisia","value":602.412017,"adj_value":602.412017},{"country":"Libya","value":242.951645,"adj_value":242.951645},{"country":"Egypt","value":4752.983685,"adj_value":4752.983685},{"country":"Sudan","value":59.514997,"adj_value":59.514997},{"country":"South Sudan","value":19.613532,"adj_value":19.613532},{"country":"Western Sahara","value":0.032113,"adj_value":0.032113},{"country":"Equatorial Guinea","value":161.964373,"adj_value":161.964373},{"country":"Mauritania","value":126.280667,"adj_value":126.280667},{"country":"Cameroon","value":224.961698,"adj_value":224.961698},{"country":"Senegal","value":196.428411,"adj_value":196.428411},{"country":"Mali","value":72.426079,"adj_value":72.426079},{"country":"Guinea","value":135.350114,"adj_value":135.350114},{"country":"Sierra Leone","value":77.325724,"adj_value":77.325724},{"country":"Cote d'Ivoire","value":266.335569,"adj_value":266.335569},{"country":"Ghana","value":949.913963,"adj_value":949.913963},{"country":"Gambia","value":37.899622,"adj_value":37.899622},{"country":"Niger","value":71.493157,"adj_value":71.493157},{"country":"Togo","value":311.819809,"adj_value":311.819809},{"country":"Nigeria","value":3437.952784,"adj_value":3437.952784},{"country":"Central African Republic","value":34.309874,"adj_value":34.309874},{"country":"Gabon","value":203.872443,"adj_value":203.872443},{"country":"Chad","value":56.591528,"adj_value":56.591528},{"country":"St Helena","value":3.720487,"adj_value":3.720487},{"country":"Burkina Faso","value":53.875343,"adj_value":53.875343},{"country":"Benin","value":631.462518,"adj_value":631.462518},{"country":"Angola","value":1166.161667,"adj_value":1166.161667},{"country":"Congo (Brazzaville)","value":249.220232,"adj_value":249.220232},{"country":"Guinea-Bissau","value":2.13532,"adj_value":2.13532},{"country":"Cabo Verde","value":7.32166,"adj_value":7.32166},{"country":"Sao Tome and Principe","value":0.853963,"adj_value":0.853963},{"country":"Liberia","value":135.807551,"adj_value":135.807551},{"country":"Congo (Kinshasa)","value":136.189374,"adj_value":136.189374},{"country":"Burundi","value":5.650192,"adj_value":5.650192},{"country":"Rwanda","value":14.28771,"adj_value":14.28771},{"country":"Somalia","value":45.026584,"adj_value":45.026584},{"country":"Eritrea","value":3.497538,"adj_value":3.497538},{"country":"Ethiopia","value":1555.249376,"adj_value":1555.249376},{"country":"Djibouti","value":144.711021,"adj_value":144.711021},{"country":"Uganda","value":88.315069,"adj_value":88.315069},{"country":"Kenya","value":943.436657,"adj_value":943.436657},{"country":"Seychelles","value":18.542809,"adj_value":18.542809},{"country":"British Indian Ocean Terr.","value":0.581016,"adj_value":0.581016},{"country":"Tanzania","value":172.803054,"adj_value":172.803054},{"country":"Mauritius","value":58.435311,"adj_value":58.435311},{"country":"Mozambique","value":264.203995,"adj_value":264.203995},{"country":"Madagascar","value":54.553731,"adj_value":54.553731},{"country":"Mayotte","value":5.697333,"adj_value":5.697333},{"country":"Comoros","value":1.507078,"adj_value":1.507078},{"country":"Reunion","value":6.905271,"adj_value":6.905271},{"country":"French Southern and Antarctic","value":8.026602,"adj_value":8.026602},{"country":"South Africa","value":5458.29362,"adj_value":5458.29362},{"country":"Namibia","value":127.603603,"adj_value":127.603603},{"country":"Botswana","value":39.04197,"adj_value":39.04197},{"country":"Zambia","value":84.170835,"adj_value":84.170835},{"country":"Swaziland","value":28.521751,"adj_value":28.521751},{"country":"Zimbabwe","value":37.834783,"adj_value":37.834783},{"country":"Malawi","value":37.201602,"adj_value":37.201602},{"country":"Lesotho","value":0.881897,"adj_value":0.881897}]}]}]},{"year":"1985","children":[{"type":"Imports","children":[{"continent":"North America","children":[{"country":"Canada","value":69006.4,"adj_value":152007.2979},{"country":"Mexico","value":19131.7,"adj_value":42143.30876},{"country":"Guatemala","value":409,"adj_value":900.9452},{"country":"El Salvador","value":395.6,"adj_value":871.42768},{"country":"Honduras","value":375.4,"adj_value":826.93112},{"country":"Costa Rica","value":501.3,"adj_value":1104.26364},{"country":"Panama","value":410.6,"adj_value":904.46968},{"country":"Bahamas","value":626.3,"adj_value":1379.61364},{"country":"Jamaica","value":272.7,"adj_value":600.70356},{"country":"Haiti","value":389.6,"adj_value":858.21088},{"country":"Dominican Republic","value":982.3,"adj_value":2163.81044},{"country":"Trinidad and Tobago","value":1258.4,"adj_value":2772.00352},{"country":"Netherlands Antilles","value":808,"adj_value":1779.8624}]},{"continent":"South America","children":[{"country":"Colombia","value":1330.7,"adj_value":2931.26596},{"country":"Venezuela","value":6537.1,"adj_value":14399.92388},{"country":"Ecuador","value":1836.5,"adj_value":4045.4422},{"country":"Peru","value":1086.6,"adj_value":2393.56248},{"country":"Chile","value":745.2,"adj_value":1641.52656},{"country":"Brazil","value":7526.2,"adj_value":16578.71336},{"country":"Paraguay","value":23.6,"adj_value":51.98608},{"country":"Uruguay","value":556.6,"adj_value":1226.07848},{"country":"Argentina","value":1069.3,"adj_value":2355.45404}]},{"continent":"Europe","children":[{"country":"Iceland","value":247.8,"adj_value":545.85384},{"country":"Sweden","value":4123.7,"adj_value":9083.68636},{"country":"Norway","value":1164.3,"adj_value":2564.72004},{"country":"Finland","value":895.2,"adj_value":1971.94656},{"country":"Denmark","value":1664.4,"adj_value":3666.34032},{"country":"United Kingdom","value":14937.2,"adj_value":32903.66416},{"country":"Ireland","value":901.1,"adj_value":1984.94308},{"country":"Netherlands","value":4081.3,"adj_value":8990.28764},{"country":"Belgium","value":3355.2,"adj_value":7390.83456},{"country":"France","value":9482,"adj_value":20886.9496},{"country":"Germany","value":20239.2,"adj_value":44582.90976},{"country":"Austria","value":833.7,"adj_value":1836.47436},{"country":"Hungary","value":218.3,"adj_value":480.87124},{"country":"Switzerland","value":3476.1,"adj_value":7657.15308},{"country":"Poland","value":220.2,"adj_value":485.05656},{"country":"USSR","value":408.5,"adj_value":899.8438},{"country":"Spain","value":2515.2,"adj_value":5540.48256},{"country":"Portugal","value":546,"adj_value":1202.7288},{"country":"Italy","value":9673.8,"adj_value":21309.44664},{"country":"Yugoslavia (former)","value":542.2,"adj_value":1194.35816},{"country":"Greece","value":394.7,"adj_value":869.44516}]},{"continent":"Asia","children":[{"country":"Turkey","value":601.9,"adj_value":1325.86532},{"country":"Iran","value":725.1,"adj_value":1597.25028},{"country":"Israel","value":2122.5,"adj_value":4675.443},{"country":"Kuwait","value":184,"adj_value":405.3152},{"country":"Saudi Arabia","value":1907.1,"adj_value":4200.95988},{"country":"United Arab Emirates","value":671,"adj_value":1478.0788},{"country":"Bahrain","value":83.3,"adj_value":183.49324},{"country":"India","value":2294.7,"adj_value":5054.76516},{"country":"Pakistan","value":273.9,"adj_value":603.34692},{"country":"Bangladesh","value":196,"adj_value":431.7488},{"country":"Sri Lanka","value":281.9,"adj_value":620.96932},{"country":"Thailand","value":1428.3,"adj_value":3146.25924},{"country":"Malaysia","value":2299.9,"adj_value":5066.21972},{"country":"Singapore","value":4259.9,"adj_value":9383.70772},{"country":"Indonesia","value":4568.9,"adj_value":10064.37292},{"country":"Philippines","value":2145,"adj_value":4725.006},{"country":"Macau","value":341.9,"adj_value":753.13732},{"country":"China","value":3861.7,"adj_value":8506.55276},{"country":"Korea, South","value":10013.3,"adj_value":22057.29724},{"country":"Hong Kong","value":8396.4,"adj_value":18495.58992},{"country":"Taiwan","value":16396.3,"adj_value":36117.76964},{"country":"Japan","value":68782.9,"adj_value":151514.9721}]},{"continent":"Australia","children":[{"country":"Australia","value":2836.3,"adj_value":6247.80164},{"country":"New Zealand","value":857,"adj_value":1887.7996}]},{"continent":"Africa","children":[{"country":"Algeria","value":2333,"adj_value":5139.1324},{"country":"Egypt","value":79.1,"adj_value":174.24148},{"country":"Cote d'Ivoire","value":524.8,"adj_value":1156.02944},{"country":"Nigeria","value":3001.9,"adj_value":6612.58532},{"country":"Gabon","value":501.9,"adj_value":1105.58532},{"country":"Angola","value":1053.6,"adj_value":2320.87008},{"country":"Congo (Brazzaville)","value":609.3,"adj_value":1342.16604},{"country":"Congo (Kinshasa)","value":400.7,"adj_value":882.66196},{"country":"South Africa","value":2070.9,"adj_value":4561.77852}]}]},{"type":"Exports","children":[{"continent":"North America","children":[{"country":"Canada","value":47251,"adj_value":104084.5028},{"country":"Mexico","value":13634.7,"adj_value":30034.51716},{"country":"Guatemala","value":404.6,"adj_value":891.25288},{"country":"El Salvador","value":445.5,"adj_value":981.3474},{"country":"Honduras","value":307.9,"adj_value":678.24212},{"country":"Costa Rica","value":421.7,"adj_value":928.92076},{"country":"Panama","value":674.8,"adj_value":1486.44944},{"country":"Bahamas","value":786.3,"adj_value":1732.06164},{"country":"Jamaica","value":404.3,"adj_value":890.59204},{"country":"Haiti","value":395.9,"adj_value":872.08852},{"country":"Dominican Republic","value":742,"adj_value":1634.4776},{"country":"Trinidad and Tobago","value":503.7,"adj_value":1109.55036},{"country":"Netherlands Antilles","value":427.5,"adj_value":941.697}]},{"continent":"South America","children":[{"country":"Colombia","value":1467.7,"adj_value":3233.04956},{"country":"Venezuela","value":3399.4,"adj_value":7488.19832},{"country":"Ecuador","value":591.1,"adj_value":1302.07508},{"country":"Peru","value":495.9,"adj_value":1092.36852},{"country":"Chile","value":682.2,"adj_value":1502.75016},{"country":"Brazil","value":3139.6,"adj_value":6915.91088},{"country":"Paraguay","value":98.9,"adj_value":217.85692},{"country":"Uruguay","value":64.3,"adj_value":141.64004},{"country":"Argentina","value":721.3,"adj_value":1588.87964}]},{"continent":"Europe","children":[{"country":"Iceland","value":38,"adj_value":83.7064},{"country":"Sweden","value":1924.9,"adj_value":4240.16972},{"country":"Norway","value":665.9,"adj_value":1466.84452},{"country":"Finland","value":437.7,"adj_value":964.16556},{"country":"Denmark","value":705.7,"adj_value":1554.51596},{"country":"United Kingdom","value":11272.8,"adj_value":24831.72384},{"country":"Ireland","value":1341.8,"adj_value":2955.71704},{"country":"Netherlands","value":7269,"adj_value":16012.1532},{"country":"Belgium","value":4917.7,"adj_value":10832.70956},{"country":"France","value":6095.6,"adj_value":13427.38768},{"country":"Germany","value":9050.2,"adj_value":19935.78056},{"country":"Austria","value":441.2,"adj_value":971.87536},{"country":"Hungary","value":94.5,"adj_value":208.1646},{"country":"Switzerland","value":2287.7,"adj_value":5039.34556},{"country":"Poland","value":237.9,"adj_value":524.04612},{"country":"USSR","value":2422.8,"adj_value":5336.94384},{"country":"Spain","value":2524.1,"adj_value":5560.08748},{"country":"Portugal","value":694.5,"adj_value":1529.8446},{"country":"Italy","value":4625.2,"adj_value":10188.39056},{"country":"Yugoslavia (former)","value":594.7,"adj_value":1310.00516},{"country":"Greece","value":497.8,"adj_value":1096.55384}]},{"continent":"Asia","children":[{"country":"Turkey","value":1294.6,"adj_value":2851.74488},{"country":"Iran","value":73.9,"adj_value":162.78692},{"country":"Israel","value":2579.6,"adj_value":5682.34288},{"country":"Kuwait","value":550.6,"adj_value":1212.86168},{"country":"Saudi Arabia","value":4474.3,"adj_value":9855.98804},{"country":"United Arab Emirates","value":596.5,"adj_value":1313.9702},{"country":"Bahrain","value":107,"adj_value":235.6996},{"country":"India","value":1641.9,"adj_value":3616.77732},{"country":"Pakistan","value":1041.7,"adj_value":2294.65676},{"country":"Bangladesh","value":218.9,"adj_value":482.19292},{"country":"Sri Lanka","value":72.8,"adj_value":160.36384},{"country":"Thailand","value":849.1,"adj_value":1870.39748},{"country":"Malaysia","value":1539.2,"adj_value":3390.54976},{"country":"Singapore","value":3475.6,"adj_value":7656.05168},{"country":"Indonesia","value":795,"adj_value":1751.226},{"country":"Philippines","value":1379.3,"adj_value":3038.32204},{"country":"Macau","value":1.1,"adj_value":2.42308},{"country":"China","value":3855.7,"adj_value":8493.33596},{"country":"Korea, South","value":5956.3,"adj_value":13120.53764},{"country":"Hong Kong","value":2785.9,"adj_value":6136.78052},{"country":"Taiwan","value":4700,"adj_value":10353.16},{"country":"Japan","value":22630.9,"adj_value":49851.34652}]},{"continent":"Australia","children":[{"country":"Australia","value":5440.4,"adj_value":11984.11312},{"country":"New Zealand","value":727.5,"adj_value":1602.537}]},{"continent":"Africa","children":[{"country":"Algeria","value":430.1,"adj_value":947.42428},{"country":"Egypt","value":2322.6,"adj_value":5116.22328},{"country":"Cote d'Ivoire","value":69.7,"adj_value":153.53516},{"country":"Nigeria","value":675.7,"adj_value":1488.43196},{"country":"Gabon","value":91.2,"adj_value":200.89536},{"country":"Angola","value":136.9,"adj_value":301.56332},{"country":"Congo (Brazzaville)","value":19.4,"adj_value":42.73432},{"country":"Congo (Kinshasa)","value":101.5,"adj_value":223.5842},{"country":"South Africa","value":1205,"adj_value":2654.374}]}]}]}]} -------------------------------------------------------------------------------- /inst/example/example_date.R: -------------------------------------------------------------------------------- 1 | library(treebar) 2 | library(dplyr) 3 | 4 | # create two years of fake data 5 | dates <- seq.Date(as.Date("2014-01-01"),as.Date("2016-12-31"), by="days") 6 | df <- data.frame( 7 | date = dates, 8 | profit = runif(length(dates), 100, 10000) 9 | ) 10 | 11 | # change our date to be hierarchy of years, quarters, months, weeks 12 | # could easily change weeks to days 13 | df_hier <- df %>% 14 | mutate( 15 | year = format(date, "%Y"), 16 | quarter = paste0("Qtr",ceiling(as.numeric(format(date,"%m")) / 3)), 17 | month = format(date, "%b"), 18 | week = format(date, "%U") 19 | ) %>% 20 | select(year, quarter, month, week, profit) %>% 21 | group_by(year, quarter, month, week) %>% 22 | summarize(profit = sum(profit)) %>% 23 | ungroup() 24 | 25 | df_hier %>% 26 | d3r::d3_nest(value_col="profit") %>% 27 | treebar(value="profit") 28 | -------------------------------------------------------------------------------- /inst/example/example_legend.R: -------------------------------------------------------------------------------- 1 | #devtools::install_github("timelyportfolio/d3legendR", subdir="pkg") 2 | 3 | library(treebar) 4 | library(d3legendR) 5 | library(htmltools) 6 | library(stringr) 7 | library(jsonlite) 8 | 9 | ## make it a more generic hierarchy 10 | ## normally this step is not necessary 11 | json <- str_replace_all( 12 | readLines(system.file("example/data.json",package="treebar")), 13 | "(country)|(continent)|(year)|(type)", 14 | "id" 15 | ) 16 | 17 | data <- fromJSON(json, simplifyDataFrame=FALSE) 18 | 19 | treebar(data) 20 | 21 | 22 | # now add a legend 23 | # will eventually make this easier 24 | browsable( 25 | attachDependencies( 26 | tagList( 27 | htmlwidgets::onRender( 28 | treebar(data, margin=list(right=200), height="100%", width="100%"), 29 | htmlwidgets::JS( 30 | " 31 | function(el,x){ 32 | // get our treebar chart 33 | var chart = HTMLWidgets.getInstance(el).instance.treebar; 34 | chart.on('updateComplete.legend', drawLegend); 35 | 36 | function drawLegend(chart){ 37 | var svg = chart.getSvg(); 38 | 39 | var legend_el = svg.selectAll('.legendOrdinal').data([0]) 40 | 41 | legend_el = legend_el.enter().append('g') 42 | .attr('class', 'legendOrdinal') 43 | .merge(legend_el) 44 | .attr('transform', 'translate(' + (+chart.width()-200) + ',100)'); 45 | 46 | var legendOrdinal = d3.legendColor() 47 | .shapeWidth(30) 48 | .orient('vertical') 49 | .scale(chart.options().color); 50 | 51 | svg.select('.legendOrdinal') 52 | .call(legendOrdinal); 53 | }; 54 | } 55 | " 56 | ) 57 | ) 58 | ), 59 | list( 60 | htmldependency_d3legend_v4() 61 | ) 62 | ) 63 | ) 64 | -------------------------------------------------------------------------------- /inst/example/example_nestd3.R: -------------------------------------------------------------------------------- 1 | # examples of building nested d3 with d3r 2 | library(treebar) 3 | library(dplyr) 4 | library(d3r) 5 | 6 | # simulate a portfolio 7 | portfolio <- data.frame( 8 | year = rep(2014:2016, each=8), 9 | asset = c(rep("equity",5),rep("fixed",3)), 10 | subasset = c("infotech","infotech","energy","energy","telecom","invgrade","invgrade","highyield"), 11 | ticker = rep(c("msft","apple","xom","cvx","t","pttrx","vficx","vwehx"),3), 12 | value = runif(24,50000,250000), 13 | stringsAsFactors = FALSE 14 | ) 15 | 16 | portfolio %>% 17 | d3_nest(value_cols="value", root="portfolio") 18 | 19 | portfolio %>% 20 | d3_nest(value_cols="value", root="portfolio") %>% 21 | treebar() 22 | 23 | 24 | titanic_df <- data.frame(Titanic) 25 | tit_tb <- titanic_df %>% 26 | select(Class,Age,Survived,Sex,Freq) %>% 27 | d3_nest(value_cols="Freq", root="titanic")%>% 28 | treebar(value = "Freq") 29 | tit_tb 30 | 31 | 32 | # now add a legend 33 | # will eventually make this easier 34 | 35 | library(d3legendR) 36 | library(htmltools) 37 | 38 | tit_tb$x$height <- "100%" 39 | tit_tb$x$width <- "100%" 40 | tit_tb$x$options$margin <- list("right"=150) 41 | 42 | browsable( 43 | attachDependencies( 44 | tagList( 45 | htmlwidgets::onRender( 46 | tit_tb, 47 | htmlwidgets::JS( 48 | " 49 | function(el,x){ 50 | // get our treebar chart 51 | var chart = HTMLWidgets.getInstance(el).instance.treebar; 52 | chart.on('updateComplete.legend', drawLegend); 53 | 54 | function drawLegend(chart){ 55 | var svg = chart.getSvg(); 56 | 57 | var legend_el = svg.selectAll('.legendOrdinal').data([0]) 58 | 59 | legend_el = legend_el.enter().append('g') 60 | .attr('class', 'legendOrdinal') 61 | .merge(legend_el) 62 | .attr('transform', 'translate(' + (+chart.width()-150) + ',100)'); 63 | 64 | var legendOrdinal = d3.legendColor() 65 | .shapeWidth(30) 66 | .orient('vertical') 67 | .scale(chart.options().color); 68 | 69 | svg.select('.legendOrdinal') 70 | .call(legendOrdinal); 71 | }; 72 | } 73 | " 74 | ) 75 | ) 76 | ), 77 | list( 78 | htmldependency_d3legend_v4() 79 | ) 80 | ) 81 | ) 82 | -------------------------------------------------------------------------------- /inst/example/example_portfolio.R: -------------------------------------------------------------------------------- 1 | library(treebar) 2 | library(data.tree) 3 | 4 | portfolio <- data.frame( 5 | year = rep(2014:2016, each=8), 6 | asset = c(rep("equity",5),rep("fixed",3)), 7 | subasset = c("infotech","infotech","energy","energy","telecom","invgrade","invgrade","highyield"), 8 | ticker = rep(c("msft","apple","xom","cvx","t","pttrx","vficx","vwehx"),3), 9 | value = runif(24,50000,250000), 10 | stringsAsFactors = FALSE 11 | ) 12 | 13 | portfolio$pathString <- paste( 14 | "portfolio", 15 | portfolio$year, 16 | portfolio$asset, 17 | portfolio$subasset, 18 | portfolio$ticker, 19 | sep = "/" 20 | ) 21 | 22 | portfolio_tree <- as.Node(portfolio) 23 | 24 | treebar( 25 | ToListExplicit(portfolio_tree, unname=TRUE), 26 | id = "name" 27 | ) 28 | 29 | # also allows different tiling options 30 | library(htmltools) 31 | 32 | browsable( 33 | tagList( 34 | lapply( 35 | c("Squarify", "Binary", "SliceDice", "Slice", "Dice"), 36 | function(tile){ 37 | tags$div( 38 | style = "float:left; display:inline;", 39 | tags$h3(tile), 40 | treebar( 41 | ToListExplicit(portfolio_tree, unname=TRUE), 42 | id = "name", 43 | tile = tile, 44 | height = 250, 45 | width = 320 46 | ) 47 | ) 48 | } 49 | ) 50 | ) 51 | ) 52 | 53 | 54 | # play with treemap treepalette 55 | library(treemap) 56 | library(treebar) 57 | library(dplyr) 58 | 59 | portfolio %>% 60 | mutate(year = as.character(year)) %>% 61 | inner_join(treepalette(.,index=c("asset","subasset","ticker"))) %>% 62 | mutate(color = HCL.color) %>% 63 | select(-starts_with("HCL")) %>% 64 | d3r::d3_nest(value_cols=c("value","color")) %>% 65 | treebar() 66 | -------------------------------------------------------------------------------- /inst/example/example_replicate.R: -------------------------------------------------------------------------------- 1 | #devtools::install_github("timelyportfolio/treebar") 2 | 3 | library(stringr) 4 | library(treebar) 5 | library(jsonlite) 6 | 7 | ## make it a more generic hierarchy 8 | ## normally this step is not necessary 9 | json <- str_replace_all( 10 | readLines(system.file("example/data.json",package="treebar")), 11 | "(country)|(continent)|(year)|(type)", 12 | "id" 13 | ) 14 | 15 | data <- fromJSON(json, simplifyDataFrame=FALSE) 16 | 17 | treebar(data) 18 | 19 | 20 | # also allows different treemap tiling options 21 | library(htmltools) 22 | 23 | browsable( 24 | tagList( 25 | lapply( 26 | c("Squarify", "Binary", "SliceDice", "Slice", "Dice"), 27 | function(tile){ 28 | tags$div( 29 | style = "float:left; display:inline;", 30 | tags$h3(tile), 31 | treebar( 32 | data, 33 | tile = tile, 34 | height = 250, 35 | width = 400 36 | ) 37 | ) 38 | } 39 | ) 40 | ) 41 | ) 42 | 43 | 44 | # use different key for id and value 45 | json <- str_replace_all( 46 | readLines("./inst/example/data.json"), 47 | "(country)|(continent)|(year)|(type)", 48 | "name" 49 | ) 50 | 51 | json <- str_replace_all( 52 | json, 53 | "(value)", 54 | "size" 55 | ) 56 | 57 | data <- fromJSON(json, simplifyDataFrame=FALSE) 58 | 59 | treebar(data, value="size", id="name") 60 | -------------------------------------------------------------------------------- /inst/example/example_shiny.R: -------------------------------------------------------------------------------- 1 | #devtools::install_github("timelyportfolio/treebar") 2 | 3 | library(stringr) 4 | library(treebar) 5 | library(jsonlite) 6 | library(shiny) 7 | 8 | ## make it a more generic hierarchy 9 | ## normally this step is not necessary 10 | json <- str_replace_all( 11 | readLines(system.file("example/data.json",package="treebar")), 12 | "(country)|(continent)|(year)|(type)", 13 | "id" 14 | ) 15 | 16 | data <- fromJSON(json, simplifyDataFrame=FALSE) 17 | 18 | shinyApp( 19 | ui = htmlwidgets::onRender( 20 | treebar(data), 21 | htmlwidgets::JS( 22 | ' 23 | function(el, x){ 24 | var chart = HTMLWidgets.getInstance(el).instance.treebar; 25 | chart.on("nodeMouseover", function(d,i){ 26 | Shiny.onInputChange("treebar_mouseover", d.data); 27 | }); 28 | } 29 | ' 30 | ) 31 | ), 32 | server = function(input, output, session){ 33 | observeEvent(input$treebar_mouseover,{ 34 | print(input$treebar_mouseover) 35 | }) 36 | } 37 | ) 38 | -------------------------------------------------------------------------------- /inst/example/example_treemap.R: -------------------------------------------------------------------------------- 1 | ## work with treemap and use treecolors 2 | 3 | library(treemap) 4 | library(treebar) 5 | library(dplyr) 6 | 7 | data_hier <- tidyr:::drop_na(random.hierarchical.data(depth=4)) %>% 8 | inner_join(treepalette(.,index=names(.)[-ncol(.)])) %>% 9 | mutate(color = HCL.color) %>% 10 | select(-starts_with("HCL")) 11 | 12 | d3r::d3_nest(data_hier, value_cols=c("x","color")) %>% 13 | treebar(value="x") 14 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/d3/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2010-2016 Mike Bostock 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the author nor the names of contributors may be used to 15 | endorse or promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/d3/README.md: -------------------------------------------------------------------------------- 1 | # D3: Data-Driven Documents 2 | 3 | 4 | 5 | **D3** (or **D3.js**) is a JavaScript library for visualizing data using web standards. D3 helps you bring data to life using SVG, Canvas and HTML. D3 combines powerful visualization and interaction techniques with a data-driven approach to DOM manipulation, giving you the full capabilities of modern browsers and the freedom to design the right visual interface for your data. 6 | 7 | ## Resources 8 | 9 | * [API Reference](https://github.com/d3/d3/blob/master/API.md) 10 | * [Release Notes](https://github.com/d3/d3/releases) 11 | * [Gallery](https://github.com/d3/d3/wiki/Gallery) 12 | * [Examples](http://bl.ocks.org/mbostock) 13 | * [Wiki](https://github.com/d3/d3/wiki) 14 | 15 | ## Installing 16 | 17 | If you use NPM, `npm install d3`. Otherwise, download the [latest release](https://github.com/d3/d3/releases/latest). The released bundle supports anonymous AMD, CommonJS, and vanilla environments. You can load directly from [d3js.org](https://d3js.org), [CDNJS](https://cdnjs.com/libraries/d3), or [npmcdn](https://npmcdn.com/d3/). For example: 18 | 19 | ```html 20 | 21 | ``` 22 | 23 | For the minified version: 24 | 25 | ```html 26 | 27 | ``` 28 | 29 | You can also use the standalone D3 microlibraries. For example, [d3-selection](https://github.com/d3/d3-selection): 30 | 31 | ```html 32 | 33 | ``` 34 | 35 | D3 is written using [ES2015 modules](http://www.2ality.com/2014/09/es6-modules-final.html). Create a [custom bundle using Rollup](http://bl.ocks.org/mbostock/bb09af4c39c79cffcde4), Webpack, or your preferred bundler. To import D3 into an ES2015 application, either import specific symbols from specific D3 modules: 36 | 37 | ```js 38 | import {scaleLinear} from "d3-scale"; 39 | ``` 40 | 41 | Or import everything into a namespace (here, `d3`): 42 | 43 | ```js 44 | import * as d3 from "d3"; 45 | ``` 46 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/d3kit/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change logs 2 | 3 | ## v2.x.x 4 | 5 | ### 2.0.0 (2016-08-16) 6 | 7 | Make d3Kit compatible with D3 v4. Key changes are due to: 8 | 9 | - Removal of `d3.functor` and `d3.rebind`. Implement helper functions as replacements. 10 | - API changes for `d3.dispatch`. Now use `dispatch.call('x', ...)` instead of `dispatch.x(...)` 11 | 12 | The npm package also remove `d3` from `dependencies` and add `d3-selection` and `d3-dispatch` to `peerDependencies` instead. 13 | 14 | In terms of development, switch from grunt to gulp and webpack and prepare to migrate each module to es2015. 15 | 16 | ## v1.x.x 17 | 18 | ### 1.1.0 (2016-04-07) 19 | 20 | Add an option to select tag type for LayerOrganizer 21 | 22 | ```javascript 23 | new LayerOrganizer(container); //will create layers as by default 24 | new LayerOrganizer(container, 'div'); // will create layers as
25 | ``` 26 | 27 | ### 1.0.11 (2016-02-23) 28 | 29 | Change main file to point to `d3kit.min.js` instead of `d3kit.js` 30 | 31 | ### 1.0.10 (2016-02-17) 32 | 33 | Update D3 version in the dependencies to 3.5.16 34 | 35 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/d3kit/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Recommendations and requirements for how to best contribute to **d3Kit**. As always, thanks for contributing, and we hope these guidelines make it easier and shed some light on our approach and processes. 2 | 3 | ### Key branches 4 | - `master` is the latest released version 5 | - `dev` is where development happens and all pull requests should be submitted 6 | 7 | ### Versioning 8 | 9 | **d3Kit** comforms to the [Semantic Versioning](http://semver.org/) standard. 10 | 11 | ### Pull requests 12 | - Submit pull requests against the `dev` branch 13 | - Try not to pollute your pull request with unintended changes. Please keep them simple and small. 14 | 15 | ### License 16 | By contributing your code, you agree to license your contributions under the terms of the MIT license: 17 | https://github.com/twitter/d3kit/blob/master/LICENSE 18 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/d3kit/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Twitter, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/d3kit/README.md: -------------------------------------------------------------------------------- 1 | ## d3Kit 2 | 3 | [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] 4 | 5 | **d3Kit** is a set of thin scaffolds and utilities for speeding visualization development with [D3](https://github.com/mbostock/d3). 6 | It is a lightweight library (~8KB, minified) to relieve you from the same groundwork tasks you found yourself doing again and again. Writing code in d3Kit way also help you create reusable and responsive components easily. 7 | 8 |

9 | 10 | 11 | 12 |

13 | 14 | d3Kit features include, but are not limited to: 15 | 16 | * Setup `````` according to d3's [margin convention](http://bl.ocks.org/mbostock/3019563), make it support auto-resizing and add other convenient functions. We called it a "Skeleton" for your visualization. 17 | * Help you create reusable component. 18 | * Help you create reusable subcomponent (a.k.a. Chartlet). 19 | * Help you manage layers within a visualization. 20 | * and many more... 21 | 22 | Here are a few examples of d3Kit in action: 23 | * [Dot in a box](http://bl.ocks.org/treboresque/f839966214cf66627df6) 24 | * [Bubble Chart](http://bl.ocks.org/kristw/75999459f1a34e05d580) 25 | * [Reusable Bubble Chart](http://bl.ocks.org/kristw/d8b15dd09a4c3510621c) 26 | * [Circle Chartlet](http://bl.ocks.org/treboresque/0f01e42fb3c9268d7105) 27 | 28 | For more examples, [check out our gallery](https://github.com/twitter/d3kit/wiki/Gallery). 29 | 30 | Want to learn more? [See the wiki](https://github.com/twitter/d3kit/wiki) or [API Reference](https://github.com/twitter/d3kit/wiki/API-reference) 31 | 32 | ### Can't wait to try it? 33 | 34 | ``` 35 | bower install d3kit --save 36 | ``` 37 | 38 | or 39 | 40 | ``` 41 | npm install d3-selection d3-dispatch d3kit --save 42 | ``` 43 | 44 | ### Authors 45 | 46 | * Robert Harris [@trebor](https://twitter.com/trebor) 47 | * Krist Wongsuphasawat [@kristw](https://twitter.com/kristw) 48 | 49 | 50 | [npm-image]: https://badge.fury.io/js/d3kit.svg 51 | [npm-url]: https://npmjs.org/package/d3kit 52 | [travis-image]: https://travis-ci.org/twitter/d3kit.svg?branch=master 53 | [travis-url]: https://travis-ci.org/twitter/d3kit 54 | [daviddm-image]: https://david-dm.org/twitter/d3kit.svg?theme=shields.io 55 | [daviddm-url]: https://david-dm.org/twitter/d3kit -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/d3kit/dist/d3kit.js: -------------------------------------------------------------------------------- 1 | (function webpackUniversalModuleDefinition(root, factory) { 2 | if(typeof exports === 'object' && typeof module === 'object') 3 | module.exports = factory(require("d3-selection"), require("d3-dispatch")); 4 | else if(typeof define === 'function' && define.amd) 5 | define(["d3-selection", "d3-dispatch"], factory); 6 | else if(typeof exports === 'object') 7 | exports["d3Kit"] = factory(require("d3-selection"), require("d3-dispatch")); 8 | else 9 | root["d3Kit"] = factory(root["d3"], root["d3"]); 10 | })(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_3__) { 11 | return /******/ (function(modules) { // webpackBootstrap 12 | /******/ // The module cache 13 | /******/ var installedModules = {}; 14 | 15 | /******/ // The require function 16 | /******/ function __webpack_require__(moduleId) { 17 | 18 | /******/ // Check if module is in cache 19 | /******/ if(installedModules[moduleId]) 20 | /******/ return installedModules[moduleId].exports; 21 | 22 | /******/ // Create a new module (and put it into the cache) 23 | /******/ var module = installedModules[moduleId] = { 24 | /******/ exports: {}, 25 | /******/ id: moduleId, 26 | /******/ loaded: false 27 | /******/ }; 28 | 29 | /******/ // Execute the module function 30 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 31 | 32 | /******/ // Flag the module as loaded 33 | /******/ module.loaded = true; 34 | 35 | /******/ // Return the exports of the module 36 | /******/ return module.exports; 37 | /******/ } 38 | 39 | 40 | /******/ // expose the modules object (__webpack_modules__) 41 | /******/ __webpack_require__.m = modules; 42 | 43 | /******/ // expose the module cache 44 | /******/ __webpack_require__.c = installedModules; 45 | 46 | /******/ // __webpack_public_path__ 47 | /******/ __webpack_require__.p = ""; 48 | 49 | /******/ // Load entry module and return exports 50 | /******/ return __webpack_require__(0); 51 | /******/ }) 52 | /************************************************************************/ 53 | /******/ ([ 54 | /* 0 */ 55 | /***/ function(module, exports, __webpack_require__) { 56 | 57 | 'use strict'; 58 | 59 | Object.defineProperty(exports, "__esModule", { 60 | value: true 61 | }); 62 | exports.helper = exports.LayerOrganizer = exports.Chartlet = exports.Skeleton = exports.factory = undefined; 63 | 64 | var _skeleton = __webpack_require__(1); 65 | 66 | Object.defineProperty(exports, 'Skeleton', { 67 | enumerable: true, 68 | get: function get() { 69 | return _interopRequireDefault(_skeleton).default; 70 | } 71 | }); 72 | 73 | var _chartlet = __webpack_require__(6); 74 | 75 | Object.defineProperty(exports, 'Chartlet', { 76 | enumerable: true, 77 | get: function get() { 78 | return _interopRequireDefault(_chartlet).default; 79 | } 80 | }); 81 | 82 | var _layerOrganizer = __webpack_require__(4); 83 | 84 | Object.defineProperty(exports, 'LayerOrganizer', { 85 | enumerable: true, 86 | get: function get() { 87 | return _interopRequireDefault(_layerOrganizer).default; 88 | } 89 | }); 90 | 91 | var _helper = __webpack_require__(5); 92 | 93 | Object.defineProperty(exports, 'helper', { 94 | enumerable: true, 95 | get: function get() { 96 | return _interopRequireDefault(_helper).default; 97 | } 98 | }); 99 | 100 | var _factory = __webpack_require__(7); 101 | 102 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 103 | 104 | var factory = exports.factory = { createChart: _factory.createChart }; 105 | 106 | /***/ }, 107 | /* 1 */ 108 | /***/ function(module, exports, __webpack_require__) { 109 | 110 | 'use strict'; 111 | 112 | Object.defineProperty(exports, "__esModule", { 113 | value: true 114 | }); 115 | 116 | var _d3Selection = __webpack_require__(2); 117 | 118 | var _d3Dispatch = __webpack_require__(3); 119 | 120 | var _layerOrganizer = __webpack_require__(4); 121 | 122 | var _layerOrganizer2 = _interopRequireDefault(_layerOrganizer); 123 | 124 | var _helper = __webpack_require__(5); 125 | 126 | var _helper2 = _interopRequireDefault(_helper); 127 | 128 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 129 | 130 | // Constants 131 | var DEFAULT_OPTIONS = { 132 | margin: { top: 30, right: 30, bottom: 30, left: 30 }, 133 | offset: [0.5, 0.5], 134 | initialWidth: 720, 135 | initialHeight: 500 136 | }; 137 | 138 | var BASE_EVENTS = ['data', 'options', 'resize']; 139 | 140 | // Core Skeleton 141 | function Skeleton(chartNode, customOptions, customEvents) { 142 | var skeleton = {}; 143 | 144 | chartNode = _helper2.default.$(chartNode); 145 | 146 | var _data = null; 147 | 148 | var _options = _helper2.default.deepExtend({}, DEFAULT_OPTIONS, customOptions); 149 | 150 | var _totalWidth = 0; 151 | var _totalHeight = 0; 152 | var _innerWidth = 0; 153 | var _innerHeight = 0; 154 | 155 | var _autoResizeDetection = 'window'; // either 'window' or 'dom'; 156 | var _autoResizeMode = false; 157 | var _autoResizeFn = null; 158 | var _autoResizeToAspectRatio = false; 159 | 160 | // add svg element 161 | var _svg = (0, _d3Selection.select)(chartNode).append('svg'); 162 | var _vis = _svg.append('g'); 163 | updateOffset(); 164 | 165 | var _layers = new _layerOrganizer2.default(_vis); 166 | 167 | // setup event dispatcher 168 | var _customEvents = customEvents ? customEvents.concat(BASE_EVENTS) : BASE_EVENTS; 169 | var _dispatch = _d3Dispatch.dispatch.apply(this, _customEvents); 170 | 171 | // set default dimension 172 | dimension([_options.initialWidth, _options.initialHeight]); 173 | 174 | function data(newValue, doNotDispatch) { 175 | // getter 176 | if (arguments.length === 0) { 177 | return _data; 178 | } 179 | // setter 180 | _data = newValue; 181 | // dispatch 182 | if (!doNotDispatch) { 183 | _dispatch.call('data', this, newValue); 184 | } 185 | return skeleton; 186 | } 187 | 188 | function options(newValue, doNotDispatch) { 189 | // getter 190 | if (arguments.length === 0) { 191 | return _options; 192 | } 193 | 194 | // setter 195 | _options = _helper2.default.deepExtend(_options, newValue); 196 | 197 | if (newValue) { 198 | if (newValue.margin) { 199 | updateMargin(doNotDispatch); 200 | } else if (newValue.offset) { 201 | // When the margin is changed, 202 | // updateOffset() is already called within updateMargin() 203 | // so "else if" is used here instead of "if". 204 | // This will call updateOffset() manually 205 | // only when margin is not changed and offset is changed. 206 | updateOffset(); 207 | } 208 | } 209 | 210 | // dispatch 211 | if (!doNotDispatch) { 212 | _dispatch.call('options', this, newValue); 213 | } 214 | return skeleton; 215 | } 216 | 217 | function updateOffset() { 218 | _vis.attr('transform', 'translate(' + (_options.margin.left + _options.offset[0]) + ',' + (_options.margin.top + _options.offset[1]) + ')'); 219 | } 220 | 221 | function updateMargin(doNotDispatch) { 222 | updateOffset(); 223 | 224 | _innerWidth = _totalWidth - _options.margin.left - _options.margin.right; 225 | _innerHeight = _totalHeight - _options.margin.top - _options.margin.bottom; 226 | 227 | if (!doNotDispatch) { 228 | _dispatch.call('resize', this, [_totalWidth, _totalHeight, _innerWidth, _innerHeight]); 229 | } 230 | } 231 | 232 | function margin(newValue, doNotDispatch) { 233 | // getter 234 | if (arguments.length === 0) { 235 | return _options.margin; 236 | } 237 | 238 | // setter 239 | _options.margin = _helper2.default.extend(_options.margin, newValue); 240 | updateMargin(doNotDispatch); 241 | 242 | return skeleton; 243 | } 244 | 245 | function offset(newValue) { 246 | // getter 247 | if (arguments.length === 0) { 248 | return _options.offset; 249 | } 250 | 251 | // setter 252 | _options.offset = newValue; 253 | updateOffset(); 254 | 255 | return skeleton; 256 | } 257 | 258 | function width(newValue, doNotDispatch) { 259 | // getter 260 | if (arguments.length === 0 || newValue === null || newValue === undefined) { 261 | return _totalWidth; 262 | } 263 | 264 | // setter 265 | if (_helper2.default.isNumber(newValue)) { 266 | _totalWidth = +newValue; 267 | } else if (newValue.trim().toLowerCase() == 'auto') { 268 | _totalWidth = chartNode.clientWidth; 269 | } else { 270 | _totalWidth = +(newValue + '').replace(/px/gi, '').trim(); 271 | } 272 | 273 | if (_helper2.default.isNaN(_totalWidth)) { 274 | throw Error('invalid width: ' + _totalWidth); 275 | } 276 | 277 | // round to integer 278 | _totalWidth = Math.floor(_totalWidth); 279 | _innerWidth = _totalWidth - _options.margin.left - _options.margin.right; 280 | 281 | _svg.attr('width', _totalWidth); 282 | 283 | // dispatch 284 | if (!doNotDispatch) { 285 | _dispatch.call('resize', this, [_totalWidth, _totalHeight, _innerWidth, _innerHeight]); 286 | } 287 | return skeleton; 288 | } 289 | 290 | function height(newValue, doNotDispatch) { 291 | // getter 292 | if (arguments.length === 0 || newValue === null || newValue === undefined) { 293 | return _totalHeight; 294 | } 295 | 296 | // setter 297 | if (_helper2.default.isNumber(newValue)) { 298 | _totalHeight = +newValue; 299 | } else if (newValue.trim().toLowerCase() == 'auto') { 300 | _totalHeight = chartNode.clientHeight; 301 | } else { 302 | _totalHeight = +(newValue + '').replace(/px/gi, '').trim(); 303 | } 304 | 305 | if (_helper2.default.isNaN(_totalHeight)) { 306 | throw Error('invalid height: ' + _totalHeight); 307 | } 308 | 309 | // round to integer 310 | _totalHeight = Math.floor(_totalHeight); 311 | 312 | _innerHeight = _totalHeight - _options.margin.top - _options.margin.bottom; 313 | _svg.attr('height', _totalHeight); 314 | 315 | // dispatch 316 | if (!doNotDispatch) { 317 | _dispatch.call('resize', this, [_totalWidth, _totalHeight, _innerWidth, _innerHeight]); 318 | } 319 | return skeleton; 320 | } 321 | 322 | function dimension(values, doNotDispatch) { 323 | if (arguments.length === 0) { 324 | return [_totalWidth, _totalHeight]; 325 | } 326 | width(values[0], true); 327 | height(values[1], doNotDispatch); 328 | 329 | return skeleton; 330 | } 331 | 332 | function autoResize(newMode) { 333 | if (arguments.length === 0) { 334 | return _autoResizeMode; 335 | } else if (_autoResizeMode != newMode) { 336 | return setupAutoResize(newMode, _autoResizeDetection); 337 | } 338 | return skeleton; 339 | } 340 | 341 | function autoResizeDetection(newDetection) { 342 | if (arguments.length === 0) { 343 | return _autoResizeDetection; 344 | } else if (_autoResizeDetection != newDetection) { 345 | return setupAutoResize(_autoResizeMode, newDetection); 346 | } 347 | return skeleton; 348 | } 349 | 350 | function autoResizeToAspectRatio(ratio) { 351 | if (arguments.length === 0) { 352 | return _autoResizeToAspectRatio; 353 | } 354 | 355 | if (ratio === null || ratio === undefined || ratio === '' || ratio === false || (ratio + '').toLowerCase() === 'false') { 356 | _autoResizeToAspectRatio = false; 357 | } else if (!_helper2.default.isNumber(ratio)) { 358 | _autoResizeToAspectRatio = false; 359 | } else if (+ratio === 0) { 360 | _autoResizeToAspectRatio = false; 361 | } else { 362 | _autoResizeToAspectRatio = +ratio; 363 | } 364 | return skeleton; 365 | } 366 | 367 | function clearAutoResizeListener() { 368 | if (_autoResizeFn) { 369 | switch (_autoResizeDetection) { 370 | case 'dom': 371 | _helper2.default.off(chartNode, 'resize', _autoResizeFn); 372 | break; 373 | default: 374 | case 'window': 375 | _helper2.default.off(window, 'resize', _autoResizeFn); 376 | break; 377 | } 378 | } 379 | _autoResizeFn = null; 380 | return skeleton; 381 | } 382 | 383 | function setAutoResizeListener(fn) { 384 | if (fn) { 385 | switch (_autoResizeDetection) { 386 | case 'dom': 387 | _helper2.default.on(chartNode, 'resize', fn); 388 | break; 389 | default: 390 | case 'window': 391 | _helper2.default.on(window, 'resize', fn); 392 | break; 393 | } 394 | } 395 | _autoResizeFn = fn; 396 | return skeleton; 397 | } 398 | 399 | function setupAutoResize(newMode, newDetection) { 400 | newMode = newMode && (newMode + '').toLowerCase() == 'false' ? false : newMode; 401 | newDetection = newDetection || _autoResizeDetection; 402 | 403 | // check if there is change in listener 404 | if (newMode != _autoResizeMode) { 405 | clearAutoResizeListener(); 406 | _autoResizeMode = newMode; 407 | _autoResizeDetection = newDetection; 408 | if (newMode) { 409 | _autoResizeFn = _helper2.default.debounce(function () { 410 | if (_autoResizeToAspectRatio) { 411 | resizeToFitContainer(_autoResizeMode, true); 412 | resizeToAspectRatio(_autoResizeToAspectRatio); 413 | } else { 414 | resizeToFitContainer(_autoResizeMode); 415 | } 416 | }, 100); 417 | setAutoResizeListener(_autoResizeFn); 418 | } 419 | } 420 | // change detection mode only 421 | else if (newDetection != _autoResizeDetection) { 422 | var oldAutoResizeFn = _autoResizeFn; 423 | clearAutoResizeListener(); 424 | _autoResizeDetection = newDetection; 425 | setAutoResizeListener(oldAutoResizeFn); 426 | } 427 | 428 | if (_autoResizeFn) _autoResizeFn(); 429 | 430 | return skeleton; 431 | } 432 | 433 | function getCustomEventNames() { 434 | return customEvents || []; 435 | } 436 | 437 | function mixin(mixer) { 438 | var self = skeleton; 439 | if (_helper2.default.isObject(mixer)) { 440 | Object.keys(mixer).forEach(function (key) { 441 | self[key] = mixer[key]; 442 | }); 443 | } 444 | return self; 445 | } 446 | 447 | // This function is only syntactic sugar 448 | function resizeToFitContainer(mode, doNotDispatch) { 449 | switch (mode) { 450 | case 'all': 451 | case 'full': 452 | case 'both': 453 | dimension(['auto', 'auto'], doNotDispatch); 454 | break; 455 | case 'height': 456 | height('auto', doNotDispatch); 457 | break; 458 | default: 459 | case 'width': 460 | width('auto', doNotDispatch); 461 | break; 462 | } 463 | return skeleton; 464 | } 465 | 466 | function resizeToAspectRatio(ratio, doNotDispatch) { 467 | var w = _totalWidth; 468 | var h = _totalHeight; 469 | 470 | if (!_helper2.default.isNumber(ratio)) throw 'Invalid ratio: must be a Number'; 471 | 472 | ratio = +ratio; 473 | 474 | // no need to resize if already at ratio 475 | if ((w / h).toFixed(4) == ratio.toFixed(4)) return skeleton; 476 | 477 | var estimatedH = Math.floor(w / ratio); 478 | if (estimatedH > h) { 479 | width(Math.floor(h * ratio), doNotDispatch); 480 | } else { 481 | height(estimatedH, doNotDispatch); 482 | } 483 | return skeleton; 484 | } 485 | 486 | function hasData() { 487 | return _data !== null && _data !== undefined; 488 | } 489 | 490 | function hasNonZeroArea() { 491 | return _innerWidth > 0 && _innerHeight > 0; 492 | } 493 | 494 | // define public fields and functions 495 | _helper2.default.extend(skeleton, { 496 | // getter only 497 | getCustomEventNames: getCustomEventNames, 498 | getDispatcher: function getDispatcher() { 499 | return _dispatch; 500 | }, 501 | getInnerWidth: function getInnerWidth() { 502 | return _innerWidth; 503 | }, 504 | getInnerHeight: function getInnerHeight() { 505 | return _innerHeight; 506 | }, 507 | getLayerOrganizer: function getLayerOrganizer() { 508 | return _layers; 509 | }, 510 | getRootG: function getRootG() { 511 | return _vis; 512 | }, 513 | getSvg: function getSvg() { 514 | return _svg; 515 | }, 516 | 517 | 518 | // getter & setter 519 | data: data, 520 | options: options, 521 | margin: margin, 522 | offset: offset, 523 | width: width, 524 | height: height, 525 | dimension: dimension, 526 | autoResize: autoResize, 527 | autoResizeDetection: autoResizeDetection, 528 | autoResizeToAspectRatio: autoResizeToAspectRatio, 529 | 530 | // functions 531 | hasData: hasData, 532 | hasNonZeroArea: hasNonZeroArea, 533 | mixin: mixin, 534 | resizeToFitContainer: resizeToFitContainer, 535 | resizeToAspectRatio: resizeToAspectRatio 536 | }); 537 | 538 | // bind events 539 | _helper2.default.rebind(skeleton, _dispatch, 'on'); 540 | 541 | return skeleton; 542 | } 543 | 544 | exports.default = Skeleton; 545 | 546 | /***/ }, 547 | /* 2 */ 548 | /***/ function(module, exports) { 549 | 550 | module.exports = __WEBPACK_EXTERNAL_MODULE_2__; 551 | 552 | /***/ }, 553 | /* 3 */ 554 | /***/ function(module, exports) { 555 | 556 | module.exports = __WEBPACK_EXTERNAL_MODULE_3__; 557 | 558 | /***/ }, 559 | /* 4 */ 560 | /***/ function(module, exports, __webpack_require__) { 561 | 562 | 'use strict'; 563 | 564 | Object.defineProperty(exports, "__esModule", { 565 | value: true 566 | }); 567 | 568 | exports.default = function (mainContainer, tag) { 569 | var layers = {}; 570 | tag = tag || 'g'; 571 | 572 | function createLayerFromName(container, layerName, prefix) { 573 | var id = prefix ? prefix + '.' + layerName : layerName; 574 | if (layers.hasOwnProperty(id)) { 575 | throw 'invalid or duplicate layer id: ' + id; 576 | } 577 | 578 | var layer = container.append(tag).classed(_helper2.default.dasherize(layerName) + '-layer', true); 579 | 580 | layers[id] = layer; 581 | return layer; 582 | } 583 | 584 | function createLayerFromInfo(container, layerInfo, prefix) { 585 | if (Array.isArray(layerInfo)) { 586 | return layerInfo.map(function (info) { 587 | createLayerFromInfo(container, info, prefix); 588 | }); 589 | } else if (_helper2.default.isObject(layerInfo)) { 590 | var parentKey = Object.keys(layerInfo)[0]; 591 | var parentLayer = createLayerFromName(container, parentKey, prefix); 592 | createLayerFromInfo(parentLayer, layerInfo[parentKey], prefix ? prefix + '.' + parentKey : parentKey); 593 | return parentLayer; 594 | } else { 595 | return createLayerFromName(container, layerInfo, prefix); 596 | } 597 | } 598 | 599 | function createLayer(layerInfo) { 600 | return createLayerFromInfo(mainContainer, layerInfo); 601 | } 602 | 603 | function create(layerNames) { 604 | if (Array.isArray(layerNames)) { 605 | return layerNames.map(createLayer); 606 | } else { 607 | return createLayer(layerNames); 608 | } 609 | } 610 | 611 | function get(layerName) { 612 | return layers[layerName]; 613 | } 614 | 615 | function has(layerName) { 616 | return !!layers[layerName]; 617 | } 618 | 619 | return { 620 | create: create, 621 | get: get, 622 | has: has 623 | }; 624 | }; 625 | 626 | var _helper = __webpack_require__(5); 627 | 628 | var _helper2 = _interopRequireDefault(_helper); 629 | 630 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 631 | 632 | /***/ }, 633 | /* 5 */ 634 | /***/ function(module, exports) { 635 | 636 | 'use strict'; 637 | 638 | Object.defineProperty(exports, "__esModule", { 639 | value: true 640 | }); 641 | 642 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; 643 | 644 | /** 645 | * Example usage: 646 | * selection.call(d3Kit.helper.bindMouseEventsToDispatcher, dispatch, 'bar') 647 | * 648 | * @param {[type]} dispatch [description] 649 | * @param {[type]} prefix [description] 650 | * @return {[type]} [description] 651 | */ 652 | function bindMouseEventsToDispatcher(selection, dispatch, prefix) { 653 | return selection.on('click', function (d, i) { 654 | dispatch.call(prefix + 'Click', this, d, i); 655 | }).on('mouseover', function (d, i) { 656 | dispatch.call(prefix + 'MouseOver', this, d, i); 657 | }).on('mousemove', function (d, i) { 658 | dispatch.call(prefix + 'MouseMove', this, d, i); 659 | }).on('mouseout', function (d, i) { 660 | dispatch.call(prefix + 'MouseOut', this, d, i); 661 | }); 662 | } 663 | 664 | function removeAllChildren(selection, noTransition) { 665 | if (noTransition) { 666 | return selection.selectAll('*').remove(); 667 | } else { 668 | return selection.selectAll('*').transition().style('opacity', 0).remove(); 669 | } 670 | } 671 | 672 | // Returns true if it is a DOM element 673 | // From http://stackoverflow.com/questions/384286/javascript-isdom-how-do-you-check-if-a-javascript-object-is-a-dom-object 674 | function isElement(o) { 675 | return (typeof HTMLElement === 'undefined' ? 'undefined' : _typeof(HTMLElement)) === 'object' ? o instanceof HTMLElement : // DOM2 676 | o && (typeof o === 'undefined' ? 'undefined' : _typeof(o)) === 'object' && o !== null && o.nodeType === 1 && typeof o.nodeName === 'string'; 677 | } 678 | 679 | var isNaN = Number.isNaN ? Number.isNaN : window.isNaN; 680 | 681 | // Check whether s is element if not then do the querySelector 682 | function $(s) { 683 | return isElement(s) ? s : document.querySelector(s); 684 | } 685 | 686 | // To get a proper array from a NodeList that matches the CSS selector 687 | function $$(s) { 688 | return Array.isArray(s) ? s : [].slice.call(document.querySelectorAll(s)); 689 | } 690 | 691 | //--------------------------------------------------- 692 | // From http://youmightnotneedjquery.com/ 693 | //--------------------------------------------------- 694 | 695 | function deepExtend(out) { 696 | out = out || {}; 697 | 698 | for (var i = 1; i < arguments.length; i++) { 699 | var obj = arguments[i]; 700 | 701 | if (!obj) continue; 702 | 703 | for (var key in obj) { 704 | if (obj.hasOwnProperty(key)) { 705 | var value = obj[key]; 706 | if (isObject(value) && !Array.isArray(value) && !isFunction(value)) { 707 | out[key] = deepExtend(out[key], value); 708 | } else out[key] = value; 709 | } 710 | } 711 | } 712 | 713 | return out; 714 | } 715 | 716 | function extend(out) { 717 | out = out || {}; 718 | 719 | for (var i = 1; i < arguments.length; i++) { 720 | if (!arguments[i]) continue; 721 | 722 | for (var key in arguments[i]) { 723 | if (arguments[i].hasOwnProperty(key)) out[key] = arguments[i][key]; 724 | } 725 | } 726 | 727 | return out; 728 | } 729 | 730 | function on(element, type, listener) { 731 | if (element.addEventListener) { 732 | element.addEventListener(type, listener, false); 733 | } else if (element.attachEvent) { 734 | element.attachEvent('on' + type, listener); 735 | } 736 | } 737 | 738 | function off(element, type, listener) { 739 | element.removeEventListener(type, listener, false); 740 | } 741 | 742 | //--------------------------------------------------- 743 | // Modified from lodash 744 | //--------------------------------------------------- 745 | 746 | /** 747 | * Returns a function, that, as long as it continues to be invoked, 748 | * will not be triggered. 749 | * The function will be called after it stops being called for 750 | * "wait" milliseconds. 751 | * The output function can be called with .now() to execute immediately 752 | * For example: 753 | * doSomething(params); // will debounce 754 | * doSomething.now(params); // will execute immediately 755 | * 756 | * @param Function func function to be debounced 757 | * @param Number wait wait time until it will be executed 758 | * @param Boolean immediate If "immediate" is passed, trigger the function on the 759 | * leading edge, instead of the trailing. 760 | * @return Function debounced function 761 | */ 762 | function debounce(func, wait, immediate) { 763 | var timeout = void 0; 764 | 765 | var outputFn = function outputFn() { 766 | var context = this, 767 | args = arguments; 768 | var later = function later() { 769 | timeout = null; 770 | if (!immediate) func.apply(context, args); 771 | }; 772 | var callNow = immediate && !timeout; 773 | clearTimeout(timeout); 774 | timeout = setTimeout(later, wait); 775 | if (callNow) func.apply(context, args); 776 | 777 | // return caller for chaining 778 | return context; 779 | }; 780 | 781 | // so we know this function is debounced 782 | outputFn.isDebounced = true; 783 | // and provide a way to call the original function immediately 784 | outputFn.now = function () { 785 | clearTimeout(timeout); 786 | return func.apply(this, arguments); 787 | }; 788 | 789 | return outputFn; 790 | } 791 | 792 | //--------------------------------------------------- 793 | // From lodash 794 | //--------------------------------------------------- 795 | 796 | /** Used to determine if values are of the language type Object */ 797 | var objectTypes = { 798 | 'boolean': false, 799 | 'function': true, 800 | 'object': true, 801 | 'number': false, 802 | 'string': false, 803 | 'undefined': false 804 | }; 805 | 806 | function isObject(value) { 807 | // check if the value is the ECMAScript language type of Object 808 | // http://es5.github.io/#x8 809 | // and avoid a V8 bug 810 | // http://code.google.com/p/v8/issues/detail?id=2291 811 | return !!(value && objectTypes[typeof value === 'undefined' ? 'undefined' : _typeof(value)]); 812 | } 813 | 814 | /** `Object#toString` result shortcuts */ 815 | var numberClass = '[object Number]'; 816 | 817 | /** Used for native method references */ 818 | var objectProto = Object.prototype; 819 | 820 | /** Used to resolve the internal [[Class]] of values */ 821 | var toString = objectProto.toString; 822 | 823 | /** 824 | * Checks if `value` is a number. 825 | * 826 | * Note: `NaN` is considered a number. See http://es5.github.io/#x8.5. 827 | * 828 | * @static 829 | * @memberOf _ 830 | * @category Objects 831 | * @param {*} value The value to check. 832 | * @returns {boolean} Returns `true` if the `value` is a number, else `false`. 833 | * @example 834 | * 835 | * _.isNumber(8.4 * 5); 836 | * // => true 837 | */ 838 | function isNumber(value) { 839 | return typeof value == 'number' || value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'object' && toString.call(value) == numberClass || false; 840 | } 841 | 842 | function isFunction(functionToCheck) { 843 | var getType = {}; 844 | return !!functionToCheck && getType.toString.call(functionToCheck) === '[object Function]'; 845 | } 846 | 847 | //--------------------------------------------------- 848 | // From underscore.string 849 | //--------------------------------------------------- 850 | /* jshint ignore:start */ 851 | 852 | var nativeTrim = String.prototype.trim; 853 | 854 | function escapeRegExp(str) { 855 | if (str == null) return ''; 856 | return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); 857 | } 858 | 859 | var defaultToWhiteSpace = function defaultToWhiteSpace(characters) { 860 | if (characters == null) return '\\s';else if (characters.source) return characters.source;else return '[' + escapeRegExp(characters) + ']'; 861 | }; 862 | 863 | function trim(str, characters) { 864 | if (str == null) return ''; 865 | if (!characters && nativeTrim) return nativeTrim.call(str); 866 | characters = defaultToWhiteSpace(characters); 867 | return String(str).replace(new RegExp('\^' + characters + '+|' + characters + '+$', 'g'), ''); 868 | } 869 | 870 | function dasherize(str) { 871 | return trim(str).replace(/([A-Z])/g, '-$1').replace(/[-_\s]+/g, '-').toLowerCase(); 872 | } 873 | 874 | // Copies a variable number of methods from source to target. 875 | function rebind(target, source) { 876 | var i = 1, 877 | n = arguments.length, 878 | method = void 0; 879 | while (++i < n) { 880 | target[method = arguments[i]] = d3_rebind(target, source, source[method]); 881 | }return target; 882 | } 883 | 884 | // Method is assumed to be a standard D3 getter-setter: 885 | // If passed with no arguments, gets the value. 886 | // If passed with arguments, sets the value and returns the target. 887 | function d3_rebind(target, source, method) { 888 | return function () { 889 | var value = method.apply(source, arguments); 890 | return value === source ? target : value; 891 | }; 892 | } 893 | 894 | function functor(v) { 895 | return typeof v === 'function' ? v : function () { 896 | return v; 897 | }; 898 | } 899 | 900 | /* jshint ignore:end */ 901 | 902 | exports.default = { 903 | $: $, 904 | $$: $$, 905 | 906 | dasherize: dasherize, 907 | debounce: debounce, 908 | 909 | deepExtend: deepExtend, 910 | extend: extend, 911 | 912 | isElement: isElement, 913 | isFunction: isFunction, 914 | isNaN: isNaN, 915 | isNumber: isNumber, 916 | isObject: isObject, 917 | on: on, 918 | off: off, 919 | trim: trim, 920 | 921 | rebind: rebind, 922 | functor: functor, 923 | 924 | removeAllChildren: removeAllChildren, 925 | bindMouseEventsToDispatcher: bindMouseEventsToDispatcher 926 | }; 927 | 928 | /***/ }, 929 | /* 6 */ 930 | /***/ function(module, exports, __webpack_require__) { 931 | 932 | 'use strict'; 933 | 934 | Object.defineProperty(exports, "__esModule", { 935 | value: true 936 | }); 937 | 938 | var _d3Dispatch = __webpack_require__(3); 939 | 940 | var _helper = __webpack_require__(5); 941 | 942 | var _helper2 = _interopRequireDefault(_helper); 943 | 944 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 945 | 946 | function NOOP(selection, done) { 947 | done(); 948 | } 949 | 950 | function Chartlet(enter, update, exit, customEvents) { 951 | update = update || NOOP; 952 | exit = exit || NOOP; 953 | customEvents = customEvents || []; 954 | var _propertyCache = {}; 955 | var _dispatch = _d3Dispatch.dispatch.apply(this, ['enterDone', 'updateDone', 'exitDone'].concat(customEvents)); 956 | 957 | // getter and setter of chartlet properties 958 | 959 | function property(name, value) { 960 | // if functioning as a setter, set property in cache 961 | if (arguments.length > 1) { 962 | _propertyCache[name] = _helper2.default.functor(value); 963 | return this; 964 | } 965 | 966 | // functioning as a getter, return property accessor 967 | return _helper2.default.functor(_propertyCache[name]); 968 | } 969 | 970 | function getPropertyValue(name, d, i) { 971 | return property(name)(d, i); 972 | } 973 | 974 | function _wrapAction(action, doneHookName) { 975 | return function (selection) { 976 | action(selection, _helper2.default.debounce(function (d, i) { 977 | _dispatch.call(doneHookName, this, selection); 978 | }), 5); 979 | }; 980 | } 981 | 982 | function inheritPropertyFrom(chartlet, from, to) { 983 | _propertyCache[to || from] = function (d, i) { 984 | return chartlet.property(from)(d, i); 985 | }; 986 | return this; 987 | } 988 | 989 | function inheritPropertiesFrom(chartlet, froms, tos) { 990 | froms.forEach(function (from, i) { 991 | inheritPropertyFrom(chartlet, from, tos && i < tos.length ? tos[i] : undefined); 992 | }); 993 | return this; 994 | } 995 | 996 | function publishEventsTo(foreignDispatcher) { 997 | customEvents.forEach(function (event) { 998 | _dispatch.on(event, function () { 999 | var args = Array.prototype.slice.call(arguments); 1000 | foreignDispatcher.apply(event, this, args); 1001 | }); 1002 | }); 1003 | return this; 1004 | } 1005 | 1006 | function getCustomEventNames() { 1007 | return customEvents; 1008 | } 1009 | 1010 | // exports 1011 | var exports = { 1012 | // for use by child chartlet 1013 | getDispatcher: function getDispatcher() { 1014 | return _dispatch; 1015 | }, 1016 | 1017 | getPropertyValue: getPropertyValue, 1018 | inheritPropertyFrom: inheritPropertyFrom, 1019 | inheritPropertiesFrom: inheritPropertiesFrom, 1020 | publishEventsTo: publishEventsTo, 1021 | getCustomEventNames: getCustomEventNames, 1022 | 1023 | property: property, 1024 | enter: _wrapAction(enter, 'enterDone'), 1025 | update: _wrapAction(update, 'updateDone'), 1026 | exit: _wrapAction(exit, 'exitDone') 1027 | }; 1028 | 1029 | // bind events to exports 1030 | _helper2.default.rebind(exports, _dispatch, 'on'); 1031 | 1032 | // return exports 1033 | return exports; 1034 | } 1035 | 1036 | exports.default = Chartlet; 1037 | 1038 | /***/ }, 1039 | /* 7 */ 1040 | /***/ function(module, exports, __webpack_require__) { 1041 | 1042 | 'use strict'; 1043 | 1044 | Object.defineProperty(exports, "__esModule", { 1045 | value: true 1046 | }); 1047 | exports.createChart = createChart; 1048 | 1049 | var _skeleton = __webpack_require__(1); 1050 | 1051 | var _skeleton2 = _interopRequireDefault(_skeleton); 1052 | 1053 | var _helper = __webpack_require__(5); 1054 | 1055 | var _helper2 = _interopRequireDefault(_helper); 1056 | 1057 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 1058 | 1059 | /** 1060 | * Return a constructor for your custom chart type 1061 | * @param Object defaultOptions default options for your chart 1062 | * @param Array[String] customEvents list of custom events this chart will dispatch 1063 | * @param Function constructor constructor function function(skeleton){...} 1064 | * @return Function function(chartNode, options) that return your chart 1065 | */ 1066 | function createChart(defaultOptions, customEvents, constructor) { 1067 | var newChartClass = function newChartClass(chartNode, options) { 1068 | var skeleton = new _skeleton2.default(chartNode, _helper2.default.deepExtend({}, defaultOptions, options), customEvents); 1069 | if (constructor) constructor(skeleton); 1070 | return skeleton; 1071 | }; 1072 | 1073 | customEvents = customEvents ? customEvents : []; 1074 | 1075 | /** 1076 | * Return supported custom events for this chart class. 1077 | * This is a static method for class, not instance method. 1078 | * @return Array[String] names of custom events 1079 | */ 1080 | newChartClass.getCustomEvents = function () { 1081 | return customEvents; 1082 | }; 1083 | 1084 | return newChartClass; 1085 | } 1086 | 1087 | /***/ } 1088 | /******/ ]) 1089 | }); 1090 | ; -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/d3kit/dist/d3kit.min.js: -------------------------------------------------------------------------------- 1 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("d3-selection"),require("d3-dispatch")):"function"==typeof define&&define.amd?define(["d3-selection","d3-dispatch"],t):"object"==typeof exports?exports.d3Kit=t(require("d3-selection"),require("d3-dispatch")):e.d3Kit=t(e.d3,e.d3)}(this,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0}),t.helper=t.LayerOrganizer=t.Chartlet=t.Skeleton=t.factory=void 0;var o=n(1);Object.defineProperty(t,"Skeleton",{enumerable:!0,get:function(){return r(o)["default"]}});var i=n(6);Object.defineProperty(t,"Chartlet",{enumerable:!0,get:function(){return r(i)["default"]}});var u=n(4);Object.defineProperty(t,"LayerOrganizer",{enumerable:!0,get:function(){return r(u)["default"]}});var a=n(5);Object.defineProperty(t,"helper",{enumerable:!0,get:function(){return r(a)["default"]}});var f=n(7);t.factory={createChart:f.createChart}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t,n){function r(e,t){return 0===arguments.length?P:(P=e,t||Z.call("data",this,e),C)}function o(e,t){return 0===arguments.length?L:(L=l["default"].deepExtend(L,e),e&&(e.margin?c(t):e.offset&&a()),t||Z.call("options",this,e),C)}function a(){W.attr("transform","translate("+(L.margin.left+L.offset[0])+","+(L.margin.top+L.offset[1])+")")}function c(e){a(),T=S-L.margin.left-L.margin.right,k=D-L.margin.top-L.margin.bottom,e||Z.call("resize",this,[S,D,T,k])}function p(e,t){return 0===arguments.length?L.margin:(L.margin=l["default"].extend(L.margin,e),c(t),C)}function h(e){return 0===arguments.length?L.offset:(L.offset=e,a(),C)}function m(t,n){if(0===arguments.length||null===t||void 0===t)return S;if(S=l["default"].isNumber(t)?+t:"auto"==t.trim().toLowerCase()?e.clientWidth:+(t+"").replace(/px/gi,"").trim(),l["default"].isNaN(S))throw Error("invalid width: "+S);return S=Math.floor(S),T=S-L.margin.left-L.margin.right,q.attr("width",S),n||Z.call("resize",this,[S,D,T,k]),C}function g(t,n){if(0===arguments.length||null===t||void 0===t)return D;if(D=l["default"].isNumber(t)?+t:"auto"==t.trim().toLowerCase()?e.clientHeight:+(t+"").replace(/px/gi,"").trim(),l["default"].isNaN(D))throw Error("invalid height: "+D);return D=Math.floor(D),k=D-L.margin.top-L.margin.bottom,q.attr("height",D),n||Z.call("resize",this,[S,D,T,k]),C}function v(e,t){return 0===arguments.length?[S,D]:(m(e[0],!0),g(e[1],t),C)}function y(e){return 0===arguments.length?F:F!=e?N(e,$):C}function b(e){return 0===arguments.length?$:$!=e?N(F,e):C}function w(e){return 0===arguments.length?R:(R=null!==e&&void 0!==e&&""!==e&&e!==!1&&"false"!==(e+"").toLowerCase()&&(!!l["default"].isNumber(e)&&(0!==+e&&+e)),C)}function x(){if(H)switch($){case"dom":l["default"].off(e,"resize",H);break;default:case"window":l["default"].off(window,"resize",H)}return H=null,C}function j(t){if(t)switch($){case"dom":l["default"].on(e,"resize",t);break;default:case"window":l["default"].on(window,"resize",t)}return H=t,C}function N(e,t){if(e=(!e||"false"!=(e+"").toLowerCase())&&e,t=t||$,e!=F)x(),F=e,$=t,e&&(H=l["default"].debounce(function(){R?(M(F,!0),_(R)):M(F)},100),j(H));else if(t!=$){var n=H;x(),$=t,j(n)}return H&&H(),C}function E(){return n||[]}function O(e){var t=C;return l["default"].isObject(e)&&Object.keys(e).forEach(function(n){t[n]=e[n]}),t}function M(e,t){switch(e){case"all":case"full":case"both":v(["auto","auto"],t);break;case"height":g("auto",t);break;default:case"width":m("auto",t)}return C}function _(e,t){var n=S,r=D;if(!l["default"].isNumber(e))throw"Invalid ratio: must be a Number";if(e=+e,(n/r).toFixed(4)==e.toFixed(4))return C;var o=Math.floor(n/e);return o>r?m(Math.floor(r*e),t):g(o,t),C}function z(){return null!==P&&void 0!==P}function A(){return T>0&&k>0}var C={};e=l["default"].$(e);var P=null,L=l["default"].deepExtend({},s,t),S=0,D=0,T=0,k=0,$="window",F=!1,H=null,R=!1,q=(0,i.select)(e).append("svg"),W=q.append("g");a();var I=new f["default"](W),K=n?n.concat(d):d,Z=u.dispatch.apply(this,K);return v([L.initialWidth,L.initialHeight]),l["default"].extend(C,{getCustomEventNames:E,getDispatcher:function(){return Z},getInnerWidth:function(){return T},getInnerHeight:function(){return k},getLayerOrganizer:function(){return I},getRootG:function(){return W},getSvg:function(){return q},data:r,options:o,margin:p,offset:h,width:m,height:g,dimension:v,autoResize:y,autoResizeDetection:b,autoResizeToAspectRatio:w,hasData:z,hasNonZeroArea:A,mixin:O,resizeToFitContainer:M,resizeToAspectRatio:_}),l["default"].rebind(C,Z,"on"),C}Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),u=n(3),a=n(4),f=r(a),c=n(5),l=r(c),s={margin:{top:30,right:30,bottom:30,left:30},offset:[.5,.5],initialWidth:720,initialHeight:500},d=["data","options","resize"];t["default"]=o},function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=function(e,t){function n(e,n,r){var o=r?r+"."+n:n;if(c.hasOwnProperty(o))throw"invalid or duplicate layer id: "+o;var u=e.append(t).classed(i["default"].dasherize(n)+"-layer",!0);return c[o]=u,u}function r(e,t,o){if(Array.isArray(t))return t.map(function(t){r(e,t,o)});if(i["default"].isObject(t)){var u=Object.keys(t)[0],a=n(e,u,o);return r(a,t[u],o?o+"."+u:u),a}return n(e,t,o)}function o(t){return r(e,t)}function u(e){return Array.isArray(e)?e.map(o):o(e)}function a(e){return c[e]}function f(e){return!!c[e]}var c={};return t=t||"g",{create:u,get:a,has:f}};var o=n(5),i=r(o)},function(e,t){"use strict";function n(e,t,n){return e.on("click",function(e,r){t.call(n+"Click",this,e,r)}).on("mouseover",function(e,r){t.call(n+"MouseOver",this,e,r)}).on("mousemove",function(e,r){t.call(n+"MouseMove",this,e,r)}).on("mouseout",function(e,r){t.call(n+"MouseOut",this,e,r)})}function r(e,t){return t?e.selectAll("*").remove():e.selectAll("*").transition().style("opacity",0).remove()}function o(e){return"object"===("undefined"==typeof HTMLElement?"undefined":x(HTMLElement))?e instanceof HTMLElement:e&&"object"===("undefined"==typeof e?"undefined":x(e))&&null!==e&&1===e.nodeType&&"string"==typeof e.nodeName}function i(e){return o(e)?e:document.querySelector(e)}function u(e){return Array.isArray(e)?e:[].slice.call(document.querySelectorAll(e))}function a(e){e=e||{};for(var t=1;t1?(h[e]=f["default"].functor(t),this):f["default"].functor(h[e])}function a(e,t,n){return i(e)(t,n)}function c(e,t){return function(n){e(n,f["default"].debounce(function(e,r){m.call(t,this,n)}),5)}}function l(e,t,n){return h[n||t]=function(n,r){return e.property(t)(n,r)},this}function s(e,t,n){return t.forEach(function(t,r){l(e,t,n&&r (http://kristw.yellowpigz.com)", 17 | "Robert Harris " 18 | ], 19 | "license": "MIT", 20 | "main": "dist/d3kit.min.js", 21 | "files": [ 22 | "src/**/*.*", 23 | "dist/*.*" 24 | ], 25 | "peerDependencies": { 26 | "d3-dispatch": "~1.0.1", 27 | "d3-selection": "~1.0.2" 28 | }, 29 | "devDependencies": { 30 | "babel-core": "^6.3.21", 31 | "babel-loader": "^6.2.0", 32 | "babel-plugin-transform-object-assign": "^6.1.12", 33 | "babel-preset-es2015": "^6.3.13", 34 | "bower": "^1.6.5", 35 | "browser-sync": "~2.14.0", 36 | "chai": "^3.5.0", 37 | "d3-dispatch": "~1.0.1", 38 | "d3-selection": "~1.0.2", 39 | "del": "^2.2.0", 40 | "eslint": "^3.1.1", 41 | "eslint-config-airbnb": "^9.0.1", 42 | "eslint-plugin-import": "^1.12.0", 43 | "eslint-plugin-jsx-a11y": "^2.0.1", 44 | "eslint-plugin-mocha": "^4.3.0", 45 | "gh-pages": "^0.11.0", 46 | "gulp": "^3.9.0", 47 | "gulp-load-plugins": "^1.1.0", 48 | "gulp-newer": "~1.1.0", 49 | "gulp-rename": "^1.2.2", 50 | "gulp-uglify": "~1.5.4", 51 | "istanbul-instrumenter-loader": "~0.1.3", 52 | "karma": "~0.13.15", 53 | "karma-chai": "^0.1.0", 54 | "karma-coverage": "~0.5.3", 55 | "karma-mocha": "^1.1.1", 56 | "karma-mocha-reporter": "^2.1.0", 57 | "karma-phantomjs-launcher": "^1.0.1", 58 | "karma-sourcemap-loader": "~0.3.6", 59 | "karma-webpack": "~1.7.0", 60 | "mocha": "^3.0.2", 61 | "pkgfiles": "^2.3.0", 62 | "run-sequence": "^1.1.5", 63 | "webpack": "^1.12.9", 64 | "webpack-stream": "^3.1.0" 65 | }, 66 | "scripts": { 67 | "gh-pages": "npm run build && gh-pages -d dist", 68 | "test": "karma start --single-run", 69 | "tdd": "karma start", 70 | "build": "NODE_ENV=production gulp build", 71 | "dev": "gulp", 72 | "start": "NODE_ENV=production gulp", 73 | "eslint": "eslint --ignore-path .gitignore \"src/**/*.@(js|jsx)\"", 74 | "eslint-fix": "eslint --fix --ignore-path .gitignore \"src/**/*.@(js|jsx)\"", 75 | "preversion": "npm test", 76 | "version": "npm run build && git add -A dist", 77 | "postversion": "git push ; git push --tags; pkgfiles", 78 | "prepublish": "pkgfiles" 79 | }, 80 | "engines": { 81 | "node": "~6.3" 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/treebard3/README.md: -------------------------------------------------------------------------------- 1 | Block-a-Day #12. Update of [Treemap Bar Chart](https://bl.ocks.org/cmgiven/018fd027d443b177e18fffb9afcdb5bd) to enable zooming into a specific country on click. 2 | 3 | **Data Sources:** [Census](https://www.census.gov/foreign-trade/balance/index.html) 4 | 5 | **What I Learned:** In a bit of treemap implementation trivia, nodes without a parent value of zero (i.e. those in a different continent than the selected country) will have `NaN` for their position values, as a result of a divide by zero, while those with a parent value but no value of their own will have position values, although width and height of, obviously, zero. I was originally just catching the `NaN`s, but this resulted in nodes flying to two different positions, thus the checking of `d.value` to determine how to position the nodes. 6 | 7 | **What I'd Do With More Time:** Might be interesting if the transition was to vertically expand and fade the non-selected countries, to reinforce the idea of zooming in. 8 | 9 | ## Block-a-Day 10 | 11 | Just what it sounds like. For fifteen days, I will make a [D3.js v4](https://d3js.org) block every single day. Rules: 12 | 13 | 1. Ideas over implementation. Do something novel, don't sweat the details. 14 | 2. No more than two hours can be spent on coding (give or take). 15 | 3. Every. Single. Day. 16 | 17 | ### Previously 18 | 19 | * [Map to Force-Directed Graph](https://bl.ocks.org/cmgiven/4cfa1a95f9b952622280a90138842b79) 20 | * [Brushable Scatterplot/Choropleth](https://bl.ocks.org/cmgiven/abca90f6ba5f0a14c54d1eb952f8949c) 21 | * [Treemap Bar Chart](https://bl.ocks.org/cmgiven/018fd027d443b177e18fffb9afcdb5bd) 22 | * [Triangular Scatterplot](https://bl.ocks.org/cmgiven/a0f58034cea5331a814b30b74aacb8af) 23 | * [Choropleth with Animated Stripes](http://bl.ocks.org/cmgiven/09140e2ac8119340048f62d1b241977e) 24 | * [Collatz Conjecture](https://bl.ocks.org/cmgiven/231f779f9655025f38b5b4b828f3b7b0) 25 | * [Bouncing Logo](https://bl.ocks.org/cmgiven/a325f14550a65dc8ff6898ef0f9feeb4) 26 | * [Rectangular Collision Detection](https://bl.ocks.org/cmgiven/547658968d365bcc324f3e62e175709b) 27 | * [Demers Catogram](https://bl.ocks.org/cmgiven/9d6bc46cf586738458c13dd2b5dadd84) 28 | * [Gooey Exploding Scatterplot](https://bl.ocks.org/cmgiven/e5dfe0888968ee8c507f5469a4d62b6f) 29 | * [Zoomable Choropleth](https://bl.ocks.org/cmgiven/d39ec773c4f063a463137748097ff52f) 30 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/treebard3/treebard3.css: -------------------------------------------------------------------------------- 1 | .treebar label { 2 | font-family: sans-serif; 3 | font-size: 14px; 4 | position: absolute; 5 | left: 92px; top: 26px; 6 | } 7 | .treebar .axis .domain { display: none; } 8 | .treebar .axis line { stroke: #ccc; } 9 | .treebar .axis.x0 text { font-weight: 700; } 10 | .treebar .hover-active rect { opacity: .75; } 11 | .treebar .hover-active rect.hover { opacity: 1; } 12 | -------------------------------------------------------------------------------- /inst/htmlwidgets/lib/treebard3/treebard3.js: -------------------------------------------------------------------------------- 1 | var DEFAULT_OPTIONS = { 2 | margin: { top: 15, right: 15, bottom: 40, left: 60 }, 3 | width: 960, 4 | height: 500, 5 | color: d3.scaleOrdinal(d3.schemeCategory20), 6 | id: "id", 7 | value: "value", 8 | tile: "Squarify" 9 | }; 10 | 11 | var CUSTOM_EVENTS = [ 12 | "nodeClick", 13 | "nodeMouseover", 14 | "nodeMouseout", 15 | "updateComplete" 16 | ]; 17 | 18 | var Treebar = d3Kit.factory.createChart( 19 | DEFAULT_OPTIONS, 20 | CUSTOM_EVENTS, 21 | constructor 22 | ); 23 | 24 | function constructor(skeleton) { 25 | 26 | var layers = skeleton.getLayerOrganizer(); 27 | var dispatch = skeleton.getDispatcher(); 28 | var options = skeleton.options(); 29 | 30 | layers.create(['x-axis', 'y-axis', 'content']); 31 | 32 | var visualize = d3Kit.helper.debounce(function(){ 33 | 34 | if(!skeleton.hasData()){ 35 | d3Kit.helper.removeAllChildren(layers.get('content')); 36 | return; 37 | } 38 | 39 | var data = skeleton.data(); 40 | 41 | var width = skeleton.getInnerWidth(); 42 | var height = skeleton.getInnerHeight(); 43 | 44 | var root = d3.hierarchy(data) 45 | .sum(function (d) { return d[options.value] }); 46 | 47 | var depth1Data = root.children; 48 | depth1Data.sort(function (a, b) { 49 | return a.data[options.id] - b.data[options.id] 50 | }); 51 | 52 | var svg = layers.get('content'); 53 | 54 | var color = options.color; 55 | 56 | var x0 = d3.scaleBand() 57 | .domain( 58 | depth1Data.map(function (d) { 59 | return d.data[options.id] 60 | }).sort() 61 | ) 62 | .range([0, width]) 63 | .padding(0.15); 64 | 65 | var x1 = d3.scaleBand() 66 | .range([0, width]) 67 | .domain( 68 | d3.set( 69 | d3.merge(depth1Data.map( 70 | function (d) { 71 | var ids = d.data.children.map(function(dd){ 72 | return dd[options.id]; 73 | }); 74 | return ids; 75 | } 76 | ))).values() 77 | ) 78 | .rangeRound([0, x0.bandwidth()]) 79 | .paddingInner(0.1); 80 | 81 | var y = d3.scaleLinear() 82 | .domain([0, d3.max(depth1Data, function (d) { 83 | return d3.max(d.children, function (e) { return e.value; }); 84 | })]).nice() 85 | .range([0,height]); 86 | 87 | var x0Axis = d3.axisBottom() 88 | .scale(x0) 89 | .tickSize(0) 90 | 91 | var x1Axis = d3.axisBottom() 92 | .scale(x1); 93 | 94 | var yAxis = d3.axisLeft() 95 | .tickSize(-width) 96 | .scale(y.copy().range([height, 0])); 97 | 98 | layers.get('x-axis') 99 | .attr('transform', 'translate(0,' + (height + 22) + ')') 100 | .classed('axis', true) 101 | .call(x0Axis); 102 | 103 | layers.get('y-axis') 104 | .classed('axis', true) 105 | .call(yAxis); 106 | 107 | var t = d3.transition(); 108 | 109 | update(); 110 | 111 | function sum(d) { 112 | return !options._selected || options._selected === d[options.id] ? d[options.value] : 0; 113 | } 114 | 115 | function update() { 116 | root.sum(sum); 117 | 118 | var depth1 = svg.selectAll('.depth1') 119 | .data(depth1Data, function (d) { return d.data[options.id]; }); 120 | 121 | depth1 = depth1.enter().append('g') 122 | .attr('class', 'depth1') 123 | .merge(depth1) 124 | .attr('transform', function (d) { 125 | return 'translate(' + x0(d.data[options.id]) + ',0)'; 126 | }); 127 | 128 | depth1.each(function(d1){ 129 | var ax1 = d3.select(this).selectAll('.x1.axis').data([0]); 130 | ax1 = ax1.enter() 131 | .append('g') 132 | .merge(ax1); 133 | ax1.attr('class', 'x1 axis') 134 | .attr('transform', 'translate(0,' + height + ')') 135 | .call(x1Axis); 136 | }); 137 | 138 | var depth2Data = d3.merge(depth1Data.map(function (d) { return d.children })); 139 | 140 | var depth2Ids = d3.set( 141 | depth2Data.map( 142 | function(d){return d.data[options.id]} 143 | ) 144 | ).values().sort(d3.ascending); 145 | 146 | y.domain([0, d3.max(depth2Data.map(function (d) { return d.value }))]).nice(); 147 | 148 | // We use a copied Y scale to invert the range for display purposes 149 | yAxis.scale(y.copy().range([height, 0])); 150 | layers.get('y-axis').transition(t).call(yAxis); 151 | 152 | var depth2 = depth1.selectAll('.depth2') 153 | .data(function (d) { 154 | return d.children; 155 | }, 156 | function (d) { 157 | return d.data[options.id]; 158 | } 159 | ); 160 | 161 | depth2 = depth2.enter().append('g') 162 | .attr('class', 'depth2') 163 | .merge(depth2) 164 | .attr('transform', function (d) { 165 | return 'translate(' + x1(d.data[options.id]) + ',' + height + ')'; 166 | }) 167 | .each(function (d) { 168 | // UPDATE + ENTER 169 | // Note that we can use .each on selections as a way to perform operations 170 | // at a given depth of the hierarchy tree. 171 | d.children.sort(function (a, b) { 172 | return depth2Ids.indexOf(b.data[options.id]) - 173 | depth2Ids.indexOf(a.data[options.id]); 174 | }) 175 | d.children.forEach(function (d) { 176 | d.sort(function (a, b) { return b.value - a.value }); 177 | }); 178 | d.treemap = d3.treemap().tile(d3["treemap" + options.tile]); 179 | 180 | // The treemap layout must be given a root node, so we make a copy of our 181 | // child node, which creates a new tree from the branch. 182 | d.treemapRoot = d.copy(); 183 | d.treemap.size([x1.bandwidth(), y(d.value)])(d.treemapRoot); 184 | }); 185 | 186 | // d3.hierarchy gives us a convenient way to access the parent datum. This line 187 | // adds an index property to each node that we'll use for the transition delay. 188 | root.each(function (d) { 189 | d.index = d.parent ? d.parent.children.indexOf(d) : 0 190 | }); 191 | 192 | depth2.transition(t) 193 | .delay(function (d, i) { return d.parent.index * 150 + i * 50 }) 194 | .attr('transform', function (d) { 195 | return 'translate(' + x1(d.data[options.id]) + ',' + (height - y(d.value)) + ')'; 196 | }); 197 | 198 | var depth3 = depth2.selectAll('.depth3') 199 | // Note that we're using our copied branch. 200 | .data( 201 | function (d) { 202 | return d.treemapRoot.children; 203 | }, 204 | function (d) { 205 | return d.data[options.id]; 206 | } 207 | ); 208 | 209 | depth3 = depth3.enter().append('g') 210 | .attr('class', 'depth3') 211 | .merge(depth3); 212 | 213 | var depth4 = depth3.selectAll('.depth4') 214 | .data(function (d) { 215 | return d.children; 216 | }, 217 | function (d) { 218 | return d.data[options.id]; 219 | }); 220 | 221 | var enterDepth4 = depth4.enter().append('rect') 222 | .attr('class', 'depth4'); 223 | 224 | depth4 = depth4.merge(enterDepth4) 225 | .attr('x', function (d) { return d.value ? d.x0 : x1.bandwidth() / 2; }) 226 | .attr('width', function (d) { return d.value ? d.x1 - d.x0 : 0; }) 227 | .attr('y', 0) 228 | .attr('height', 0) 229 | .style('fill', function (d) { 230 | return (d.data && d.data.color) ? d.data.color : color(d.parent.data[options.id]); 231 | }); 232 | 233 | depth4 234 | .on('mouseover', function (d,i) { 235 | svg.classed('hover-active', true); 236 | depth4.classed('hover', function (e) { 237 | return e.data[options.id] === d.data[options.id]; 238 | }) 239 | dispatch.apply('nodeMouseover', this, [d,i]); 240 | }) 241 | .on('mouseout', function (d,i) { 242 | svg.classed('hover-active', false); 243 | depth4.classed('hover', false); 244 | dispatch.apply('nodeMouseout', this, [d,i]); 245 | }) 246 | .on('click', function (d, i) { 247 | options._selected = options._selected === d.data[options.id] ? null : d.data[options.id]; 248 | dispatch.apply('nodeClick', this, [d,i]); 249 | update(); 250 | }) 251 | .append('title') 252 | .text(function (d) { return d.data[options.id] }); 253 | 254 | depth4.filter(function (d) { return d.data[options.id] === options._selected }) 255 | .each(function (d) { d3.select(this.parentNode).raise() }) 256 | .raise(); 257 | 258 | depth4 259 | .transition(t) 260 | .attr('x', function (d) { 261 | return d.value ? d.x0 : x1.bandwidth() / 2; 262 | }) 263 | .attr('width', function (d) { 264 | return d.value ? d.x1 - d.x0 : 0; 265 | }) 266 | .attr('y', function (d) { 267 | return d.value ? d.y0 : d.parent.parent.y1 / 2; 268 | }) 269 | .attr('height', function (d) { 270 | return d.value ? d.y1 - d.y0 : 0; 271 | }); 272 | 273 | dispatch.apply('updateComplete', this, [skeleton]); 274 | } 275 | }, 10); 276 | 277 | skeleton 278 | .autoResize('all') 279 | .on('options', visualize) 280 | .on('data', visualize) 281 | .on('resize', visualize); 282 | } 283 | 284 | -------------------------------------------------------------------------------- /inst/htmlwidgets/treebar.js: -------------------------------------------------------------------------------- 1 | HTMLWidgets.widget({ 2 | 3 | name: 'treebar', 4 | 5 | type: 'output', 6 | 7 | factory: function(el, width, height) { 8 | 9 | var instance = {}; 10 | 11 | return { 12 | 13 | renderValue: function(x) { 14 | 15 | instance.x = x; 16 | 17 | // rare case but currently a nesting function 18 | // in R that I have written will supply 19 | // an array, so in case of array, 20 | // we will take the first element 21 | if(Array.isArray(x.data)) x.data = x.data[0]; 22 | 23 | // ugly and will fix but for now 24 | // empty and re-render in dynamic 25 | el.innerHTML = ""; 26 | var treebar = new Treebar(el, x.options); 27 | 28 | treebar 29 | .width(el.getBoundingClientRect().width) 30 | .height(el.getBoundingClientRect().height) 31 | .data(x.data); 32 | 33 | instance.treebar = treebar; 34 | 35 | }, 36 | 37 | resize: function(width, height) { 38 | 39 | 40 | }, 41 | 42 | instance: instance 43 | 44 | }; 45 | } 46 | }); -------------------------------------------------------------------------------- /inst/htmlwidgets/treebar.yaml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - name: d3kit 3 | version: 2.0.0 4 | src: htmlwidgets/lib/d3kit/dist 5 | script: d3kit.js 6 | - name: treebard3 7 | version: 0.1 8 | src: htmlwidgets/lib/treebard3 9 | script: treebard3.js 10 | stylesheet: treebard3.css 11 | -------------------------------------------------------------------------------- /man/treebar-shiny.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/treebar.R 3 | \name{treebar-shiny} 4 | \alias{renderTreebar} 5 | \alias{treebar-shiny} 6 | \alias{treebarOutput} 7 | \title{Shiny bindings for treebar} 8 | \usage{ 9 | treebarOutput(outputId, width = "100\%", height = "400px") 10 | 11 | renderTreebar(expr, env = parent.frame(), quoted = FALSE) 12 | } 13 | \arguments{ 14 | \item{outputId}{output variable to read from} 15 | 16 | \item{width, height}{Must be a valid CSS unit (like \code{'100\%'}, 17 | \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a 18 | string and have \code{'px'} appended.} 19 | 20 | \item{expr}{An expression that generates a treebar} 21 | 22 | \item{env}{The environment in which to evaluate \code{expr}.} 23 | 24 | \item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This 25 | is useful if you want to save an expression in a variable.} 26 | } 27 | \description{ 28 | Output and render functions for using treebar within Shiny 29 | applications and interactive Rmd documents. 30 | } 31 | 32 | -------------------------------------------------------------------------------- /man/treebar.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/treebar.R 3 | \name{treebar} 4 | \alias{treebar} 5 | \title{Interactive Zoomable Treemap Bar Charts} 6 | \usage{ 7 | treebar(data = NULL, ..., width = NULL, height = NULL, elementId = NULL) 8 | } 9 | \arguments{ 10 | \item{data}{\code{string} json data of a four level d3.js hierarchy. 11 | inflexible now but will improve} 12 | 13 | \item{...}{additional arguments currently supports 14 | id, name, and tile for customizing your chart} 15 | } 16 | \description{ 17 | htmlwidget based off Chris Given's 18 | \href{http://bl.ocks.org/cmgiven/4541f6de7b6fbef482aaa43f3a71f8d4}{Treemap Bar} 19 | } 20 | \examples{ 21 | #devtools::install_github("timelyportfolio/treebar") 22 | 23 | library(stringr) 24 | library(treebar) 25 | library(jsonlite) 26 | 27 | ## make it a more generic hierarchy 28 | ## normally this step is not necessary 29 | json <- str_replace_all( 30 | readLines(system.file("example/data.json",package="treebar")), 31 | "(country)|(continent)|(year)|(type)", 32 | "id" 33 | ) 34 | 35 | data <- fromJSON(json, simplifyDataFrame=FALSE) 36 | 37 | treebar(data) 38 | 39 | 40 | # also allows different treemap tiling options 41 | library(htmltools) 42 | 43 | browsable( 44 | tagList( 45 | lapply( 46 | c("Squarify", "Binary", "SliceDice", "Slice", "Dice"), 47 | function(tile){ 48 | tags$div( 49 | style = "float:left; display:inline;", 50 | tags$h3(tile), 51 | treebar( 52 | data, 53 | tile = tile, 54 | height = 250, 55 | width = 400 56 | ) 57 | ) 58 | } 59 | ) 60 | ) 61 | ) 62 | 63 | 64 | # use different key for id and value 65 | json <- str_replace_all( 66 | readLines("./inst/example/data.json"), 67 | "(country)|(continent)|(year)|(type)", 68 | "name" 69 | ) 70 | 71 | json <- str_replace_all( 72 | json, 73 | "(value)", 74 | "size" 75 | ) 76 | 77 | data <- fromJSON(json, simplifyDataFrame=FALSE) 78 | 79 | treebar(data, value="size", id="name") 80 | library(treebar) 81 | library(data.tree) 82 | 83 | portfolio <- data.frame( 84 | year = rep(2014:2016, each=8), 85 | asset = c(rep("equity",5),rep("fixed",3)), 86 | subasset = c("infotech","infotech","energy","energy","telecom","invgrade","invgrade","highyield"), 87 | ticker = rep(c("msft","apple","xom","cvx","t","pttrx","vficx","vwehx"),3), 88 | value = runif(24,50000,250000), 89 | stringsAsFactors = FALSE 90 | ) 91 | 92 | portfolio$pathString <- paste( 93 | "portfolio", 94 | portfolio$year, 95 | portfolio$asset, 96 | portfolio$subasset, 97 | portfolio$ticker, 98 | sep = "/" 99 | ) 100 | 101 | portfolio_tree <- as.Node(portfolio) 102 | 103 | treebar( 104 | ToListExplicit(portfolio_tree, unname=TRUE), 105 | id = "name" 106 | ) 107 | 108 | # also allows different tiling options 109 | library(htmltools) 110 | 111 | browsable( 112 | tagList( 113 | lapply( 114 | c("Squarify", "Binary", "SliceDice", "Slice", "Dice"), 115 | function(tile){ 116 | tags$div( 117 | style = "float:left; display:inline;", 118 | tags$h3(tile), 119 | treebar( 120 | ToListExplicit(portfolio_tree, unname=TRUE), 121 | id = "name", 122 | tile = tile, 123 | height = 250, 124 | width = 320 125 | ) 126 | ) 127 | } 128 | ) 129 | ) 130 | ) 131 | 132 | 133 | # play with treemap treepalette 134 | library(treemap) 135 | library(treebar) 136 | library(dplyr) 137 | 138 | portfolio \%>\% 139 | mutate(year = as.character(year)) \%>\% 140 | inner_join(treepalette(.,index=c("asset","subasset","ticker"))) \%>\% 141 | mutate(color = HCL.color) \%>\% 142 | select(-starts_with("HCL")) \%>\% 143 | d3r::d3_nest(value_cols=c("value","color")) \%>\% 144 | treebar() 145 | #devtools::install_github("timelyportfolio/treebar") 146 | 147 | library(stringr) 148 | library(treebar) 149 | library(jsonlite) 150 | library(shiny) 151 | 152 | ## make it a more generic hierarchy 153 | ## normally this step is not necessary 154 | json <- str_replace_all( 155 | readLines(system.file("example/data.json",package="treebar")), 156 | "(country)|(continent)|(year)|(type)", 157 | "id" 158 | ) 159 | 160 | data <- fromJSON(json, simplifyDataFrame=FALSE) 161 | 162 | shinyApp( 163 | ui = htmlwidgets::onRender( 164 | treebar(data), 165 | htmlwidgets::JS( 166 | ' 167 | function(el, x){ 168 | var chart = HTMLWidgets.getInstance(el).instance.treebar; 169 | chart.on("nodeMouseover", function(d,i){ 170 | Shiny.onInputChange("treebar_mouseover", d.data); 171 | }); 172 | } 173 | ' 174 | ) 175 | ), 176 | server = function(input, output, session){ 177 | observeEvent(input$treebar_mouseover,{ 178 | print(input$treebar_mouseover) 179 | }) 180 | } 181 | ) 182 | } 183 | 184 | -------------------------------------------------------------------------------- /thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/timelyportfolio/treebar/06d8aed34bc2632580ea9818b1512e8a8d8e6c9a/thumbnail.png -------------------------------------------------------------------------------- /treebar.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | BuildType: Package 16 | PackageUseDevtools: Yes 17 | PackageInstallArgs: --no-multiarch --with-keep.source 18 | PackageRoxygenize: rd,collate,namespace 19 | --------------------------------------------------------------------------------