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

Add initial victory-legend #116

Merged
merged 4 commits into from
Sep 21, 2016

Conversation

janesh-travolta
Copy link
Contributor

No description provided.

container.appendChild(label);

const bBox = label.getBoundingClientRect();
body.removeChild(container);
Copy link
Contributor

Choose a reason for hiding this comment

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

I have concerns about this pattern. Everything will need to be extendable to the React Native version of Victory

@boygirl
Copy link
Contributor

boygirl commented Aug 24, 2016

@janesh-travolta This is generally looking good! Here's my high-level feedback:

Anything that renders svg needs to be extracted into a new component and included as a prop

  • users should be able to provide their own symbols / labels / etc
  • default components should be replaceable with native compatible versions in victory-native. This pattern makes our native versions look like this. Short and sweet :)

It should be possible to specify everything about the style of a symbol and label

  • i.e. opacity, stroke, etc.
  • maybe the data prop could be more like:
data={[
  {
    name: "thing 1", // required
    label: {all the props for your label component}, // optional with defaults
    symbol: {all the props for your symbol component} // optional with defaults
  },
  ...
]}

import { merge, assign, isEmpty } from "lodash";
import VictoryLabel from "../victory-label/victory-label";
import VictoryContainer from "../victory-container/victory-container";
import Point from "../point/point"; // it should be replaced
Copy link
Contributor

Choose a reason for hiding this comment

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

If you merge master you can use the point component victory-primitives/point

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.

Overall there is some confusion about how theme / props / fallback props should operate together. I think I would like to open a branch for you to merge this work into rather than master so that we can collaborate more directly on getting this more consistent with other Victory components.

static defaultProps = {
x: 0,
y: 0,
height: 100,
Copy link
Contributor

Choose a reason for hiding this comment

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

width and height don't seem to be used at all. Instead they are coming from default legend style?

};

getLabelStyles(props) {
return merge({}, fallbackProps.style.labels, props.label);
Copy link
Contributor

Choose a reason for hiding this comment

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

props.label is not defined

const { dataComponent, labelComponent } = props;
const data = isEmpty(props.data) ? defaultLegendData : props.data;

data.forEach((series, i) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a length cached for loop for perf reasons

);
});

const group = this.renderGroup([...dataComponents, ...labelComponents]);
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer if calculating all the dataComponents and labelComponents was moved outside of the render method like:

renderLegend(props) {
  ...
  return [...dataComponents, ...labelComponents];
}

render() {
   // do all your style / theme / fallback prop merging here
   const group = this.renderGroup(this.renderLegend(reconciledProps));
   return props.standalone ? this.renderContainer(props, group) : group;
}

dataComponent, assign({}, symbolProps)
);
labelComponents[i] = React.cloneElement(
labelComponent, assign({}, labelProps)
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary assign

}, assign({}, fallbackProps.style.labels, props.style.labels, series.label));

dataComponents[i] = React.cloneElement(
dataComponent, assign({}, symbolProps)
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary assign

data.forEach((series, i) => {
const font = this.getLabelStyles(series);
const symbolSize = font.fontSize;
const hPadding = symbolSize * 0.87;
Copy link
Contributor

Choose a reason for hiding this comment

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

Magic numbers...

@boygirl boygirl changed the base branch from master to legend September 15, 2016 18:17
@boygirl
Copy link
Contributor

boygirl commented Sep 21, 2016

@janesh-travolta I'm going to merge this into the legend branch for ease of collaboration

@boygirl boygirl merged commit 7d15430 into FormidableLabs:legend Sep 21, 2016
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.

2 participants