All Projects → HowNetWorks → Tracegraph

HowNetWorks / Tracegraph

Licence: mit
A JavaScript library for plotting graphs of traceroute or similar data

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Tracegraph

Floweaver
View flow data as Sankey diagrams
Stars: ✭ 266 (+504.55%)
Mutual labels:  data-visualization, d3
Anichart.js
Easily create data visualization animation videos
Stars: ✭ 480 (+990.91%)
Mutual labels:  data-visualization, d3
Victory Chart
Chart Component for Victory
Stars: ✭ 286 (+550%)
Mutual labels:  data-visualization, d3
Keen Dataviz.js
Data Visualization Charting Library
Stars: ✭ 215 (+388.64%)
Mutual labels:  data-visualization, d3
React Plotly.js
A plotly.js React component from Plotly 📈
Stars: ✭ 701 (+1493.18%)
Mutual labels:  data-visualization, d3
Reaviz
📊 Data visualization library for React based on D3
Stars: ✭ 215 (+388.64%)
Mutual labels:  data-visualization, d3
Py d3
D3 block magic for Jupyter notebook.
Stars: ✭ 428 (+872.73%)
Mutual labels:  data-visualization, d3
Calendar Heatmap
A d3 heatmap for representing time series data similar to github's contribution chart
Stars: ✭ 1,985 (+4411.36%)
Mutual labels:  data-visualization, d3
Party Mode
An experimental music visualizer using d3.js and the web audio api.
Stars: ✭ 690 (+1468.18%)
Mutual labels:  data-visualization, d3
D3 Node
Server-side D3 for static chart/map generation ✨📊
Stars: ✭ 606 (+1277.27%)
Mutual labels:  data-visualization, d3
Plotly.js
Open-source JavaScript charting library behind Plotly and Dash
Stars: ✭ 14,268 (+32327.27%)
Mutual labels:  data-visualization, d3
D4
Data-Driven Declarative Documents
Stars: ✭ 797 (+1711.36%)
Mutual labels:  data-visualization, d3
Visx
🐯 visx | visualization components
Stars: ✭ 14,544 (+32954.55%)
Mutual labels:  data-visualization, d3
Plotly Graphing Library For Matlab
Plotly Graphing Library for MATLAB®
Stars: ✭ 234 (+431.82%)
Mutual labels:  data-visualization, d3
Semiotic
A data visualization framework combining React & D3
Stars: ✭ 2,207 (+4915.91%)
Mutual labels:  data-visualization, d3
Britecharts
Client-side reusable Charting Library based on D3.js v5 that allows easy and intuitive use of charts and components that can be composed together creating amazing visualizations.
Stars: ✭ 3,688 (+8281.82%)
Mutual labels:  data-visualization, d3
Electricitymap Contrib
A real-time visualisation of the CO2 emissions of electricity consumption
Stars: ✭ 2,138 (+4759.09%)
Mutual labels:  data-visualization, d3
Victory Native
victory components for react native
Stars: ✭ 2,013 (+4475%)
Mutual labels:  data-visualization, d3
Historical Ranking Data Visualization Based On D3.js
这是一个数据可视化项目,能够将历史数据排名转化为动态柱状图图表
Stars: ✭ 4,649 (+10465.91%)
Mutual labels:  data-visualization, d3
D3 Id3
iD3: an Integrated Development Environment for D3.js
Stars: ✭ 789 (+1693.18%)
Mutual labels:  data-visualization, d3

@hownetworks/tracegraph CircleCI

tracegraph is a JavaScript library for plotting graphs of traceroute or similar data.

Check out the small Observable HQ notebook demonstrating how it can be used.

Installation

$ npm install @hownetworks/tracegraph

Usage

import { tracegraph } from "@hownetworks/tracegraph";

tracegraph()

const graph = tracegraph();

graph(traces)

const layout = graph(traces);

traces should be an array where each item has the following properties:

  • trace.hops - an array of hops that belong to the trace, each hop can be whichever object suits your purpose

layout.bounds is the bounding box of the layout, returned as a DOMRect-like object with some extra convenience properties:

  • bounds.cx, bounds.cy - the coordinates for the center point of the box
  • bounds.expanded(left, [top=left, [right=left, bottom=top]]) - a function that returns a new box that has been expanded by the given amount(s)

layout.traces is an array where each item is a defined/undefined segment is a trace and has the following properties:

  • trace.index - the index of the trace
  • trace.width - the width of the trace
  • trace.hops - the hops belonging to the trace
  • trace.defined - whether the segment is defined or not
  • trace.points - points for drawing the segment
  • trace.smoothness - the layout's smoothness value
  • trace.horizontal - whether the layout is horizontal or vertical

layout.nodes is an array where each item has the following properties:

  • node.bounds - the bounding box of the node, returned as a DOMRect-like similar to layout.bounds above
  • node.horizontal - whether the layout is horizontal or vertical
  • node.hops - an array of hops that belong to the node
  • node.traceIndexes - an array of indexes of the traces that are connected to the node
  • node.traceStops - used for creating (optional) linear gradient for the node to match the positions of its connected traces

graph.horizontal([horizontal])

Defines whether the layout is either horizontal or vertical. Evaluated without arguments for each layout.

Default: false (the layout is vertical)

graph.traceWidth([width])

Defines the width of a trace. Evaluated for each trace with the arguments trace, traceIndex, and traces.

Default: 1

graph.traceSmoothness([smoothness])

A coefficient used in calculating the trace curves. The value should be between 0 and 1 (inclusive), a larger value generally meaning a more round appearance for the curves. Evaluated without arguments for each layout.

Default: 0.5

graph.hopDefined([defined])

Tark traces a hop as either defined or undefined. Evaluated for each hop, with hop, hopIndex, trace, traceIndex, and traces as the arguments.

Default: true

graph.hopLevel([level])

A hop's position (depth, level) in the trace. Evaluated for each hop, with hop, hopIndex, trace, traceIndex, and traces as the arguments.

Default:

function hopLevel(hop, hopIndex) {
  return hopIndex;
}

graph.nodeSize([size])

A node's minimum size as [width, height], used for layout. The final size of the node may be larger. Evaluated without arguments for each output node, with node as the argument. node won't have its position data such as node.x0 set, as the layout won't be finished at the time of the evaluation.

Default: [10, 10]

graph.nodeId([id])

A string identifier for the node a hop belongs to. Evaluated for each hop, with hop, hopIndex, trace, traceIndex, and traces as the arguments.

Default:

function nodeId(hop, hopIndex, trace, traceIndex) {
  return `${traceIndex}-${hopIndex}`;
}

graph.levelMargin([margin])

Margin size around each level of nodes. Evaluated without arguments for each layout.

Default: 10

Helper Functions

import { traceCurve, nodeGradient, genUID } from "@hownetworks/tracegraph";

traceCurve(traceSegment)

Return a string suitable for plotting a layouted trace segment.

svg
  .selectAll(".trace")
  .data(layout.traces)
  .enter()
  .append("path")
  .attr("class", "trace")
  .attr("d", traceCurve());

nodeGradient(node) and genUID()

nodeGradient is a helper method for coloring nodes based on the traces that go through them. genUID can be used to generate the ids for the gradients.

const ids = nodes.map(() => genUID());

svg.append("defs")
  .selectAll("linearGradient")
  .data(layout.nodes.map(nodeGradient))
  .enter().append("linearGradient")
    .attr("id", (d, i) => ids[i].id)
    .attr("gradientUnits", d => d.gradientUnits)
    .attr("x1", d => d.x1)
    .attr("y1", d => d.y1)
    .attr("x2", d => d.x2)
    .attr("y2", d => d.y2)
  .selectAll("stop")
  .data(d => d.stops);
  .enter().append("stop")
    .attr("offset", d => d.offset)
    .attr("stop-color", d => ["red", "green", "blue"][d.traceIndex % 3]);

svg.selectAll("circle")
  .data(layout.nodes)
  .enter().append("circle")
    .attr("fill", "white")
    .attr("stroke", (d, i) => ids[i])
    .attr("r", d => 10)
    .attr("cx", d => d.bounds.cx)
    .attr("cy", d => d.bounds.cy);

License

This library is MIT licensed. See LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].