Skip to content

Improve group focus indicator #84

Open
@frankelavsky

Description

@frankelavsky

Hi!

The group focus indicator isn't great (especially for scatter, line, and clustered bars).

I'm talking about this:
Screenshot 2023-08-30 at 7 26 52 PM

I've got a suggested solution: filters. You're already using them for text and geometries - it's the dual-outline strategy (and white outline on text). We can use that same strategy to create some great looking group focus indicators. On focus, you'd apply the filter to a special group appended at the end of the chart (the group doesn't need to be appended on focus, just change the href values).

This "top" group contains <use> elements, which simply reference the group or element you want to duplicate:
Screenshot 2023-08-30 at 7 02 51 PM

Like this:

<g filter="url(#VCL-t-s-f-COOL-NEW-FILTER-scatter-plot-LabelCollision)">
    <use href=""></use>
    <use href=""></use>
</g>

Here's what it would look like if you group stuff up like this and apply a filter to the group:
Screenshot 2023-08-30 at 7 13 03 PM

The code for the filter looks like this:

<filter id="VCL-t-s-f-COOL-NEW-FILTER-scatter-plot-LabelCollision" class="VCL-t-s-f-COOL-NEW-FILTER-scatter-plot-LabelCollision">
    <feMorphology in="SourceAlpha" result="dilatedText" operator="dilate" radius="10"></feMorphology>
    <feFlood flood-color="#ffffff" flood-opacity="1" result="whiteTextFlood"></feFlood>
    <feComposite in="whiteTextFlood" in2="dilatedText" operator="in" result="textOutline"></feComposite>

    <feMorphology in="SourceAlpha" result="dilatedBlack" operator="dilate" radius="11.5"></feMorphology>
    <feFlood flood-color="#000" flood-opacity="1" result="blackFlood"></feFlood>
    <feComposite in="blackFlood" in2="dilatedBlack" operator="in" result="blackOutline"></feComposite>

    <feMerge>
        <feMergeNode in="blackOutline"></feMergeNode>
        <feMergeNode in="textOutline"></feMergeNode>
        <feMergeNode in="SourceGraphic"></feMergeNode>
    </feMerge>
</filter>

You can obviously change the radius values to whatever:
Screenshot 2023-08-30 at 7 16 11 PM

Here are some examples:
Screenshot 2023-08-30 at 7 08 01 PM
Screenshot 2023-08-30 at 7 11 45 PM
Screenshot 2023-08-30 at 7 14 18 PM

Of course, you can just show the filter effect on only the geometry group if you want, just don't add a <use> element for the text:
Screenshot 2023-08-30 at 7 15 02 PM

And for line, you have 3 elements (line, dot group, text):
Screenshot 2023-08-30 at 7 23 27 PM

I think this is quite an aesthetic improvement and also improves accessibility. The bounding-box style focus indicator just isn't great (I wonder who designed that...).

(Oh, and as a note: when we hover and get that dotted line effect? The components are currently accomplishing this with filters and fill effects on a duplicated element. It would actually be an improvement to copy my above solution and have a <g> element that contains <use> elements here too, and you just have to update the reference id (and add the fancy fill/filter effects to the <use> element). It's not a big deal, since the current system works. But this reduces render/draw time and only requires a paint update instead.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededneeds investigationThis item needs to be looked into, additional content from issue submitter would help as well.questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions