In [1]:
require 'daru/view'
Out[1]:
true
In [2]:
Daru::View.plotting_library = :highcharts
Out[2]:
:highcharts
In [3]:
opts = {
      chart: {
        map: 'countries/in/in-all'
      },

      title: {
          text: 'Highmaps basic demo'
      },

      subtitle: {
          text: 'Source map: <a href="http://code.highcharts.com/mapdata/countries/in/in-all.js">India</a>'
      },

      mapNavigation: {
          enabled: true,
          buttonOptions: {
              verticalAlign: 'bottom'
          }
      },

      colorAxis: {
          min: 0
      }
    }

df = Daru::DataFrame.new(
  {
    countries: ['in-py', 'in-ld', 'in-wb', 'in-or', 'in-br', 'in-sk', 'in-ct', 'in-tn', 'in-mp', 'in-2984', 'in-ga', 'in-nl', 'in-mn', 'in-ar', 'in-mz', 'in-tr', 'in-3464', 'in-dl', 'in-hr', 'in-ch', 'in-hp', 'in-jk', 'in-kl', 'in-ka', 'in-dn', 'in-mh', 'in-as', 'in-ap', 'in-ml', 'in-pb', 'in-rj', 'in-up', 'in-ut', 'in-jh'],
    data: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
  }
)
map = Daru::View::Plot.new(df, opts, chart_class: 'map')
map.show_in_iruby
Out[3]:
In [4]:
opts = {
      chart: {
        map: 'countries/in/custom/in-all-andaman-and-nicobar'
      },

      title: {
          text: 'Highmaps basic demo'
      },

      subtitle: {
          text: 'Source map: <a href="http://code.highcharts.com/mapdata/countries/in/in-all.js">India</a>'
      },

      mapNavigation: {
          enabled: true,
          buttonOptions: {
              verticalAlign: 'bottom'
          }
      },

      colorAxis: {
          min: 0
      }
    }

df = Daru::DataFrame.new(
  {
    countries: ['in-5390', 'in-py', 'in-ld', 'in-an', 'in-wb', 'in-or', 'in-br', 'in-sk', 'in-ct', 'in-tn', 'in-mp', 'in-2984', 'in-ga', 'in-nl', 'in-mn', 'in-ar', 'in-mz', 'in-tr', 'in-3464', 'in-dl', 'in-hr', 'in-ch', 'in-hp', 'in-jk', 'in-kl', 'in-ka', 'in-dn', 'in-mh', 'in-as', 'in-ap', 'in-ml', 'in-pb', 'in-rj', 'in-up', 'in-ut', 'in-jh'],
    data: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]
  }
)
map = Daru::View::Plot.new(df, opts, chart_class: 'map')
map.show_in_iruby
Out[4]:
In [5]:
opts = {
      chart: {
        map: 'countries/us/us-all'
      },

      title: {
          text: 'Highmaps basic demo'
      },

      subtitle: {
          text: 'Source map: <a href="http://code.highcharts.com/mapdata/countries/us/us-all.js">United States of America</a>'
      },

      mapNavigation: {
          enabled: true,
          buttonOptions: {
              verticalAlign: 'bottom'
          }
      },

      colorAxis: {
          min: 0
      }
    }

data = [
    ['us-ma', 0],
    ['us-wa', 1],
    ['us-ca', 2],
    ['us-or', 3],
    ['us-wi', 4],
    ['us-me', 5],
    ['us-mi', 6],
    ['us-nv', 7],
    ['us-nm', 8],
    ['us-co', 9],
    ['us-wy', 10],
    ['us-ks', 11],
    ['us-ne', 12],
    ['us-ok', 13],
    ['us-mo', 14],
    ['us-il', 15],
    ['us-in', 16],
    ['us-vt', 17],
    ['us-ar', 18],
    ['us-tx', 19],
    ['us-ri', 20],
    ['us-al', 21],
    ['us-ms', 22],
    ['us-nc', 23],
    ['us-va', 24],
    ['us-ia', 25],
    ['us-md', 26],
    ['us-de', 27],
    ['us-pa', 28],
    ['us-nj', 29],
    ['us-ny', 30],
    ['us-id', 31],
    ['us-sd', 32],
    ['us-ct', 33],
    ['us-nh', 34],
    ['us-ky', 35],
    ['us-oh', 36],
    ['us-tn', 37],
    ['us-wv', 38],
    ['us-dc', 39],
    ['us-la', 40],
    ['us-fl', 41],
    ['us-ga', 42],
    ['us-sc', 43],
    ['us-mn', 44],
    ['us-mt', 45],
    ['us-nd', 46],
    ['us-az', 47],
    ['us-ut', 48],
    ['us-hi', 49],
    ['us-ak', 50],
    ['undefined', 51]
] 

df = Daru::DataFrame.new(
  {
    countries: data.map {|row| row[0]},
    data: data.map {|row| row[1]}
  }
)
map = Daru::View::Plot.new(df, opts, chart_class: 'map')
map.show_in_iruby
Out[5]:
In [6]:
opts = {
      chart_class: 'map',
      chart: {
        map: 'countries/af/af-all'
      },

      title: {
          text: 'Highmaps basic demo'
      },

      subtitle: {
          text: 'Source map: <a href="http://code.highcharts.com/mapdata/countries/af/af-all.js">Afghanistan</a>'
      },

      mapNavigation: {
          enabled: true,
          buttonOptions: {
              verticalAlign: 'bottom'
          }
      },

      colorAxis: {
          min: 0
      }
    }

data = [
    ['af-kt', 0],
    ['af-pk', 1],
    ['af-gz', 2],
    ['af-bd', 3],
    ['af-nr', 4],
    ['af-kr', 5],
    ['af-kz', 6],
    ['af-ng', 7],
    ['af-tk', 8],
    ['af-bl', 9],
    ['af-kb', 10],
    ['af-kp', 11],
    ['af-2030', 12],
    ['af-la', 13],
    ['af-lw', 14],
    ['af-pv', 15],
    ['af-sm', 16],
    ['af-vr', 17],
    ['af-pt', 18],
    ['af-bg', 19],
    ['af-hr', 20],
    ['af-bk', 21],
    ['af-jw', 22],
    ['af-bm', 23],
    ['af-gr', 24],
    ['af-fb', 25],
    ['af-sp', 26],
    ['af-fh', 27],
    ['af-hm', 28],
    ['af-nm', 29],
    ['af-2014', 30],
    ['af-oz', 31],
    ['af-kd', 32],
    ['af-zb', 33]
]

df = Daru::DataFrame.new(
  {
    countries: data.map {|row| row[0]},
    data: data.map {|row| row[1]}
  }
)
map = Daru::View::Plot.new(df, opts, chart_class: 'map')
map.show_in_iruby
Out[6]:
In [7]:
opts = {
      chart_class: 'map',
      chart: {
        map: 'countries/au/au-all'
      },

      title: {
          text: 'Highmaps basic demo'
      },

      subtitle: {
          text: 'Source map: <a href="http://code.highcharts.com/mapdata/countries/au/au-all.js">Australia</a>'
      },

      mapNavigation: {
          enabled: true,
          buttonOptions: {
              verticalAlign: 'bottom'
          }
      },

      colorAxis: {
          min: 0
      }
    }

data = [
    ['au-nt', 0],
    ['au-wa', 1],
    ['au-ct', 2],
    ['au-sa', 3],
    ['au-ql', 4],
    ['au-2557', 5],
    ['au-ts', 6],
    ['au-jb', 7],
    ['au-ns', 8],
    ['au-vi', 9]
]

df = Daru::DataFrame.new(
  {
    countries: data.map {|row| row[0]},
    data: data.map {|row| row[1]}
  }
)
map = Daru::View::Plot.new(df, opts, chart_class: 'map')
map.show_in_iruby
Out[7]:
In [8]:
opts = {
      chart_class: 'map',
      chart: {
          map: 'countries/bd/bd-all'
      },

      title: {
          text: 'Highmaps basic demo'
      },

      subtitle: {
          text: 'Source map: <a href="http://code.highcharts.com/mapdata/countries/bd/bd-all.js">Bangladesh</a>'
      },

      mapNavigation: {
          enabled: true,
          buttonOptions: {
              verticalAlign: 'bottom'
          }
      },

      colorAxis: {
          min: 0
      }
    }

df = Daru::DataFrame.new(
  {
    countries: ['bd-da', 'bd-kh', 'bd-ba', 'bd-cg', 'bd-sy', 'bd-rj', 'bd-rp'],
    data: [0, 1, 2, 3, 4, 5, 6]
  }
)
map = Daru::View::Plot.new(df, opts, chart_class: 'map')
map.show_in_iruby
Out[8]:
In [9]:
opts = {
      chart_class: 'map',
      chart: {
          map: 'countries/be/be-all'
      },

      title: {
          text: 'Highmaps basic demo'
      },

      subtitle: {
          text: 'Source map: <a href="http://code.highcharts.com/mapdata/countries/be/be-all.js">Belgium</a>'
      },

      mapNavigation: {
          enabled: true,
          buttonOptions: {
              verticalAlign: 'bottom'
          }
      },

      colorAxis: {
          min: 0
      }
    }

data = [
    ['be-3530', 0],
    ['be-3527', 1],
    ['be-3532', 2],
    ['be-3533', 3],
    ['be-3534', 4],
    ['be-3535', 5],
    ['be-3528', 6],
    ['be-3529', 7],
    ['be-489', 8],
    ['be-490', 9],
    ['be-3526', 10]
]

df = Daru::DataFrame.new(
  {
    countries: data.map {|row| row[0]},
    data: data.map {|row| row[1]}
  }
)
map = Daru::View::Plot.new(df, opts, chart_class: 'map')
map.show_in_iruby
Out[9]:
In [10]:
opts = {
      chart_class: 'map',
      chart: {
          map: 'countries/ca/ca-all'
      },

      title: {
          text: 'Highmaps basic demo'
      },

      subtitle: {
          text: 'Source map: <a href="http://code.highcharts.com/mapdata/countries/ca/ca-all.js">Canada</a>'
      },

      mapNavigation: {
          enabled: true,
          buttonOptions: {
              verticalAlign: 'bottom'
          }
      },

      colorAxis: {
          min: 0
      }
    }

data = [
    ['ca-5682', 0],
    ['ca-bc', 1],
    ['ca-nu', 2],
    ['ca-nt', 3],
    ['ca-ab', 4],
    ['ca-nl', 5],
    ['ca-sk', 6],
    ['ca-mb', 7],
    ['ca-qc', 8],
    ['ca-on', 9],
    ['ca-nb', 10],
    ['ca-ns', 11],
    ['ca-pe', 12],
    ['ca-yt', 13]
]

df = Daru::DataFrame.new(
  {
    countries: data.map {|row| row[0]},
    data: data.map {|row| row[1]}
  }
)
map = Daru::View::Plot.new(df, opts, chart_class: 'map')
map.show_in_iruby
Out[10]:
In [11]:
opts = {
      chart_class: 'map',
      chart: {
          map: 'countries/cn/cn-all'
      },

      title: {
          text: 'Highmaps basic demo'
      },

      subtitle: {
          text: 'Source map: <a href="http://code.highcharts.com/mapdata/countries/cn/cn-all.js">China</a>'
      },

      mapNavigation: {
          enabled: true,
          buttonOptions: {
              verticalAlign: 'bottom'
          }
      },

      colorAxis: {
          min: 0
      }
    }

data = [
    ['cn-3664', 0],
    ['cn-gd', 1],
    ['cn-sh', 2],
    ['cn-zj', 3],
    ['cn-ha', 4],
    ['cn-xz', 5],
    ['cn-yn', 6],
    ['cn-ah', 7],
    ['cn-hu', 8],
    ['cn-sa', 9],
    ['cn-cq', 10],
    ['cn-gz', 11],
    ['cn-hn', 12],
    ['cn-sc', 13],
    ['cn-sx', 14],
    ['cn-he', 15],
    ['cn-jx', 16],
    ['cn-nm', 17],
    ['cn-gx', 18],
    ['cn-hl', 19],
    ['cn-fj', 20],
    ['cn-bj', 21],
    ['cn-hb', 22],
    ['cn-ln', 23],
    ['cn-sd', 24],
    ['cn-tj', 25],
    ['cn-js', 26],
    ['cn-qh', 27],
    ['cn-gs', 28],
    ['cn-xj', 29],
    ['cn-jl', 30],
    ['cn-nx', 31]
]

df = Daru::DataFrame.new(
  {
    countries: data.map {|row| row[0]},
    data: data.map {|row| row[1]}
  }
)
map = Daru::View::Plot.new(df, opts, chart_class: 'map')
map.show_in_iruby
Out[11]:
In [12]:
opts = {
      chart_class: 'map',
      chart: {
          map: 'countries/fr/fr-all'
      },

      title: {
          text: 'Highmaps basic demo'
      },

      subtitle: {
          text: 'Source map: <a href="http://code.highcharts.com/mapdata/countries/fr/fr-all.js">France</a>'
      },

      mapNavigation: {
          enabled: true,
          buttonOptions: {
              verticalAlign: 'bottom'
          }
      },

      colorAxis: {
          min: 0
      }
    }

data = [
    ['fr-t', 0],
    ['fr-h', 1],
    ['fr-e', 2],
    ['fr-r', 3],
    ['fr-u', 4],
    ['fr-n', 5],
    ['fr-p', 6],
    ['fr-o', 7],
    ['fr-v', 8],
    ['fr-s', 9],
    ['fr-g', 10],
    ['fr-k', 11],
    ['fr-a', 12],
    ['fr-c', 13],
    ['fr-f', 14],
    ['fr-l', 15],
    ['fr-d', 16],
    ['fr-b', 17],
    ['fr-i', 18],
    ['fr-q', 19],
    ['fr-j', 20],
    ['fr-m', 21],
    ['fr-re', 22],
    ['fr-yt', 23],
    ['fr-gf', 24],
    ['fr-mq', 25],
    ['fr-gp', 26],
    ['undefined', 27]
]

df = Daru::DataFrame.new(
  {
    countries: data.map {|row| row[0]},
    data: data.map {|row| row[1]}
  }
)
map = Daru::View::Plot.new(df, opts, chart_class: 'map')
map.show_in_iruby
Out[12]:
In [ ]: