"code": "DE.BW",
        "value": 157
    },
    {
        "code": "DE.HE",
        "value": 134
    },
    {
        "code": "DE.NI",
        "value": 136
    },
    {
        "code": "DE.TH",
        "value": 704
    }
]
H.set_dict_options(options) # set options
H.add_data_set(data, 'map', 'Random data', joinBy=['code_hasc', 'code'], # set dataset
                states={
                    'hover': {
                        'color': '#BADA55'
                    }
                },
                dataLabels={
                    'enabled': True,
                    'format': '{point.properties.postal}'
                })

H.set_map_source('http://www.highcharts.com/samples/data/jsonp.php?filename=germany.geo.json&callback=?', True) # set map data from the src (jsonp)

H.htmlcontent
Example #2
0
H.set_dict_options(options)
data_url = 'http://www.highcharts.com/samples/data/jsonp.php?filename=us-population-density.json&callback=?'  # set data_src
H.add_data_from_jsonp(
    data_url,
    'json_data',
    'map',
    'Population density',
    joinBy=['postal-code', 'code'],  # add dataset from data_src using jsonp
    dataLabels={
        'enabled': True,
        'color': 'white',
        'format': '{point.code}'
    },
    tooltip={'pointFormat': '{point.code}: {point.value}/kmĀ²'})

H.set_map_source('http://code.highcharts.com/mapdata/countries/us/us-all.js',
                 jsonp_map=False)
"""
python-highcharts provides add_JSscript method:
add_JSscript(js_script, js_loc):
js_script is the javascript string 
js_loc is location of this javascript string, can be either head (at beginning of the script) or
end (in the end of the script)

The JS string here is a function to convert (state) codes in dateset to Upper case (from lower)
However, it is not recommended to do it this way. 
The better practice is to load data into python environment and handle in python. 
It can be done by writting a python script or using the functions in highmap_helper module
"""
H.add_JSscript(
    "$.each(json_data, function () {\
            this.code = this.code.toUpperCase();\
            'mapline': {
                'showInLegend': False,
                'enableMouseTracking': False
            }
        },
    } 

H.set_dict_options(options)
data_url = 'http://www.highcharts.com/samples/data/jsonp.php?filename=us-counties-unemployment.json&callback=?'
H.add_data_from_jsonp(data_url, 'json_data', 'map', 'Unemployment rate', joinBy = ['hc-key', 'code'], 
     tooltip = {
                    'valueSuffix': '%'
                },
                borderWidth = 0.5,
                states = {
                    'hover': {
                        'color': '#bada55'
                    }
                }
                )
H.add_data_set(RawJavaScriptText('[lines[0]]'), 'mapline', 'State borders', color = 'white')
H.add_data_set(RawJavaScriptText('[lines[1]]'), 'mapline', 'Separator', color = 'gray')
H.set_map_source('http://code.highcharts.com/mapdata/countries/us/us-all-all.js', jsonp_map = False)
H.add_JSscript("var lines = Highcharts.geojson(Highcharts.maps['countries/us/us-all-all'], 'mapline');", 'head')
H.add_JSscript("Highcharts.each(geojson, function (mapPoint) {\
            mapPoint.name = mapPoint.name + ', ' + mapPoint.properties['hc-key'].substr(3, 2);\
        });", 'head')

H.htmlcontent

Example #4
0
            'mapData': "Highcharts.maps['custom/europe']",
            'tooltip': {
                'headerFormat': '',
                'pointFormat': '{point.name}: <b>{series.name}</b>'
            }
        }
    }
}

data1 = [{'code': x} for x in ['IE', 'IS', 'GB', 'PT']]
data2 = [{'code': x} for x in ['NO', 'SE', 'DK', 'DE', 'NL', 'BE', 'LU', 'ES', 'FR', 'PL', 'CZ', 'AT', 'CH', 'LI', 'SK', 'HU',\
                    'SI', 'IT', 'SM', 'HR', 'BA', 'YF', 'ME', 'AL', 'MK']]
data3 = [
    {
        'code': x
    } for x in
    ['FI', 'EE', 'LV', 'LT', 'BY', 'UA', 'MD', 'RO', 'BG', 'GR', 'TR', 'CY']
]
data4 = [{'code': x} for x in ['RU']]

H.set_dict_options(options)
H.add_data_set(data1, 'map', 'UTC')
H.add_data_set(data2, 'map', 'UTC + 1')
H.add_data_set(data3, 'map', 'UTC + 2')
H.add_data_set(data4, 'map', 'UTC + 3')

H.set_map_source(
    'http://code.highcharts.com/mapdata/custom/europe.js',
    jsonp_map=False)  # set map data from src. data is in .js format

H.htmlcontent
        "value": 157
    }, {
        "code": "DE.HE",
        "value": 134
    }, {
        "code": "DE.NI",
        "value": 136
    }, {
        "code": "DE.TH",
        "value": 704
    }
]
H.set_dict_options(options)  # set options
H.add_data_set(
    data,
    'map',
    'Random data',
    joinBy=['code_hasc', 'code'],  # set dataset
    states={'hover': {
        'color': '#BADA55'
    }},
    dataLabels={
        'enabled': True,
        'format': '{point.properties.postal}'
    })

H.set_map_source(
    'http://www.highcharts.com/samples/data/jsonp.php?filename=germany.geo.json&callback=?',
    True)  # set map data from the src (jsonp)

H.htmlcontent
Example #6
0
        "value": 728
    },
    {
        "code": "CL.AN",
        "value": 200
    },
]
H.set_dict_options(options)  # set options
H.add_data_set(
    data,
    'map',
    'Random data',
    joinBy=['code_hasc', 'code'],  # set dataset
    states={'hover': {
        'color': '#BADA55'
    }},
    dataLabels={
        'enabled': True,
        'format': '{point.properties.postal}'
    })

H.set_map_source('http://code.highcharts.com/mapdata/countries/cl/cl-all.js',
                 False)  # set map data from the src (jsonp)

fobj = open(
    '/home/jmmauricio/Documents/public/workspace/pypstools/dev/high/map.html',
    'w')
fobj.write(H.htmlcontent)

fobj.close()
                'style': {
                    'fontWeight': 'bold'
                }
            },
            'mapData': "Highcharts.maps['custom/europe']",
            'tooltip': {
                'headerFormat': '',
                'pointFormat': '{point.name}: <b>{series.name}</b>'
            }

        }
    }
} 



data1 = [{'code': x} for x in ['IE','IS', 'GB', 'PT']]
data2 = [{'code': x} for x in ['NO', 'SE', 'DK', 'DE', 'NL', 'BE', 'LU', 'ES', 'FR', 'PL', 'CZ', 'AT', 'CH', 'LI', 'SK', 'HU',\
                    'SI', 'IT', 'SM', 'HR', 'BA', 'YF', 'ME', 'AL', 'MK']]
data3 = [{'code': x} for x in ['FI', 'EE', 'LV', 'LT', 'BY', 'UA', 'MD', 'RO', 'BG', 'GR', 'TR', 'CY']]
data4 = [{'code': x} for x in ['RU']]

H.set_dict_options(options)
H.add_data_set(data1, 'map', 'UTC')
H.add_data_set(data2, 'map', 'UTC + 1')
H.add_data_set(data3, 'map', 'UTC + 2')
H.add_data_set(data4, 'map', 'UTC + 3')

H.set_map_source('http://code.highcharts.com/mapdata/custom/europe.js', jsonp_map=False) # set map data from src. data is in .js format

H.htmlcontent