Design (LLD)  a Bar Graph Library - Machine Coding

Design (LLD) a Bar Graph Library - Machine Coding

My project.png

Bar Graph Library - Part 1

  1. 2-D Graph with (x, y axis)
  2. Uniform Range (like value will be in multiple or will have same difference)
  3. Each Bar Can have Two Colors (both can be anything but same for all bars)
  4. Values can be Added dynamic (it can be real time also)

Features

  1. Generate 2D Graph
  2. Create Bar with specific color
  3. Render the 2d graph using the given bars values

Rough Solution (LLD-Machine Coding)

class x-axis {
    int base ;
    int range ;
    public:
        x-axis(int base, int range) {
        }
}

class y-axis {
    int base ;
    int range ;
    public:
        y-axis(int base, int range) {
        }
}

class 2d-graph {
    x-axis x ;
    y-axis y ;
    public:
        2d-graph() {
        }
}
class Element {
    string color ;
    public:
        Element(string color) {
        }
}

class Bar extends Element {
    int width ;
    int height ;
    public:
        Bar(int x, int y) {
        }

        draw() {
        }
}
class BarGraph {
    vector<Bar> bars ;
    public:
        BarGraph() {
        }
        render() {
        |
}