Exemple #1
0
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')
Exemple #2
0
            return -1
        else:
            try:
                I = self.mod.get_current()
            except:
                I = -1
            return I


if __name__ == '__main__':
    acc = [Accelerator(mod=asp), Accelerator(mod=sls), Accelerator(mod=diamond), Accelerator(mod=nsls), \
     Accelerator(mod=esrf), Accelerator(mod=ssrl), Accelerator(mod=spring8), Accelerator(mod=als), \
     Accelerator(mod=elettra), Accelerator(mod=anka), Accelerator(mod=astrid), Accelerator(mod=pohang), \
     Accelerator(mod=pf)]

    chart = MapChart(600, 350)

    data_dict = {}
    counter = 0
    for a in acc:
        #I = 100 + counter;
        #counter += 1
        I = a.get_current()
        a.I = I
        data_dict[a.isocode] = I

        print a.acronym, I, type(I)

    #url = http://chart.apis.google.com/chart?cht=map&cht=map:fixed=-60,-20,80,-35&chs=600x350&chd=s:9PfAu&chld=US-NY|CH|US-CA|AU-VIC|GB
    #chart.add_data_dict(data_dict)