Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Legend #189

Merged
merged 23 commits into from
Jan 19, 2017
Merged

Legend #189

merged 23 commits into from
Jan 19, 2017

Conversation

angelanicholas
Copy link
Contributor

  • adds new victory legend component & tests
  • demos:
    screen shot 2017-01-18 at 2 52 06 pm

janesh-travolta and others added 11 commits August 24, 2016 14:02
* master: (164 commits)
  short cut equality checks
  simplify area
  add sCU to VictoryLabel
  adjust domain for padding when calculating padding
  add sCU to all primitive components
  Version 11.0.1 - VictorySharedEvents bug
  update changelog
  fallback container
  removed .DS_Store from project
  Version 11.0.0 - support VictorySelectionContainer
  update changelog
  set active on data when triggering toolitps
  add selection spec
  support active prop on primitive children
  add active
  dont include parent with all eventKey helper
  allow childName 0
  correct child-parent events
  lint
  extract selection logic
  ...
Copy link
Contributor

@boygirl boygirl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@angelanicholas this is looking good. I think the changes I would like to see before merging are 1) getting rid of state, and 2) making it work with themes (and then adding appropriate legend themes). If you get around to adding a colorScale that's great too, but a nice to have. Events can wait until v2 if you like.

import VictoryContainer from "../victory-container/victory-container";
import Point from "../victory-primitives/point";

const defaultStyles = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@angelanicholas Can this stuff go into a theme instead? Can you add a theme prop so that the legends work with themes?


constructor(props) {
super(props);
this.state = this.getLegendState(props);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other components calculate values in render and then pass some kind of calculatedProps object down to the methods that need them.

symbol: PropTypes.object
})
),
containerComponent: PropTypes.element,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have legend take a colorScale prop so that it can auto-color a legend to match some component that uses one of our color scales i.e. pies and stacked bars

})
),
containerComponent: PropTypes.element,
dataComponent: PropTypes.element,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VictoryLegend should work with events, but we can save that for v2 if you want.

@angelanicholas
Copy link
Contributor Author

@boygirl Sounds good! I haven't really figured out what kind of events we'd want in legend yet, will file a ticket for that after merging. Removed state and added colorScale and theme props though! Ready for re-review.

getCalculatedProps() { // eslint-disable-line max-statements
const { role } = this.constructor;
const { data, orientation, theme } = this.props;
let { height, width } = this.props;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to define width / height in the theme too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And padding

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

const symbolStyles = [];
const labelStyles = [];
let leftOffset = 0;

padding = Helpers.getPadding({ padding: padding || theme.padding });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to remove padding from default props, and make this check respect padding = 0. Also, if you remove padding from default props, this should have a fallback right in the code like props.padding || theme.padding || 0; except with existence checking that respects zero.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helpers.getPadding has a 0 fallback already if padding || theme.padding is undefined, and padding was removed from defaultProps in the previous commit

@boygirl
Copy link
Contributor

boygirl commented Jan 19, 2017

🚀 Thanks @angelanicholas

@angelanicholas angelanicholas merged commit 8c1d993 into master Jan 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants