Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
d3charts
Advanced tools
Readme
v0.1.8
Convenience functions for spinning up d3-powered charts. Not an automatic charting tool, just a way for code-lovers to reduce tedium.
By @wilson428 and @davejohn
Assuming you have a <div>
in the body with the id "bar_chart":
// Data thanks to http://harrypotter.answers.wikia.com/wiki/Top_200_most_named_harry_potter_characters_s
var mentions = [ ["Harry", 18956], ["Ron", 6464], ["Hermione", 5486], ["Dumbledore", 2421], ["Hagrid", 2024], ["Snape", 1956], ["Voldemort", 1797], ["Sirius", 1471], ["Draco", 1198] ];
var chart = d3charts("#bar_chart", {
margin: { top: 35, right: 20, bottom: 20, left: 35 },
aspect: 0.75,
onChartResize: update_chart,
title: "Most-mentioned Characters in <em>Harry Potter</em>"
});
var x = chart.addAxis("x", {
domain: mentions.map(function(d) { return d[0]; }),
type: "ordinal"
});
var y = chart.addAxis("y", {
domain: [0, 20000],
rules: true,
tickFormat: function(d) { return (d / 1000) + "K" }
});
var bars = chart.data_layer.selectAll(".bar")
.data(mentions)
.enter()
.append("rect")
.attr("class", "bar");
function update_chart() {
chart.data_layer.selectAll(".bar")
.attr("x", function(d) {
return x.scale(d[0]);
})
.attr("width", function(d) {
return x.scale.bandwidth();
})
.attr("y", function(d) {
console.log(d[1], y.scale(d[1]), chart.height)
return y.scale(d[1]);
})
.attr("height", function(d) {
return chart.height - y.scale(d[1]);
})
}
update_chart();
The d3charts
function creates a new blank chart without any axes or anything else, inside a responsive SVG courtesy of elastic-SVG. There are two layers: g.axes_layer
and g.data_layer
.
property | description | default |
---|---|---|
margin | margin around charts | {top: 20, right: 50, bottom: 30, left: 30} |
title | title of chart | "" |
opts
also accepts some arguments for elastic-SVG
:
property | description | default |
---|---|---|
width | width of chart | container width |
aspect | height/width | 0.618 |
height | height of chart | width * 0.618 |
myChart.resize()
elastic-svg
after loadsetDomain
for resetting the domain after constructionFAQs
Wrapper for D3 charts, now d3.v5 compliant
The npm package d3charts receives a total of 16 weekly downloads. As such, d3charts popularity was classified as not popular.
We found that d3charts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.