123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <!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">
- ${demo.css}
- </style>
- <script type="text/javascript">
- $(function () {
- /*
- TODO:
- - Check data labels after drilling. Label rank? New positions?
- - Not US Mainland text
- - Separators
- */
- var data = Highcharts.geojson(Highcharts.maps['countries/us/us-all']),
- // Some responsiveness
- small = $('#container').width() < 400;
- // Set drilldown pointers
- $.each(data, function (i) {
- this.drilldown = this.properties['hc-key'];
- this.value = i; // Non-random bogus data
- });
- // Instanciate the map
- $('#container').highcharts('Map', {
- chart : {
- events: {
- drilldown: function (e) {
- if (!e.seriesOptions) {
- var chart = this,
- mapKey = 'countries/us/' + e.point.drilldown + '-all',
- // Handle error, the timeout is cleared on success
- fail = setTimeout(function () {
- if (!Highcharts.maps[mapKey]) {
- chart.showLoading('<i class="icon-frown"></i> Failed loading ' + e.point.name);
- fail = setTimeout(function () {
- chart.hideLoading();
- }, 1000);
- }
- }, 3000);
- // Show the spinner
- chart.showLoading('<i class="icon-spinner icon-spin icon-3x"></i>'); // Font Awesome spinner
- // Load the drilldown map
- $.getScript('http://code.highcharts.com/mapdata/' + mapKey + '.js', function () {
- data = Highcharts.geojson(Highcharts.maps[mapKey]);
- // Set a non-random bogus value
- $.each(data, function (i) {
- this.value = i;
- });
- // Hide loading and add series
- chart.hideLoading();
- clearTimeout(fail);
- chart.addSeriesAsDrilldown(e.point, {
- name: e.point.name,
- data: data,
- dataLabels: {
- enabled: true,
- format: '{point.name}'
- }
- });
- });
- }
- this.setTitle(null, { text: e.point.name });
- },
- drillup: function () {
- this.setTitle(null, { text: 'USA' });
- }
- }
- },
- title : {
- text : 'Highcharts Map Drilldown'
- },
- subtitle: {
- text: 'USA',
- floating: true,
- align: 'right',
- y: 50,
- style: {
- fontSize: '16px'
- }
- },
- legend: small ? {} : {
- layout: 'vertical',
- align: 'right',
- verticalAlign: 'middle'
- },
- colorAxis: {
- min: 0,
- minColor: '#E6E7E8',
- maxColor: '#005645'
- },
- mapNavigation: {
- enabled: true,
- buttonOptions: {
- verticalAlign: 'bottom'
- }
- },
- plotOptions: {
- map: {
- states: {
- hover: {
- color: '#EEDD66'
- }
- }
- }
- },
- series : [{
- data : data,
- name: 'USA',
- dataLabels: {
- enabled: true,
- format: '{point.properties.postal-code}'
- }
- }],
- drilldown: {
- //series: drilldownSeries,
- activeDataLabelStyle: {
- color: '#FFFFFF',
- textDecoration: 'none',
- textShadow: '0 0 3px #000000'
- },
- drillUpButton: {
- relativeTo: 'spacingBox',
- position: {
- x: 0,
- y: 60
- }
- }
- }
- });
- });
- </script>
- </head>
- <body>
- <script src="../../js/highmaps.js"></script>
- <script src="../../js/modules/data.js"></script>
- <script src="../../js/modules/drilldown.js"></script>
- <script src="http://code.highcharts.com/mapdata/countries/us/us-all.js"></script>
- <link href="http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
- <div id="container" style="height: 500px; min-width: 310px; max-width: 800px; margin: 0 auto"></div>
- </body>
- </html>
|