-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Html legend dc v3 #1392
Html legend dc v3 #1392
Conversation
@rrameshkumar76 Please review changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for considering this PR for merge. Looks good to me. I don't have any experience using D3v4, Looks like these are just method changes for v4 in specs.
The only one I am not sure about is the usage of .nodes() for [0].
Actually quite a lot has changed between D3v3 to D3v4. Thankfully in your code there was nothing that needed change :) The I have not gone very deeply into the functionality of the widget, I do understand that it offers features that are different from the legend already included in the library. Please add one/two more example that demonstrates those. I have added you as a contributor to my fork of dc.js. Please checkout branch Documentation will also need to be updated. |
Thanks @rrameshkumar76, can you please add an example showing scrollbar and css styling. I have given you commit access to the repository, you can directly commit to the branch. |
I have updated the example for html legends to show the scrollbar.Please take a look and let me know if it needs more updates. Another feature I can add is to highlight the selected legend. I have that working in my project without specs which i would need to add. I can commit that to the same branch. |
Please add the highlight feature and commit to the same branch. |
I have added the highlight feature. Please take a look in the example. specs are pending. If It looks good then will go ahead and add the specs. The build fails in "saucelabs-jasmine:all" . I hope this has nothing to do with my commit? |
Thanks @rrameshkumar76, the example looks much more explanatory now. The feature to highlight selected items is definitely useful. I have made minor changes in CSS (dc.scss and the example html) - just to make example look better. Please pull before making further changes. Please go ahead with the specs. Also check the documentation at http://localhost:8888/web/examples/html-legend.html, some methods have no documentation as of now. Ignore the errors on "saucelabs-jasmine:all", it is not related to your commits. Sauce labs is a 3rd party service to run tests on multiple browsers. In this repository credentials for that service are not there so it will fail. |
src/html-legend.js
Outdated
@@ -16,7 +14,8 @@ dc.htmlLegend = function () { | |||
_container, | |||
_legendText = dc.pluck('name'), | |||
_maxItems, | |||
_horizontal = false; | |||
_horizontal = false, | |||
_legendItemClass; | |||
|
|||
var _l; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be made a local variable in _legend.render
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the _legendItemClass variable? This can be overridden using the legendItemClass method in below file.
The legend highlighting is probably only useful/works for pie chart legends and not for multi line charts/stacked bar charts as the behaviour of legend usage is different in those charts.
One thing good may be to add the legend highlight as optional parameter(highlightSelected) allowing user to choose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I meant the var _l
Yes, I also agree that making the highlight selection as optional setting is a good idea. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will move _l to be a a local variable and add highlightSelected as optional setting.
Thanks @rrameshkumar76, I will check and get back. 👍 |
documentation update and spec for highlight is still pending. I think i will need to add a piechart and attach htmlLegend in specs for the unit testing the highlightSelected option. |
@rrameshkumar76 I have made some code changes which should not have changed any functionality. dc.js charts generally keep CSS class names as variables. Also simplified the code using using d3's Thanks for your great work! |
The changes look good. I fixed the jsdoc , spec is still pending. |
Thanks @rrameshkumar76! I look forward to reviewing this week. Going forward, I want to figure out a plan for keeping the HTML legend in sync with the SVG legend. I don't think code or tests can be shared, so maybe it is just something to keep in mind for reviews. @kum-deepak, learning how to write (and fix) specs is often a blocker for contributors. I don't think the difficulty is Jasmine so much as understanding what it means to test the DOM. Since you've already picked this up, maybe you have suggestions for how to write the specs for this PR? (There are also quite a few PRs which look good except for missing/broken specs. If you're interested in helping in this area, we could discuss it in the #1391 discussion thread.) |
Thanks @rrameshkumar76! Next 2-3 days I will not be responding frequently. In the meanwhile please check the API of SVG Legend to ensure that this module implements a super-set of the functionality. Same goes for specs as well. Again many thanks for you diligent efforts. |
The html legend should already have all the features of the svg legend with some extra functionality added to it. I just have one spec left for one of the methods (legendItemClass). Other specs have been completed. |
…dded example for horizontal menu.
Changed the base to |
Thanks @davejlong, @rrameshkumar76, @kum-deepak! Merged for 3.0.0 |
Based on #1329. Updated for D3v4.