Skip to content

Replace mouseout/mouseover event handling with SVG stylesheet #6

@jzabroski

Description

@jzabroski

Lines 193-198 are not written using d3.js best practices. Such presentation concerns should be managed in the stylesheet and managed using stylesheet selectors. The radar.js code should only care about which selectors, and the class names should be semantic in meaning.

      .on('mouseover', function(d){
        d3.select(this).select("text.name").style({opacity:'1.0'});
      })
      .on('mouseout', function(d){
        d3.select(this).select("text.name").style({opacity:'0.1'});
      })

would become:

<style>
svg text.name { font-family: Arial, Sans-serif; font-size: 12px; opacity: 0.1 }
svg text.name:hover { font-family: Arial, Sans-serif; font-size: 12px; opacity: 1.0 }
</style>

This also allows consumers like me (see issue #5) to change the style of the presentation without needing to edit any code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions