Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Commit

Permalink
Added mapchart example
Browse files Browse the repository at this point in the history
  • Loading branch information
gak committed Mar 15, 2009
1 parent 76610bd commit af07747
Show file tree
Hide file tree
Showing 2 changed files with 256 additions and 0 deletions.
195 changes: 195 additions & 0 deletions examples/mapchart-birth-rate.txt
@@ -0,0 +1,195 @@
CD 49.6
GW 49.6
LR 49.6
NE 49.0
AF 48.2
ML 48.1
AO 47.3
BI 47.1
UG 46.6
SL 46.2
TD 45.5
RW 44.5
BF 44.0
SO 42.9
TL 42.1
MW 40.7
BJ 40.2
NG 39.9
GN 39.8
MZ 39.5
ER 39.3
ZM 39.3
KE 39.2
RO 39.0
GQ 38.5
YE 38.3
ET 38.2
TG 36.8
MG 36.4
CF 36.1
PS 35.9
CI 35.3
SN 35.2
IM 35.1
GM 34.9
CM 34.5
KM 33.4
GT 33.2
MR 32.5
ST 32.4
IQ 31.7
SD 31.5
SB 30.5
GH 29.6
PG 29.6
LS 29.0
CV 28.9
VU 28.8
DJ 28.7
SZ 28.5
NP 28.1
HT 27.9
HN 27.9
ZW 27.9
BO 27.3
TJ 27.3
PK 27.2
WS 26.8
RS 26.7
KH 26.4
JO 25.9
US 25.9
PH 25.8
GA 25.7
NA 25.7
TO 25.6
BZ 25.2
BW 24.9
NI 24.9
SA 24.9
BD 24.8
PY 24.8
WS 24.7
EG 24.2
GF 23.9
DO 23.5
CU 23.4
MV 23.4
EH 23.3
IN 23.0
SV 22.8
UZ 22.6
ZA 22.3
OM 22.1
KG 21.8
TM 21.8
BI 21.5
VE 21.4
FJ 21.1
EC 21.0
PE 20.9
DZ 20.8
PA 20.8
MY 20.6
MA 20.5
IQ 20.3
VC 20.1
JM 19.9
IL 19.7
KZ 19.7
SR 19.5
MX 19.3
BR 19.2
LC 19.1
VN 18.8
CO 18.7
ID 18.7
BT 18.5
US 18.5
MN 18.4
TR 18.4
PF 18.3
LB 18.2
MM 18.2
GD 18.0
RE 18.0
KW 17.9
CR 17.8
AR 17.5
BH 17.1
GY 17.1
BS 16.9
TN 16.7
NC 16.4
AL 16.3
AZ 16.2
QA 16.2
AE 16.2
IE 15.5
UY 15.1
CL 15.0
LK 15.0
MU 14.8
GP 14.8
TT 14.8
TH 14.6
IS 14.3
NL 14.1
US 14.0
NZ 13.7
ME 13.6
VG 13.4
US 13.3
ZA 13.2
KR 13.1
RS 12.8
AM 12.5
AN 12.5
AU 12.4
MQ 12.4
CY 12.2
GF 12.2
GB 12.0
NO 12.0
LU 11.5
BO 11.4
SE 11.3
DK 11.2
FI 11.2
NL 11.1
BB 11.0
NC 10.9
EE 10.8
GE 10.8
ES 10.8
TN 10.7
PT 10.5
BE 10.4
CA 10.3
CU 10.3
SK 10.0
MT 9.8
RO 9.8
PL 9.5
GB 9.4
BY 9.4
GR 9.3
HU 9.3
ZA 9.3
LV 9.3
AT 9.2
CZ 9.2
IT 9.2
CH 9.2
UA 9.2
LT 9.1
HR 9.0
SI 9.0
BG 8.9
BA 8.8
JP 8.3
DE 8.2
SG 8.2
CD 7.6
MD 7.6
61 changes: 61 additions & 0 deletions examples/mapchart.py
@@ -0,0 +1,61 @@
#!/usr/bin/env python
"""
Copyright Gerald Kaszuba 2008
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

import os
import sys

ROOT = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(ROOT, '..'))

from pygooglechart import MapChart

import settings
import helper

def birth_rate():

# Create a chart object of 200x100 pixels
chart = MapChart(440, 220)

# Load the data from a file, create a dict that looks like:
# {'AU': 5, 'YE': 10}
data = {}
countries = open('mapchart-birth-rate.txt', 'rb').read().split('\n')
for line in countries[:-1]:
code, score = line.split(' ', 1)
data[code] = float(score)

# Set the data dictionary for country codes to value mapping
chart.add_data_dict(data)

# Download the chart
chart.download('mapchart-birth-rate.png')

# Now do it in africa ...
chart.set_geo_area('africa')

# ... with white as the default colour and gradient from green to red
chart.set_colours(('EEEEEE', '10A010', 'D03000'))

chart.download('mapchart-birth-rate-africa.png')

def main():
birth_rate()

if __name__ == '__main__':
main()

0 comments on commit af07747

Please sign in to comment.