Ltree Visualizer - A golang library to visualize postgres ltree type data using DOT language and Graphviz

Overview

Ltree Visualizer

Build Status Go Report Card GoDoc License Visits Badge

A golang library to visualize postgres ltree type data using DOT language and Graphviz

alt text

What is Ltree?

Ltree is a data type which is used to represent the hierarchical tree-like structures in flat rows and columns in postgres DB For more info-refer this https://www.postgresql.org/docs/9.1/ltree.html

Sample Hierarchy: alt text

why do we need this library ?

Ltree Labels are separated using Dot . like 1.2.3.4 and it is not easy to visualize like a tree.

This Library can produce output into two different formats:

  • DOT Graph
  • Image

DOT Graph:

DOT is a graph description language, using this language we can represent Directed, Undirected and FlowCharts. https://en.wikipedia.org/wiki/DOT_(graph_description_language)

digraph graphname {
    a -> b -> c;
    b -> d;
}

alt text

How to use?

  • get LtreeVisualizer
  go get github.com/jinagamvasubabu/ltreevisualizer
  • import and use it like below for to generate the output in DOT graph string:
  import "github.com/jinagamvasubabu/ltreevisualizer"
  import "github.com/sirupsen/logrus"
 
  l := ltreevisualizer.Visualizer{}
  resp, err := l.GenerateDotGraph(context.Background(), //json data)
  fmt.Println(resp)
  • import and use it like below for to generate the output as an image:
  import "github.com/jinagamvasubabu/ltreevisualizer"
  import "github.com/sirupsen/logrus"
 
  l := ltreevisualizer.Visualizer{}
  err := l.ConvertLtreeDataToImage(context.Background(), //json data)

Note: This will create a graph.png image if you don't specify Filepath

You can refer examples directory for more info

Config:

//Visualizer config
type Visualizer struct {
	LogLevel log.Level
	RankDir  string
	FilePath string
}

RankDir: Sets the direction of tree layout(https://www.graphviz.org/docs/attrs/rankdir/) and supported values are

  • TB (Top to Bottom)
  • RL (Right to Left)
  • LR (Left to Right)
  • BT (Bottom to Top) Note: Default is TB

FilePath: FilePath to save the image, this parameter is optional for GenerateDotGraph. Note: Default value of FilePath is graph.png

Input:

Ltree Visualizer accepts data in this format

//VisualizerSchema Contract to send to ltreevisualizer
type VisualizerSchema struct {
	Data []data `json:"data"`
}

type data struct {
	ID   int32  `json:"id"`
	Name string `json:"name"`
	Path string `json:"path"`
	Type string `json:"type"`
}

Refer data.json file under examples directory for sample data

How to test?

Refer visualizer_test.go for sample tests

You might also like...
🎨 The adorable charts library for Golang
🎨 The adorable charts library for Golang

go-echarts 🎨 The adorable charts library for Golang. If a language can be used to build web scrapers, it definitely needs to provide a graceful data

go-echarts 🎨 The adorable charts library for Golang
go-echarts 🎨 The adorable charts library for Golang

go-echarts 🎨 The adorable charts library for Golang. If a language can be used to build web scrapers, it definitely needs to provide a graceful data

A charts library for Golang
A charts library for Golang

go-charts go-charts基于go-chart生成数据图表,无其它模块的依赖纯golang的实现,支持svg与png的输出,Apache ECharts在前端开发中得到众多开发者的认可,go-charts兼容Apache ECharts的配置参数,简单快捷的生成相似的图表(svg或png

Gfx - Golang file system extension library
Gfx - Golang file system extension library

gfx Golang文件操作扩展库,包含工作和生活中关于文件操作的各种有用的使用方法,包括 更友好的API 文件创建 文件删除 文件复制 一切皆可配置 文件名

3D Wireframe Drawing Library for Go
3D Wireframe Drawing Library for Go

pinhole 3D Wireframe Drawing Library for Go Javascript Version Demo Why does this exist? I needed a CPU based 3D rendering library with a very simple

HSM package provides a simple state chart library written in Go.

UML HSM HSM package provides a simple state chart library written in Go. Supported UML State Chart Features Feature Implemented Test case Simple state

fswatch, this library could help watching filesystem changes, like macOS fswatch

fswatch go library for simple UNIX file system watching fswatch provides simple UNIX file system watching in Go. It is based around the Watcher struct

Globe wireframe visualizations in Golang
Globe wireframe visualizations in Golang

globe Globe wireframe visualizations in Golang backed by pinhole. Getting Started Install globe with $ go get -u github.com/mmcloughlin/globe Start wi

🚀Statsview is a real-time Golang runtime stats visualization profiler
🚀Statsview is a real-time Golang runtime stats visualization profiler

Statsview is a real-time Golang runtime stats visualization profiler. It is built top on another open-source project, go-echarts, which helps statsview to show its graphs on the browser.

Comments
Releases(v1.0.1)
Owner
Vasubabu Jinagam
Lazy Coder :) Help people to ride, rent and share cars globally:) 🚘 🚙
Vasubabu Jinagam
Visualizer of container layer sizes

Container Layer Analyzer Have you ever wondered what exactly is eating up your precious space in each layer of your container images? Would you like t

Dan Čermák 76 Nov 14, 2022
Slice graph uses graphviz in order to pretty print slices for you.

slicegraph Slice graph uses graphviz in order to make you understand what happens underneath your slices.

Jędrzej 33 Sep 22, 2022
Tool to visualize the graph of embedded structs in Go projects

Visualize a hierarchy of embedded Go structs This tool scans a directory of Go source code files to create a visualization of struct embedding in the

David Schlachter 215 Nov 27, 2022
An SVG-based tool to visualize public transport journeys retrieved from a HAFAS system

Time-Space Train Planner An SVG-based tool to visualize public transport journeys retrieved from a HAFAS system, in order to see all possible connecti

Traines 39 Nov 5, 2022
HBase Exporter,fetch data from jmx for region-level data.

HBase Exporter Prometheus exporter for HBase which fetch data from hbase jmx, written in Go. You can even see region-level metrics. Installation and U

David 13 Nov 4, 2022
A repository for plotting and visualizing data

gonum/plot is the new, official fork of code.google.com/p/plotinum. It provides an API for building and drawing plots in Go

null 2.3k Dec 2, 2022
A repository for plotting and visualizing data

Gonum Plot gonum/plot is the new, official fork of code.google.com/p/plotinum. It provides an API for building and drawing plots in Go. Note that this

null 19.1k Jun 3, 2021
Attempt to plot light sensor data from lunarsensor.

lightsensor Attempt to plot light sensor data from lunarsensor. Buy the components, install firmware on Ambient Light Sensor. Build the go app that po

Konstantin Chukhlomin 1 Nov 10, 2022
Data visualization with chart, Create CSV file, Read Write CSV file

Data visualization with chart, Create CSV file, Read Write CSV file, Read from json file and many more in single project ......

MD FAISAL PORAG 1 Jan 13, 2022
go chart is a basic charting library in native golang.

Package chart is a very simple golang native charting library that supports timeseries and continuous line charts.

Will Charczuk 3.6k Dec 7, 2022