Skip to content

Labeling algorithms (e.g., occlusion)? #27

Open
@mbostock

Description

@mbostock
Member

In some line plots, if the cardinality of z is relatively low, it would be nice to label the lines say at the start or end. Similarly for dot plots, it would be lovely to have an automatic labeling strategy. Related vega-label.

Activity

changed the title [-]Automatic labeling?[/-] [+]Labeling algorithms (e.g., occlusion)?[/+] on Feb 24, 2021
mbostock

mbostock commented on Feb 24, 2021

@mbostock
MemberAuthor

Related #139 for a transform that is useful for labeling lines.

Fil

Fil commented on Mar 5, 2021

@Fil
Contributor

we have a nice solution for stacked series and bars thanks to stackXMid

mbostock

mbostock commented on Mar 18, 2021

@mbostock
MemberAuthor

I really want an automatic algorithm for labeling scatterplots. And possibly stacked areas and other things. Something that considers only occlusion, like @fil/occlusion, would be a great place to start.

Fil

Fil commented on Sep 27, 2021

@Fil
Contributor

I also like the "halo" (white stroke clone) strategy from https://observablehq.com/@mbostock/inequality-in-american-cities and think it should be available from Plot.text (and maybe occlusion as well!).

Other refs:

Fil

Fil commented on Mar 29, 2022

@Fil
Contributor

Here's a prototype for a labelling strategy based on @fil/occlusion
https://observablehq.com/@observablehq/plot-occlusion-27

On this scatterplot, the occludeText function is able to avoid putting text on top of symbols. It's still not capable of finding a correct position to put the texts. It also needs to wait for the chart to be appended to the DOM before it can kick in, as it needs to measure the actual bounding boxes.

mbostock

mbostock commented on Mar 29, 2022

@mbostock
MemberAuthor

Can we avoid getBoundingClientRect by using the same metrics approach that Plot.text uses?

Fil

Fil commented on Mar 29, 2022

@Fil
Contributor

Yes it's one of the todos. Some challenges (probably not too hard):

  • we'll have to compute intersections not only for text but for symbols, rects, lines, paths… (this might also be useful for interactions);
  • this is yet another case where it will be useful to know in which facet we are, because the same position in two facets is not creating an occlusion.
Fil

Fil commented on Dec 8, 2022

@Fil
Contributor
Fil

Fil commented on Mar 23, 2023

@Fil
Contributor

A typical request is to limit occlusion of end-of-line labels, like in https://observablehq.com/@d3/cancer-survival-rates (unfinished Plot version: https://observablehq.com/@observablehq/plot-cancer-survival-rates). The dodgeY transform doesn't address this concern since by construction it disregards an initial y channel.

I wonder if it would be fair for the dodgeY transform to switch to a different algorithm if y is already there?

Fil

Fil commented on Apr 4, 2023

@Fil
Contributor

See also mapbox’s text-variable-anchor property
https://docs.mapbox.com/mapbox-gl-js/example/variable-label-placement/

4 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Fil@mbostock@huw

        Issue actions

          Labeling algorithms (e.g., occlusion)? · Issue #27 · observablehq/plot