My problem here is that I want to display a little bit of text when you click on each country, such as the Capital City of each one. For now, I have just included placeholder numbers. I tried using the str("x") command, but no success was found. What do I do here?
Here is a screenshot of what I currently have, and in the solution I want, I want "Washington DC" to be displayed in place of 66. Here is the image result I am getting
# import pygal library
import pygal
mm = pygal.maps.world.World()
# create a world map
worldmap = pygal.maps.world.World()
# set the title of the map
worldmap.title = 'Countries'
# adding the countries
worldmap.add('Random Data', {
'aq' : 69,
'cd' : 30,
'de' : 40,
'eg' : 50,
'ga' : 45,
'hk' : 23,
'in' : 0,
'jp' : 65,
'nz' : 41,
'kz' : 32,
'us' : 66
})
# save into the file
worldmap.render_to_file('worldmapresult.svg')
open('worldmapresult.svg')
print("Success")
You can use
tooltip_...from pygal! Here are the documentations for everything tooltip-related.Add a font size and border radius for the tooltips:
Now add the appropriate labels:
Here is the full code: