New "Places Color" tab in Family line graph

Hi All,

I like very much Family Line Graph and also like colorizing by family name (Family Colors tab). I would like add similar tab for colorizing by birth places because it will be very informative on chart. I have started rewrite code of this graph and I’m here now (tab have created):

.
I’m not too familliary in py so I’d like ask support from you:
This code collect all surnames on surname tab. Could you advice how can I change this to collect birth places instead ot surnames?

progress = ProgressMeter(
            _('Finding Surnames'), parent=uistate.window)
        progress.set_pass(_('Finding surnames'),
                          database.get_number_of_people())
        for person in database.iter_people():
            progress.step()
            key = person.get_primary_name().get_surname()
            count = 0
            if key in surnames:
                count = surnames[key]
            surnames[key] = count + 1
        progress.close()

Thx in advance.
Attila

1 Like

Places are related to events, So for each people, you need to collect all events.
If you need to do this only for birth event, you can use the function:

from gramps.gen.utils.db import get_birth_or_fallback

get_birth_or_fallback(self.r_db, person)

When you have the event:

event.get_place_handle()

Thx, it’s working:

Could you help me how can I get name of place instead ot place ID (see on pic)?

thx in advance.
Attila

This is not the place ID but the place handle.
To get the real place, you need to do:

from gramps.gen.display.place import displayer as _pd

place = dbstate.db.get_place_from_handle(handle)
place_name = _pd.display(dbstate.db, place)

The place name will use the place format you choose in the display preference tab.

2 Likes

Thx your help, it’s working perfectly: image

2 Likes

Output (colorizing by bithplace) is like this:

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.