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

Set minimum/maximum domain for circle packing #460

Merged
merged 1 commit into from
May 24, 2016

Conversation

bryanph
Copy link
Contributor

@bryanph bryanph commented Apr 1, 2016

Changes the current behavior, which is to select the minimum value in the data as the minimum domain.

This causes problems when data is close together, like for example consider the values: [90, 100, 110, 120]. In this case 90 would be drawn as the minimum circle size and 120 as the max circle size.

It might perhaps be useful to also add a custom parameter to change the minimum domain.

@davelandry
Copy link
Member

I'm not a fan of changing this default behavior to zero. If you'd like to make a publically accessable variable to change the domain mins and max that's fine. What might help you in the interim is changing the default minimum radius of the size scale (it defaults to 3):

.size({"scale": {"min": 10}})

Additionally, if you'd like to make the minimum dependent on other things like the available size, reference the current default maximum: https://github.com/alexandersimoes/d3plus/blob/master/src/viz/methods/size.coffee#L13-L14

@bryanph bryanph force-pushed the master branch 2 times, most recently from 4bbcd29 to 671e12d Compare May 18, 2016 13:22
@bryanph bryanph changed the title Set minimum domain to 0 in circle packing Set minimum/,aximum domain for circle packing May 18, 2016
@bryanph
Copy link
Contributor Author

bryanph commented May 18, 2016

I have revised the commit to make the domain min and max available as an option like so:

domain {
min:
max:
}

@bryanph
Copy link
Contributor Author

bryanph commented May 23, 2016

@davelandry would you mind taking a look at this again? :)

@davelandry davelandry changed the title Set minimum/,aximum domain for circle packing Set minimum/maximum domain for circle packing May 23, 2016
@davelandry
Copy link
Member

Getting close!

I don't think this warrants having it's own .domain( ) method, as it only applies specifically to sizing (whereas the x and y axis methods have their own domains).

I would nest it inside of the scale method, moving the current "min" and "max" keys under a new "range" key. The new size.coffee would look something like this:

filter = require "../../core/methods/filter.coffee"

module.exports =
  accepted:   [false, Function, Number, Object, String]
  dataFilter: true
  deprecates: ["value", "value_var"]
  mute:       filter(true)
  scale:
    accepted:   [Function]
    deprecates: "size_scale"
    domain:
      max:
        accepted: [false, Number]
        value:    false
      min:
        accepted: [false, Number]
        value:    false
    range:
      max:
        accepted: [Function, Number]
        value:    (vars) ->
          Math.floor d3.max [d3.min([vars.width.viz,vars.height.viz])/15, 6]
      min:
        accepted: [Function, Number]
        value:    3
    value:      d3.scale.sqrt()
  solo:       filter(true)
  threshold:
    accepted: [Boolean, Function, Number]
    value:    false
  value:      false

@bryanph
Copy link
Contributor Author

bryanph commented May 24, 2016

@davelandry, I have amended it, thanks for your quick response.
Please let me know if this is sufficient :)

@davelandry davelandry merged commit 21c98ec into d3plus:master May 24, 2016
@davelandry
Copy link
Member

Great work @bryanph, I've updated the documentation to clarify this new change: https://github.com/alexandersimoes/d3plus/wiki/Visualizations#size

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

Successfully merging this pull request may close these issues.

None yet

2 participants