123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Highmaps Example</title>
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
- <style type="text/css">
- #container {
- height: 500px;
- min-width: 310px;
- max-width: 800px;
- margin: 0 auto;
- }
- .loading {
- margin-top: 10em;
- text-align: center;
- color: gray;
- }
- </style>
- <script type="text/javascript">
- $(function () {
- // Load the data from a Google Spreadsheet
- // https://docs.google.com/a/highsoft.com/spreadsheet/pub?hl=en_GB&hl=en_GB&key=0AoIaUO7wH1HwdFJHaFI4eUJDYlVna3k5TlpuXzZubHc&output=html
- Highcharts.data({
- googleSpreadsheetKey: '0AoIaUO7wH1HwdFJHaFI4eUJDYlVna3k5TlpuXzZubHc',
- // custom handler when the spreadsheet is parsed
- parsed: function (columns) {
- // Read the columns into the data array
- var data = [];
- $.each(columns[0], function (i, code) {
- data.push({
- code: code.toUpperCase(),
- value: parseFloat(columns[2][i]),
- name: columns[1][i]
- });
- });
- // Initiate the chart
- $('#container').highcharts('Map', {
- chart : {
- borderWidth : 1
- },
- colors: ['rgba(19,64,117,0.05)', 'rgba(19,64,117,0.2)', 'rgba(19,64,117,0.4)',
- 'rgba(19,64,117,0.5)', 'rgba(19,64,117,0.6)', 'rgba(19,64,117,0.8)', 'rgba(19,64,117,1)'],
- title : {
- text : 'Population density by country (/km²)'
- },
- mapNavigation: {
- enabled: true
- },
- legend: {
- title: {
- text: 'Individuals per km²',
- style: {
- color: (Highcharts.theme && Highcharts.theme.textColor) || 'black'
- }
- },
- align: 'left',
- verticalAlign: 'bottom',
- floating: true,
- layout: 'vertical',
- valueDecimals: 0,
- backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || 'rgba(255, 255, 255, 0.85)',
- symbolRadius: 0,
- symbolHeight: 14
- },
- colorAxis: {
- dataClasses: [{
- to: 3
- }, {
- from: 3,
- to: 10
- }, {
- from: 10,
- to: 30
- }, {
- from: 30,
- to: 100
- }, {
- from: 100,
- to: 300
- }, {
- from: 300,
- to: 1000
- }, {
- from: 1000
- }]
- },
- series : [{
- data : data,
- mapData: Highcharts.maps['custom/world'],
- joinBy: ['iso-a2', 'code'],
- animation: true,
- name: 'Population density',
- states: {
- hover: {
- color: '#BADA55'
- }
- },
- tooltip: {
- valueSuffix: '/km²'
- }
- }]
- });
- },
- error: function () {
- $('#container').html('<div class="loading">' +
- '<i class="icon-frown icon-large"></i> ' +
- 'Error loading data from Google Spreadsheets' +
- '</div>');
- }
- });
- });
- </script>
- </head>
- <body>
- <script src="../../js/highmaps.js"></script>
- <script src="../../js/modules/data.js"></script>
- <script src="http://code.highcharts.com/mapdata/custom/world.js"></script>
- <div id="container">
- <div class="loading">
- <i class="icon-spinner icon-spin icon-large"></i>
- Loading data from Google Spreadsheets...
- </div>
- </div>
- </body>
- </html>
|