Giter VIP home page Giter VIP logo

gson's Introduction

GSON

GSON is a simple python project built to Visualize JSON data as plots, pies and bars.

JSON format to use:

For Plot:

{
  "p1": {
    "x": [1, 2, 3, 4],
    "y": [2, 4, 3, 4]
  },

  "p2": {
    "x": [1, 2, 3, 4],
    "y": [1, 6, 7, 9]
  },

  "p3": {
    "x": [1, 2, 3, 4],
    "y": [2, 6, 23, 9]
  }

  "..."
}

For Pie & Bars:

{
  "p1": 4,

  "p2": 10,

  "p3": 40,

  "..."
}

Note: You can put your data in a sub directory in the JSON file.


Functions used in GSON:

Opening JSON file:

...
    with open(src) as f:
        data = json.load(f)

    if subset_key:
        if subset_key in data:
            data = {subset_key: data[subset_key]}
        else:
            raise KeyError(f"The specified subset key '{subset_key}' does not exist in the JSON data.")
...

Use data for Plot:

...
    for i, inner_dict in enumerate(data.values()):
        values_list = list(inner_dict.values())
        x_values = values_list[0]
        y_values = values_list[1]
...

Use data for Pie & Bars:

...
    keys = list(data.keys())
    values = list(data.values())
...

Call Functions

For Plot:

visualize_plot(src: str, colors: list, linestyle: str = 'solid', linewidth: int = 1, title: str = 'Graph', x_axis: str = 'x-axis', y_axis: str = 'y-axis', subset_key: str = None)

For Pie:

visualize_pie(src: str, colors: list, title: str = 'Pie', subset_key: str = None)

For Bars:

visualize_bar(src: str, colors: list, title: str = 'Bars', x_axis: str = 'x-axis', y_axis: str = 'y-axis', subset_key: str = None)

Images:

2 3 1

Feel free to contribute to the project

gson's People

Contributors

fadlgh 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.