Coder Social home page Coder Social logo

john-guerra / navio Goto Github PK

View Code? Open in Web Editor NEW
106.0 106.0 13.0 119.6 MB

A d3 visualization widget to help summarizing, exploring and navigating large network visualizations

Home Page: https://navio.dev

License: MIT License

JavaScript 92.41% HTML 7.50% Shell 0.07% CSS 0.02%

navio's Introduction

Star

Moma Explorer Navio:
A visualization widget to understand and explore your data

Use it to summarize, explore and navigate your multivariate data using three simple interactions:

Sort Filter a Range Filter By Value
Click on a header to sort
Navio sort on les miserables network
Drag to select a range
Moma Explorer
Click on a value to select all instances
Navio select a value with the vispubdata

Try it!

You can test Navio right now with your own CSV or JSON data (less than 200MB), using:

Obervable Notebook Shipyard Jupyter Notebook
Navio-load Observable Shipyard loading data Navio Jupyter Notebooks

Other demos:

Comparing

Why using something else for summarizing your data?. Here is how Navio compares with other alternatives:

Navio vs Parallel Coordinates

You can use this Notebook to compare Navio with Parallel Coordinates, using your own data. Please be aware that the Vegalite implementation of Parallel Coordinates will break with a few thousand rows (on the image below it broke with 500 rows and 86 attributes of the fifa19 Kaggle Dataset)

Navio versus Parallel Coordinates

Navio vs Scatterplot Matrix

Use this Notebook to compare Navio with a Scatterplot Matrix, using your own data. Please be aware that the Vegalite implementation of the Scatterplot Matrix only support quantitative attributes and will also break with a dozen attributes and a few hundred rows), therefore the image below only displayed 8 attributes (out of the 28) on the scatterplot matrix.

Navio versus Scatterplot Matrix

Install

npm install navio

Or use it from unpkg

  <script type="text/javascript" src="https://d3js.org/d3.v4.min.js"></script>
  
  <script src="https://unpkg.com/[email protected]/dist/umd/popper.min.js"></script>
  <script type="text/javascript" src="https://unpkg.com/navio/dist/navio.min.js"></script>

Requires ^[email protected], ^[email protected]. If you want to use d3@4 use [email protected]

Usage

TLDR

<!DOCTYPE html>
<body>
  <!-- Placeholder for the widget -->
  <div id="navio"></div>

  <!-- NAVIO Step 0: Load the libraries -->
  <script type="text/javascript" src="https://d3js.org/d3.v6.min.js"></script>
  <script src="https://unpkg.com/[email protected]/dist/umd/popper.min.js"></script>
  <script type="text/javascript" src="https://unpkg.com/navio/dist/navio.min.js"></script>

<script>
  // NAVIO  Step 1.  Create a Navio passing a d3 selection to place it and an optional height
  var nv = navio(d3.select("#navio"), 600);

  d3.csv(YOUR_DATA).then(data) => {
    // NAVIO Step 2. Load your data!
    nv.data(data);

    // NAVIO Step 3. Detect your attributes (or load them manually)
    nv.addAllAttribs();

    // Optional, setup a selection callback
    nv.updateCallback( selected => console.log("selected in Navio: ", selected.length));
  });
</script>
</body>
</html>

Step by step

  1. HTML. Start with this template
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Basic Usage</title>
</head>
<body>

  // Your Navio widget goes here
  <div id="Navio"></div>

</body>
</html>
  1. Import Navio. Create and import a new JavaScript file below the scripts (d3 and Navio) or right in the html like in the example below.
<script src="https://d3js.org/d3.v6.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/navio/dist/navio.min.js"></script>
<script type="text/javascript">
  //   YOUR_JS_CODE_HERE
</script>
  1. Create a Navio Instance
var nv = navio(d3.select("#Navio"), 600); //height 600
  1. [Optional] Configure navio to your liking
