All examples By author By category About

1wheel

camelCase attributes

at and st in jetpack work like v3's attr and style. Passing an object sets multiple attributes, passing a string returns a single attribute and passing a string & second argument sets a single attribute.

To avoid having to use quotes around attributes and styles with hyphens when using the object notation, camelCase keys are hyphenated. Instead of:

selection
    .style('margin-top', '250px')
    .style('text-align', 'center')
    .style('font-weight', 600)

or with d3-selection-multi:

selection.styles({'margin-top': '250px', 'text-align': 'center', 'font-weight': 600})

you can write:

selection.st({fontSize: '250px', textAlign: 'center', fontWeight: 600})

With syntax highlighting on, it is a little easier to see the difference between keys and values when everything isn't a string. Plus there's less typing!