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

Fix #22 and add docs #25

Merged
merged 15 commits into from
Sep 5, 2016
Merged

Fix #22 and add docs #25

merged 15 commits into from
Sep 5, 2016

Conversation

tarekis
Copy link
Contributor

@tarekis tarekis commented Sep 5, 2016

Adds option position, which is enumerated and accepts one of two positions currently: 'bottom' and 'top'. Now the legend element will (correctly) be added to the chart container on the created event, and pre- or appended to the svg.

I also reworked the demo page, added a small documentation to it, and rephrased option descriptions to be more precise.

li.setAttribute('data-legend', i);
li.textContent = legend.name || legend;
legendElement.appendChild(li);
for (var legendNamesIndex = 0, length = legendNames.length; legendNamesIndex < length; legendNamesIndex++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you rewrite forEach to for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Performance is way higher, and forEach is plain syntax sugar. It does lots of unneeded checks on each iteration.

Copy link
Contributor Author

@tarekis tarekis Sep 5, 2016

Choose a reason for hiding this comment

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

If jsperf wasn't down you could see the reference test here. Let's hope jsperf v2 comes soon...

Copy link
Contributor

Choose a reason for hiding this comment

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

I know about that test, but this is micro-optimization, and doesn't actually make a difference. I consider the advantages of forEach to be more important; readability, less chance of a off-by-one error, and having a separate scope. If it would be about thousands of items in the array I would consider using for, but for this not. Sorry.

@SpaceK33z
Copy link
Contributor

Hi, thanks for this. It's a huge PR, so it will take some time to review.

@tarekis
Copy link
Contributor Author

tarekis commented Sep 5, 2016

Sure thing, thanks for your time to review it!

})
]
});</code></pre>
<h3>Chart with <i>clickable</i>:</h3>
Copy link
Contributor

Choose a reason for hiding this comment

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

The default value is clickable: true. It says here that the legend should be clickable, but you pass clickable: false, making it not-clickable ;).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, i actually changed the value to false, so actual changes for the option can be seen on the page; it would be quite irritating not to change anything, this way the viewer won't see any changes the option makes, but the description is indeed misleading. I'd change the description to:

Sets the legends clickable state; setting this value to false disables toggling graphs on legend click.

Please let me know if you can agree with that making sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

Allright, yeah it was only the text that confused me. That change would be fine.

@SpaceK33z
Copy link
Contributor

Other then the changes above, it looks good. The example page is really gorgeous now :).

@SpaceK33z
Copy link
Contributor

For a next time, it would be better to make a separate PR for each feature. It makes changes easier to review and reason about. I won't ask you to do it for this one, because that would probably be a huge pain.

@tarekis
Copy link
Contributor Author

tarekis commented Sep 5, 2016

You're right twice, it would be a huge pain, and i realized my error the moment i pushed the commits; gonna seperate future PR's ;)

@tarekis
Copy link
Contributor Author

tarekis commented Sep 5, 2016

Reverted the enumeration and loop conversion and fixed the clickable description.. and some things i just broke by doing just that 😅 . Please have a quick look if you deem the changes useful now.

@SpaceK33z
Copy link
Contributor

Great. Thanks again!

@SpaceK33z SpaceK33z closed this Sep 5, 2016
@SpaceK33z
Copy link
Contributor

Ehmm whoops

@SpaceK33z SpaceK33z reopened this Sep 5, 2016
@SpaceK33z SpaceK33z merged commit 66c56b6 into CodeYellowBV:master Sep 5, 2016
@SpaceK33z
Copy link
Contributor

Published in v0.5.0.

@tarekis
Copy link
Contributor Author

tarekis commented Sep 5, 2016

No problem! Also, i just realized that the index.html belongs into the gh-pages branch, oops. Do you wanna change that, or should i hack together some PR?

@SpaceK33z
Copy link
Contributor

No it's fine, I'll also update the gh-pages branch.

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