// Default parameters
nv.x0 = 0;  //Where to start drawing navio in x
nv.y0 = 100; //Where to start drawing navio in y, useful if your attrib names are too long
nv.maxNumDistictForCategorical = 10; // addAllAttribs uses this for deciding if an attribute is categorical (has less than nv.maxNumDistictForCategorical categories) or ordered
nv.maxNumDistictForOrdered = 90; // addAllAttribs uses this for deciding if an attribute is ordered (has less than nv.maxNumDistictForCategorical categories) or text. Use nv.maxNumDistictForOrdered = Infinity for never choosing Text

nv.howManyItemsShouldSearchForNotNull = 100; // How many rows should addAllAttribs search to decide guess an attribute type
nv.margin = 10; // Margin around navio

nv.levelsSeparation = 40; // Separation between the levels
nv.divisionsColor = "white"; // Border color for the divisions
nv.levelConnectionsColor = "rgba(205, 220, 163, 0.5)"; // Color for the conections between levels
nv.divisionsThreshold = 4; // What's the minimum row height needed to draw divisions
nv.fmtCounts = d3.format(",.0d"); // Format used to display the counts on the bottom
nv.legendFont = "14px sans-serif"; // The font for the header
nv.nestedFilters = true; // Should navio use nested levels?

nv.showAttribTitles = true; // Show headers?
nv.attribWidth = 15; // Width of the columns
nv.attribRotation = -45; // Headers rotation
nv.attribFontSize = 13; // Headers font size
nv.attribFontSizeSelected = 32; // Headers font size when mouse over

nv.filterFontSize = 10; // Font size of the filters explanations on the bottom

nv.tooltipFontSize = 12; // Font size for the tooltip
nv.tooltipBgColor = "#b2ddf1"; // Font color for tooltip background
nv.tooltipMargin = 50; // How much to separate the tooltip from the cursor
nv.tooltipArrowSize = 10; // How big is the arrow on the tooltip

nv.digitsForText = 2; // How many digits to use for text attributes

nv.id("attribName"); // Shows this id on the tooltip, should be unique

nv.addAllAttribsRecursionLevel = Infinity; // How many levels depth do we keep on adding nested attributes
nv.addAllAttribsIncludeObjects = false; // Should addAllAttribs include objects
nv.addAllAttribsIncludeArrays = false; // Should addAllAttribs include arrays

// Default colors for values
nv.nullColor = "#ffedfd"; // Color for null values
nv.defaultColorInterpolator = d3.interpolateBlues;
nv.defaultColorInterpolatorDate = d3.interpolatePurples;
nv.defaultColorInterpolatorDiverging = d3.interpolateBrBG;
nv.defaultColorInterpolatorOrdered = d3.interpolateOranges;
nv.defaultColorInterpolatorText = d3.interpolateGreys;
nv.defaultColorRangeBoolean = ["#a1d76a", "#e9a3c9", "white"]; //true false null
nv.defaultColorRangeSelected = ["white", "#b5cf6b"];
nv.defaultColorCategorical = d3.schemeCategory10;

// // Discouraged: If you want to break perceptual rules to have many more categories use
// // the following "Piñata mode 🎉"
// nv.defaultColorCategorical = d3.schemeCategory10
//   .concat(d3.schemeAccent)
//   .concat(d3.schemePastel1)
//   .concat(d3.schemeSet2)
//   .concat(d3.schemeSet3);
// nv.maxNumDistictForCategorical = nv.defaultColorCategorical.length;
  1. [Optional] Add your attributes manually. Navio supports six types of attributes: categorical, sequential (numerical), diverging (numerical with negative values), text, date and boolean. You can either add them manually or use nv.addAllAttribs() to auto detect them (must be called after seting the data with nv.data(your_data))
nv.addCategoricalAttrib("attribName", [customScale]);
nv.addSequentialAttrib("attribName", [customScale]);
nv.addDivergingAttrib("attribName", [customScale]);
nv.addTextAttrib("attribName", [customScale]); // Colors by the first nv.digitsForText
nv.addOrderedAttrib("attribName", [customScale]); // Sorts and then colors by rank
nv.addDateAttrib("attribName", [customScale]);
nv.addBooleanAttrib("attribName", [customScale]);

If you ommit the [customScale] parameter it will use the defaults. You can also create your own custom made parameters using nv.addAttrib("attribName", customScale). For example, if you already have a scale for setting the colors of a cluster property on your visualization, you can tell navio to use the same matching colors. Make sure to set the domain and range of the scale, as navio will not try to do it with this function.

var color = d3.scaleOrdinal(d3.schemeSet3)
  .domain["cluster1", "cluster2", "cluster3"];

nv.addAttrib("cluster", color);
  1. Set the data

After loading your data pass it to navio. This will trigger the drawing operation. You can force redrawing using nv.update();

nv.data(myData);

If your data is a network, or you have some links in the same format of a d3.forceSimulation you can also add them to navio using nv.links([links]). This won't trigger a redraw, so make sure to call it before setting your data

nv.links(myLinks);
nv.data(myData);
  1. Detect Attributes. navio also includes a function that detects the attributes automatically, which is slow, redraws the whole thing, and my be buggy. Use it at your own risk. But make sure to call it after setting your data
nv.data(myData);
nv.addAllAttribs();
  1. Set a callback. A function that navio will call when the user filters/sort the data
nv.updateCallback( data => console.log("The filtered data is ", data));

Other methods

# nv.update() <>

Use it to force a redraw of navio after changing the underlying data without losing the filters. Useful in case you modify the data with some other action in your code, e.g. you recomputed clusters in a network chart.

# nv.hardUpdate([opts]) <>

Slower update that recomputes brushes and checks for parameters. Use it if you change any parameters or added new attributes after calling .data. opts can be an object that contains any of the following attributes:

  • shouldDrawBrushes (defaults true)
  • shouldUpdateColorDomains (defaults true)
  • recomputeBrushes (defaults true)
  • levelsToUpdate (defaults all levels, should be an array of indices)

# nv.getColorScales(attr ) <>

Returns the color scale for a certain attribute, make sure to pass an attribute that has been already added

# nv.getAttribs( ) <>

Returns the ordered list of attributes added to navio

License

