Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-flame-graph

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-flame-graph - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

8

bower.json
{
"name": "d3-flame-graph",
"version": "0.1.0",
"version": "0.2.0",
"homepage": "https://github.com/spiermar/d3-flame-graph",

@@ -27,4 +27,8 @@ "authors": [

"dependencies": {
"d3": "~3.5.6"
"d3": "~3.5.5",
"d3-tip": "~0.6.7"
},
"resolutions": {
"d3": "3.5.5"
}
}

@@ -5,5 +5,5 @@ var gulp = require('gulp'),

notify = require("gulp-notify"),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
del = require('del');
del = require('del'),
browserSync = require('browser-sync').create();

@@ -24,24 +24,10 @@ gulp.task('clean', function() {

gulp.task('connect', function() {
connect.server({
root: ['example', 'src', 'bower_components'],
livereload: true
});
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: ['example', 'src', 'bower_components']
}
});
});
gulp.task('html', function () {
gulp.src('./example/*.html')
.pipe(connect.reload());
});
gulp.task('js', function () {
gulp.src('./src/*.js')
.pipe(connect.reload());
});
gulp.task('watch', function () {
gulp.watch(['./example/*.html'], ['html']);
gulp.watch(['./src/*.js'], ['js']);
});
gulp.task('default', ['connect', 'watch']);
gulp.task('default', ['browser-sync']);
{
"name": "d3-flame-graph",
"version": "0.1.0",
"version": "0.2.0",
"description": "A d3.js library to produce flame graphs.",

@@ -31,2 +31,3 @@ "main": "dist/d3.layout.flame.min.js",

"devDependencies": {
"browser-sync": "^2.9.10",
"browserify": "^11.2.0",

@@ -33,0 +34,0 @@ "del": "^2.0.2",

# d3-flame-graph
D3.js Plugin for Flame Graphs
A d3.js library to produce flame graphs.
![Flame Graph](http://www.brendangregg.com/FlameGraphs/cpu-mysql-filt.svg)
If you don't know what flame graphs are, check [Brendan Gregg's post](http://www.brendangregg.com/flamegraphs.html).
> Flame graphs are a visualization of profiled software, allowing the most frequent code-paths to be identified quickly and accurately. They can be generated using my open source programs on [github.com/brendangregg/FlameGraph](http://github.com/brendangregg/FlameGraph), which create interactive SVGs.
>
> <cite>Brendan Gregg</cite>
## Disclaimer
This is the first release of this library. As such, expect to find bugs and issues. We count on your support to find and report them!
**At this point, the library provides only basic flame graph functionality. Please check the [issues](https://github.com/spiermar/d3-flame-graph/issues) page for roadmap information.**
## Getting Started
### Bower
Make sure [Bower](http://bower.io/) installed on your system. If not, please install it using [npm](https://www.npmjs.com/).
```
$ npm install bower -g
```
Install the d3-flame-graph library.
```
$ cd your-project
$ bower install --save
```
And use it!
```
<script type="text/javascript" src="bower_components/d3/d3.js"></script>
<script type="text/javascript" src="bower_components/d3-flame-graph/dist/d3.layout.flame.js"></script>
<script type="text/javascript">
var flamegraph = d3.layout.flame().height(600).width(1200);
d3.json("stacks.json", function(error, data) {
if (error) return console.warn(error);
d3.select("svg g.partition")
.datum(data)
.call(flamegraph);
});
</script>
```
## Issues
For bugs, questions and discussions please use the [GitHub Issues](https://github.com/spiermar/d3-flame-graph/issues).
## Contributing
We love contributions! But in order to avoid total chaos, we have a few guidelines.
If you found a bug, have questions or feature requests, don't hesitate to open an [issue](https://github.com/spiermar/d3-flame-graph/issues).
If you're working on an issue, please comment on it so we can assign you to it.
If you have code to submit, follow the general pull request format. Fork the repo, make your changes, and submit a [pull request](https://github.com/spiermar/d3-flame-graph/pulls).
### Gulp.js
This library uses Gulp.js as build system. A few tasks are already defined, including browser-sync that can be used for development. To start it, just execute the default task.
```
$ git clone https://github.com/spiermar/d3-flame-graph.git
$ cd d3-flame-graph
$ npm install
$ bower install
$ gulp
```
## License
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

@@ -12,20 +12,39 @@ (function() {

}
function name(d) {
return d.name;
}
function color(name) {
var hash = 0, i, chr, len;
function hash(name) {
// Return a vector (0.0->1.0) that is a hash of the input string.
// The hash is computed to favor early characters over later ones, so
// that strings with similar starts have similar vectors. Only the first
// 6 characters are considered.
var hash = 0, weight = 1, max_hash = 0, mod = 10, max_char = 6;
if (name) {
for (i = 0, len = name.length; i < len; i++) {
if (name[i] == '(') { break; }
chr = name.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
for (var i = 0; i < name.length; i++) {
if (i > max_char) { break; }
hash += weight * (name.charCodeAt(i) % mod);
max_hash += weight * (mod - 1);
weight *= 0.70;
}
if (max_hash > 0) { hash = hash / max_hash; }
}
hash = Math.abs((hash % 256) / 256.);
var r = 50 + Math.round(60 * hash);
var gb = 135 + Math.round(90 * hash);
return "rgb(" + r + "," + gb + "," + gb + ")";
return hash;
}
function color_hash(name) {
// Return an rgb() color string that is a hash of the provided name,
// and with a warm palette.
var vector = 0;
if (name) {
name = name.replace(/.*`/, ""); // drop module name if present
name = name.replace(/\(.*/, ""); // drop extra info
vector = hash(name);
}
var r = 200 + Math.round(55 * vector);
var g = 0 + Math.round(230 * (1 - vector));
var b = 0 + Math.round(55 * (1 - vector));
return "rgb(" + r + "," + g + "," + b + ")";
}
function augment(root) {

@@ -69,2 +88,6 @@ // Augment partitioning layout with "dummy" nodes so that internal nodes'

var tip = d3.tip().attr('class', 'd3-tip').html(function(d) { return label(d); });
container.call(tip);
var g = container.selectAll("rect")

@@ -78,3 +101,5 @@ .data(nodes)

.attr("class", "frame")
.attr("name", function(d) { return d.name; });
.attr("name", function(d) { return d.name; })
.on('mouseover', tip.show)
.on('mouseout', tip.hide);

@@ -84,3 +109,3 @@ rect = g.append("svg:rect")

.attr("height", function(d) { return frameheight; })
.attr("fill", function(d) {return color(d.name); })
.attr("fill", function(d) {return color_hash(d.name); })
.style("opacity", function(d) {return d.dummy ? 0 : 1;})

@@ -98,4 +123,4 @@

.attr("class", "label")
.style("display", function (d) { return d.dx * kx < 25 ? "none" : "block";})
.text(label)
.style("display", function (d) { return d.dx * kx < 35 ? "none" : "block";})
.text(name)
}

@@ -102,0 +127,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc