Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Here's a thing you have to do a lot when using D3 data joins:
// Here, you provide a function to that gets an id from a datum so that D3
// can correctly identify a corresponding element to update.
var thingElements = rootSelectAll('.leaf').data(
things, function getId(thing) { return thing.id; }
);
thingElements.enter().append('option');
// Here, you provide a function get gets a label from a datum so that D3
// can set the text for each element.
thingElements.text(function getLabel(thing) { return thing.label; });
thingElements.exit().remove();
While those accessor functions aren't hard to write, it's easier to just use something that makes them for you, like this:
var thingElements = rootSelectAll('.leaf').data(accessor());
thingElements.enter().append('option');
thingElements.text(accessor('label'));
thingElements.exit().remove();
npm install accessor
If you're using Browserify:
var accessor = require('accessor');
Otherwise:
<script src="node_modules/accessor/index.js">
Then, you'll have the accessor
function. It takes an argument, property
, and returns a function that takes an object and returns that object.property
. If you provide no argument property
will default to id
.
You can specify a second argument, a default value. The accessor will return the default value if the property you're accessing is undefined on the object.
Run tests with make test
.
MIT.
FAQs
Provides accessor functions for convenience in D3 programming
The npm package accessor receives a total of 0 weekly downloads. As such, accessor popularity was classified as not popular.
We found that accessor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.