Skip to content
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

legend range does not update when clicking the additional values rectangle #509

Closed
m-ibm opened this issue Jul 6, 2016 · 7 comments
Closed

Comments

@m-ibm
Copy link

m-ibm commented Jul 6, 2016

I title pretty much says it all; the legend range might be incorrect when min/max is under the additional values rectangle.

I have a case where the size of the rectangles is based on field X and the legend on field Y.
It also happens that the objects with (both) min/max values of Y are small enough to be bundled under the 'Values < zzz' rectangle.

The legend displays the min/max as those of the shown values, which could be fine if the legend would update when drilling in, and that does not happen.
Since it makes sense that the legend boundaries are static, it should generate the ticks taking into account all objects, not only the displayed ones.

@davelandry
Copy link
Member

I'm not following some of this, can you post a code snippit showing the problem?

@m-ibm
Copy link
Author

m-ibm commented Jul 18, 2016

The below treemap definition is only part of what we use, but should be enough to explain this issue.

        treeMap = d3plus.viz()
        .container("#viz")
        .data(data)
        .size( {
            "value":"Y",
            "threshold":true
        })
        .type("tree_map")
        .aggs( { "X" : "mean" } )
        .legend( { "value" : true } )

When we have a few hundred data points, the tree-map will have the 'others' rectangle.
Assume that the values of X are between 1 and 10. The legend should be between these values.
However, if for example. all values of 0 (or 10) are on data points hidden in the 'others' rectangle the legend will display 1-10 (or 0-9) instead of 0-10.

This appears to happen because the calculation of the legend occurs only after filtering the data to be displayed. This calculation is only performed once, so drilling in will not change the boundaries.

The fix should be simple - consider all the data when deciding on the min/max values for the legend.

@davelandry
Copy link
Member

If I'm understanding you correctly, this is expected behavior.

Set aside the "threshold" option for a second, and consider simple nesting. Given this configuration:

<div id="viz"></div>
var data = [
  {value: 10, parent: 1, id: "a"},
  {value: 30, parent: 1, id: "b"},
  {value: 20, parent: 2, id: "c"}
];

d3plus.viz()
  .container("#viz")
  .color("value")
  .data(data)
  .id("parent")
  .size("value")
  .type("tree_map")
  .draw();

The visible color scale here goes from 20 to 40, which is correct given the groupings that are occurring. Even though there is a data point with a value of 10, it is being visually represented as it's parent group, which has a summed value of 40.

@m-ibm
Copy link
Author

m-ibm commented Jul 24, 2016

My point is that the legend is incorrect, not the aggregation.
In your example there will be no color for value 10 even when expanding parent 1. This is not what the user expects.
The legend should always represent all the values in the data, regardless of the aggregation.
If (and this isn't happening as far as I can tell) the legend would be updated when expanding parent 1, then it is arguably correct though, as a user, I would find it somewhat confusing to see the legend change (note that I mentioned color and size as different data fields).

@davelandry
Copy link
Member

I'm sorry, that snippet of code I posted is missing a crucial line:

var data = [
  {value: 10, parent: 1, id: "a"},
  {value: 30, parent: 1, id: "b"},
  {value: 20, parent: 2, id: "c"}
];

d3plus.viz()
  .container("#viz")
  .color("value")
  .data(data)
  .id(["parent", "id"])
  .size("value")
  .type("tree_map")
  .draw();

When you give the .id( ) method an array of IDs, it properly nests the data and updates the scale when zooming. Here is what it looks like at the parent level, with color scale from 20 to 40:

screen shot 2016-08-12 at 10 25 05 am

And then once clicking on parent 1, the scale updates to 10 to 30:
screen shot 2016-08-12 at 10 25 30 am

Let me know if that's not what you are seeing, or what you'd expect the scale ranges to be for each level.

@m-ibm
Copy link
Author

m-ibm commented Aug 15, 2016

Your example works as expected.
However, my (specific) data does not have nesting levels. The nesting is implicit by having too many rectangles to display, thus the other rectangle appears.

What I see is the legend being drawn with values that don't include the actual data min and max. This could be fine as in my example min and max happen to be inside the other rectangle whose legend value is defined by the mean of its contents.
However, the redraw when drilling into the other rectangle has he same values; I would expect a different range, especially since now min and max are not aggregated with anything.

In the general case, whether or not the other rectangle is displayed, I would expect to see a legend with the min/max range of the original data.
I think this is orthogonal to whether the data has nesting levels or not.

@davelandry davelandry changed the title Legend range might be incorrect when min/max is under the additional values rectangle legend range does not update when clicking the additional values rectangle Aug 16, 2016
@davelandry
Copy link
Member

Ahh I see, thanks for clarifying. I was able to fix it so that the legend scale updates when clicking on the other rectangle. Will be part of next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants