Add toggleable provinces legend#1471
Conversation
Add a new Provinces Legend toggle: insert a button (#provincesLegend) in the provinces toolbar and wire it to a new toggleProvincesLegend handler.
The handler clears the legend if present or builds it from pack.provinces (only entries with p.i and not removed), applies the current state filter (provincesFilterState), maps provinces to [id, color, name], and calls drawLegend("Provinces", data) to render it.
✅ Deploy Preview for afmg ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
If I have all provinces displayed (states: all), then the legend doesn't fit the screen. We would need it to have a logic to change number of columns based on elements number and not go off screen. |
|
|
We can allow it, but maybe rescale (change sizes inside). Or test how many still look good and restrict it to take x first max. |
|
I had the idea of adding a filter, "Provinces displayed on screen" [in the viewport], to filter the number of provinces instead of modifying the number of legend items that can be displayed simultaneously. I think that setting an arbitrary limit based on the number of legend items that fit on the screen could cause different effects simply by changing the screen ratio and resolution. And I don't know what to do with that information. Another filter we can add to the Provinces Editor is "Dropdown -> culture" and filter by cultures. This is similar to how it already works in the Burgs editor. I think that even so, none of this completely solves the legend issue, and arbitrary adjustments will have to be made. These adjustments should be at the discretion of the repository owner. |
This PR adds a new Provinces Legend toggle. A new button (#provincesLegend) in the provinces toolbar between [chart] and [provincelabels]. This button calls function toggleProvincesLegend handler.
This function has some things set up.