Giter VIP home page Giter VIP logo

jkh920184196 / streamlit-hierarchy-viewer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cristiscu/streamlit-hierarchy-viewer

0.0 0.0 0.0 895 KB

Install as a Streamlit App in Snowflake. Or run as a local Streamlit web application querying Snowflake databases. Generates different hierarchical topologies on any parent-child relationship data. Visualize with GraphViz, or inspect the generated DOT file.

License: Creative Commons Zero v1.0 Universal

Python 100.00%

streamlit-hierarchy-viewer's Introduction

Streamlit Hierarchy Data Viewer

Install as a Streamlit App in Snowflake. Or run as a local Streamlit web application querying Snowflake databases.

Generates different hierarchical topologies on any parent-child relationship data. Visualize with GraphViz, or inspect the generated DOT file.

Running a SQL Query

The Streamlit App installs also a sample Employees table with an employee-manager relationship dependency. By default, a query on this whole data is presented to the user. The query runs automatically and shows the dataset, if there is no error:

query-result

Once you run the query, switch to the Graph tab. You may now play with different column selections from the sidebar, and the graph will change, but the query will be executed again only when you change its statement. Otherwise its result is cached.

A large number of returned values will make of course your graph har to understand. So limit your returned values only to a handful number of rows.

Hierarchical Relationships

For the most simple hierarchical relationship, select one column in the Child Column, and another in the Parent Column. The child must have the unique identifier of each row (the EMPLOYEE_ID in this case), and the parent an optional identifier of a related row (the MANAGER_ID). Select a more friendlier value in the Display Column (like the EMPLOYEE_NAME), if you have one:

employee-manager-hierarchy

By default, we display a child-parent dependency graph, with one single link from each node to its eventual parent. Check the Reverse Directions checkbox, if you want to show a parent-child hierarchy instead, with child nodes under their parent:

manager-employee-hierarchy

Groups of Nodes

Select a Group Column if you want all the nodes with the same value surrounded by a box, based on the group value. For instance, here are employees displayed by DEPARTMENT:

group-by-department

You may also group the employees by their JOB titles. The sidebar can be collapsed, to make more space. And the whole graph can be resized to the browser's window size:

group-by-job

Some other interesting use cases here could be:

  • Group by PHONE_NUMBER, to see that each employee has indeed a unique number: each node must be surrounded by one single box!
  • Group by SALARY, to see employees with the same salary.
  • Group by HIRE_DATE, to see employees hired in the same day.

Bubble Charts

As an alternative, you may select a numeric value instead, in the Value Column field, to display a Bubble Chart. Each node here appears as a circle with the radius proportional to employee's SALARY, with this value passed as a tooltip:

bubble-chart-by-salary

Remark that you can combine both as well. The employee nodes can be grouped in DEPARTMENTS, and appear as circles with the size proportional to the employee SALARY:

group-and-bubble-chart

Expand All

When you want to display each node shape with the full information you received for each row, check the Expand All box. Beware you may return too much information, hard to process and to see on screen. But this is helpful when you want to see directly related node values, without going back and forth between the graph and the dataset:

expand-all

The DOT Source Code

For any generated Graph, switch to the DOT Code tab, where you may see and copy the generated Graphviz code, in DOT notation, for the current sidebar selections.

For instance, when you show the nodes grouped by DEPARTMENT, a cluster subgraph is generated for each department value, with the employee nodes defined inside:

dot-source-code

Setup Instructions

  • Clone the repository in a local folder, that you could open with VSCode or your other preferred IDE.
  • Install SnowSQL. Locate the ~/.snowsql/config file. Add a [connection.my_conn] section with the Snowflake accountname, username and password.
  • In scripts.deploy.sql, adjust the path from the PUT statements to your local files. Then call snowsql -c my_conn -f scripts/deploy.sql, to install this as a Streamlit App in your Snowflake account, with a test employees table in the same schema. Got to your Streamlit tab in Snowsight, and test the Streamlit App right away.
  • For local tests, create and switch to a local environment, using a Python version supported by Snowpark. Install the dependencies from the requirements.txt file (Streamlit and Snowpark).
  • Call streamlit run app.py, to test and run the application locally, as a Streamlit web app.

streamlit-hierarchy-viewer's People

Contributors

cristiscu avatar

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.