localgovdrupal / localgov_elections

This module provides submodules, content types, views and configuration that allow the reporting of election results for the LocalGov Drupal distribution.
GNU General Public License v2.0
1 stars 1 forks source link

Chart breaks if candidates have no surname #92

Closed finnlewis closed 4 months ago

finnlewis commented 4 months ago

Creating an election with real data, from 2019:

image

However, I don't have the candidate names, so try removing the surname from all candidates:

image

Add surnames for labour and conservative:

image

I guess we need to make the chart rendering robust enough to no require a surname.

finnlewis commented 4 months ago

On this one, it's the views chart label is set to 'surname' .Changing this to 'party' fixes it. I guess the chart can't deal with an empty label (surname) field.

https://localgov.ddev.site/admin/structure/views/view/localgov_election_area_results/edit/block_1

image

gives:

image

finnlewis commented 4 months ago

The party field is the only field that is required on the candidate.

When we pass the chart an empty field for a label, the render breaks, so we need to be sure the label is present.

So it makes sense to use the party field.

I've updated that view to add another party field, rewriting it to include the candidate name if present.

How does this look?

image

finnlewis commented 4 months ago

Fixed, thanks @chriswales95