Navio.js is licensed under the MIT license. (http://opensource.org/licenses/MIT)

<script async defer src="https://buttons.github.io/buttons.js"></script>

navio's People

Contributors

dependabot[bot] avatar jamesscottbrown avatar jgmurillo10 avatar john-guerra avatar juancortr avatar rgonzalezp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

navio's Issues

Drop columns on read all

It would be nice to provide alist of columns (indexes or names) as an array to drop when calling nv.data(data). Currently one has to manually pull columns (attributes) which can get arduious for larger datasets.

Make sure tooltip is readable

You can't read the tooltip when hovering over the last items.

I think we should change the tooltip to be an html element, and therefore have more control on how it shows

Large datasets handing

What are the limitations of navio concerning the number of records ?

I have a file with 25 millions of records I would like to use ?
A test with a 10 millions records file shows me that navio is still usable with some slowdown however.

What could be the strategy to manage those large files ?

how to remove the popup when the navio is dismounted?

Currently if you have a popup and you dismount the navio, the popup stays on the page.

Here's a video to explain the issue—the issue can happen in observablehq if you refresh the navio cell or if the underlying data updates. Because the nv_popover is added to the body of the page it is not properly removed when the navio component is removed.

Enregistrement.de.l.ecran.2021-05-20.a.11.51.54.mov

Get filter explanations via api call?

Currently there is no function (that I can see) to pull the current filter explaination. While one can do this via the DOM: var items = document.getElementsByClassName('filterExplanation'); and iterate through children innerText/HTML, a function in the navio object would be cleaner.

[P3] Navio :: Observable

Maybe for someone new to Observable may not be clear where the data is coming from. Is there a possibility to add an input file, or input text and just paste the URL to the data..., or maybe defaults URLs.

Error setting a sequential scale

The error occurs when I try to set an sequential scale object to the function addAttr()

nv.addAttrib( 'BECAVGPTCHAREAL2', d3.scaleSequential( d3.schemeBlues ).domain( [ 0, d3.max( data, d => d[ 'BECAVGPTCHAREAL2' ] ) ] ) );
nv.data(data);

The error is: nv = TypeError: u is not a function

An observable reproducing the bug can be found here:
https://observablehq.com/@fabiancpl/navio-load

Navio tooltip failing with Bootstrap

Hi,

Apparently, Bootstrap 4 presents some interference in Navio (d3v5). The tooltip cannot be visualized. The dataset for testing is here.

<!DOCTYPE html>
  <head>
    
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">

    <title>Navio Test</title>

  </head>
  <body>
  
    <!-- Placeholder for the widget -->
    <div id="navio"></div>


    <!-- NAVIO Step 0: Load the libraries -->
    <script type="text/javascript" src="https://d3js.org/d3.v5.min.js"></script>
    <script src="https://d3js.org/d3-scale-chromatic.v1.min.js"></script>
    <script type="text/javascript" src="https://unpkg.com/navio/dist/navio.min.js"></script>

    <script>
      // NAVIO  Step 1.  Create a Navio passing a d3 selection to place it and an optional height
      var nv = navio(d3.select("#navio"), 600);

      // NAVIO Step 2. Add the Categorical and Sequential attributes you want to use
      var catColumns = [ 'animal_name', 'hair', 'feathers', 'eggs', 'milk', 'airborne', 'aquatic', 'predator', 'toothed', 'backbone', 'breathes', 'venomous', 'fins', 'tail', 'domestic', 'catsize', 'class' ];
      var seqColumns = [ 'legs' ];
      catColumns.forEach((c) => nv.addCategoricalAttrib(c));
      seqColumns.forEach((c) => nv.addSequentialAttrib(c));

      // NAVIO Step 3. Load your data!
      d3.csv( './data/animals.csv' ).then( ( data ) => {
        nv.data( data );
      } );

    </script>
  </body>
</html>

updateCallback bug?

updateCallback is only called when a filter is applied but not when user clear the last filter. How can I get this event?

App crashes with MoMA Collection

The app crashes with the MoMA collection querying:
sort Nationality > select Belgium >sort Department > select Prints and Illustrated books

Issue in angular 7

Hi, I'm trying to use navio on an Angular app with d3. I show the data in the component but when I try to sort the data (click on a header) I get this error on the console:

core.js:9110 ERROR TypeError: Cannot read property 'sourceEvent' of null at SVGGElement.<anonymous> (navio.min.js:2) at Dispatch.apply (dispatch.js:61) at customEvent (on.js:103) at Emitter.emit (brush.js:286) at Emitter.brush (brush.js:278) at SVGGElement.<anonymous> (brush.js:222) at Selection.each (each.js:5) at brush.move (brush.js:212) at Selection.call (call.js:4) at J (navio.min.js:2)

When I try to select a range, the error is:

core.js:9110 ERROR TypeError: Cannot read property 'touches' of null at SVGGElement.started (brush.js:291) at SVGGElement.<anonymous> (on.js:27) at ZoneDelegate.invokeTask (zone-evergreen.js:391) at Object.onInvokeTask (core.js:34182) at ZoneDelegate.invokeTask (zone-evergreen.js:390) at Zone.runTask (zone-evergreen.js:168) at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:465) at invokeTask (zone-evergreen.js:1603) at SVGGElement.globalZoneAwareCallback (zone-evergreen.js:1629)

Any hint about how I can solve those errors. Thanks

Get scales from Navio

It is posible to have a method for getting scale objects built in Navio for external usage?

Use transition when changing data

I have a situation where I need to perform the following steps:

  • Step 1: Load navio with data1
  • Step 2: Again load navio with data2

I would like to slow down the transition between these steps. Does Navio provide any function where you can reload the data and specify the transition duration (like in d3.js)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.