question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add HTML legend support

See original GitHub issue

Something like PR and I have asked question but I don’t think if some take a look into closed PR so opened this bug for further discussions.

I strongly feel that HTML legend make more sense and it in-fact make life much easy atleast in the following cases Issue, Issue:

Case-1: huge list of items (see image 1 in our application - summarize data of 300K records since we couldn’t show the complete list we added "Others" to show there more items below )

  • Showing them as a vertical list would be impossible because the SVG size may not be enough to fit all of them within the view-able area.
  • Even if we manage to show with adjusting gaps etc… it will be nightmare for user to walk through the list to find the particular item in the list.
  • Otherwise we must provide the arrow (up/down) to indicate more items are available and this logic would be too complicate and also its too much burden to user to click through the list to find the item of interest.

Case-2: Add advance features:

  • Its not easy to implement the search or filter feature in SVG when the list is huge to find the item of interest (see google maps - search by typing address - for example how it will be helpful).
  • In many cases it will be convenient to take controls of legends items to enable/disable filter on click of item based on certain condition (ex: if user is Guest / Author) - this just an example.
  • Would allow to taking advantage of JS frameworks data binding (Angular 2) and custom template to add meaningful presentation etc…
  • Add collapse and expand the legend or add more features like drag to position on the chart.

Case-3: Customize (see the google map image)

  • Allow to skin the legend to the application theme (material design!).
  • Not everyone JS developer are styling experts, many of the JS developer use the CSS frameworks like bootstrap to develop the website/web-applications and those frameworks doesn’t provide the styling feature for SVG.

legend google-maps

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
gordonwoodhullcommented, Jul 26, 2017

Thanks for posting these arguments. They are persuasive.

I agree with all of your points except for one.

For the advanced features, I don’t think it will be any easier to take control over the legend click action. You can easily change the click behavior using d3, for example see this answer about toggling composite child charts on legend click.

I also think it would be easy to add collapse/expand functionality with a similar “renderlet”, and maybe you could use d3.behavior.drag for dragging too. But I agree there is a much bigger ecosystem of reusable interactive behaviors on the HTML side than the SVG side.

The quickest way to get this feature into the library is to review @davejlong’s PR (or start your own dc.htmlLegend if for some reason you don’t like it).

If you don’t want to rebase the branch, you should be able to try it out just by copying the content of src/html-legend.js into your local copy of dc.js.

Once you’ve tried it out, please comment on #577 and I’ll reopen it.

Please carefully review the interface of the original legend: http://dc-js.github.io/dc.js/docs/html/dc.legend.html

I think that almost all of these are layout-related and can better be done with CSS, but legendText and maxItems should probably be added to #577 if we go with that.

Would you be willing to start a new PR and add these, along with tests?

0reactions
gordonwoodhullcommented, Apr 28, 2018

Implemented in 3.0.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML legend tag - W3Schools
Definition and Usage. The <legend> tag defines a caption for the <fieldset> element. ... The <legend> tag also supports the Global Attributes in...
Read more >
The Field Set Legend element - HTML - MDN Web Docs
The <legend> HTML element represents a caption for the content of its parent <fieldset> . Try it. HTML Demo: <legend>. Reset. HTML CSS...
Read more >
HTML <legend> Tag - GeeksforGeeks
The legend tag is used to define the title for the child contents. The legend elements are the parent element. This tag is...
Read more >
<legend> HTML Tag »
The <legend> element is used to add a caption to a group of related form <input> elements that have been grouped together into...
Read more >
HTML Legend Tag | Attributes and Various ... - eduCBA
In general, HTML tags has one or more attributes that provide a great aspect of an HTML element. The Legend Tag supports all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found