New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display ordinal dimensions with a single value domain/range #88

Closed
shodanjr opened this Issue Feb 2, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@shodanjr
Contributor

shodanjr commented Feb 2, 2015

I came across the following issue with a PC chart which is embedded into a larger application with data filtering functionality. Specifically, my data would contain an ordinal dimension which, depending on the active filter, would contain only a single value across the entire domain. When that happened, the axis associated with that particular dimension ended up getting removed completely from the chart.

I traced this down to pc.autoscale and specifically the following bit:

pc.dimensions(pc.dimensions().filter(function(p,i) {
    var uniques = yscale[p].domain().length;
    if (__.types[p] == "string" && (uniques > 60 || uniques < 2)) {
      return false;
    }
    return true;
  }));

The uniques < 2 option will throw away any ordinal dimension that only contains one unique value. I can see situations where this is desirable but I can also see several use cases where this might not be appropriate behavior (for example, in an interactive chart with filtering, this would constantly change the visual appearance and have the axes shift around).

To me it would make sense for this kind of behavior to be determined by a flag. For my use-case, simply changing the line to read uniques < 1 works.

I'd rather have some discussion on expected behaviors before contributing a fix :).

@syntagmatic

This comment has been minimized.

Show comment
Hide comment
@syntagmatic

syntagmatic Feb 2, 2015

Owner

For a single unique value, adjusting the behavior of #79 would be desirable.

uniques > 60 is also a hack, to prevent labels from crowding each other. But if some ordinal labels were skipped so that only ~20-30 labels showed up, there would be no problem with including a scale with many values in the domain.

Two flags for the min/max number of uniques sounds find to me. I've left this hack in there for a long time so that the chart would render decently in common cases, but I sometimes trip over edge cases as well and edit the line manually. It needs to go.

Owner

syntagmatic commented Feb 2, 2015

For a single unique value, adjusting the behavior of #79 would be desirable.

uniques > 60 is also a hack, to prevent labels from crowding each other. But if some ordinal labels were skipped so that only ~20-30 labels showed up, there would be no problem with including a scale with many values in the domain.

Two flags for the min/max number of uniques sounds find to me. I've left this hack in there for a long time so that the chart would render decently in common cases, but I sometimes trip over edge cases as well and edit the line manually. It needs to go.

@shodanjr

This comment has been minimized.

Show comment
Hide comment
@shodanjr

shodanjr Feb 2, 2015

Contributor

If I skip the check, then i actually get the optimal behavior that you describe in #79 (label in the middle of the axis range, poly line crossing through it). I don't like the idea of skipping labels in an ordinal dimension, especially since the library does not (yet) support hovering over polylines to get the actual values. I'll look into implementing an API for setting the minimum/maximum number of uniques, hopefully in the next few days.

Contributor

shodanjr commented Feb 2, 2015

If I skip the check, then i actually get the optimal behavior that you describe in #79 (label in the middle of the axis range, poly line crossing through it). I don't like the idea of skipping labels in an ordinal dimension, especially since the library does not (yet) support hovering over polylines to get the actual values. I'll look into implementing an API for setting the minimum/maximum number of uniques, hopefully in the next few days.

@syntagmatic syntagmatic changed the title from pc.autoscale() function removes ordinal dimensions with a single value from dimension set to Display ordinal dimensions with a single value range Feb 3, 2015

@syntagmatic syntagmatic changed the title from Display ordinal dimensions with a single value range to Display ordinal dimensions with a single value domain/range Feb 3, 2015

@syntagmatic

This comment has been minimized.

Show comment
Hide comment
@syntagmatic

syntagmatic Feb 3, 2015

Owner

Awesome work. This is an important detail.

Owner

syntagmatic commented Feb 3, 2015

Awesome work. This is an important detail.

@syntagmatic syntagmatic added the priority label Feb 3, 2015

@syntagmatic

This comment has been minimized.

Show comment
Hide comment
@syntagmatic
Owner

syntagmatic commented Feb 16, 2015

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