Play this article
Bar Graph Library - Part 1
- 2-D Graph with (x, y axis)
- Uniform Range (like value will be in multiple or will have same difference)
- Each Bar Can have Two Colors (both can be anything but same for all bars)
- Values can be Added dynamic (it can be real time also)
Features
- Generate 2D Graph
- Create Bar with specific color
- 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() {
|
}