-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbar_chart.cpp
40 lines (33 loc) · 934 Bytes
/
bar_chart.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "../single_include/tui/tui.hpp"
int main() {
// Construct window
tui::Window window;
window.set_title("Bar Chart Example");
tui::BarChart bc;
bc.data = {134, 145, 80, 70, 30};
bc.labels = {"first", "second", "third", "fourth", "fifth"};
bc.title = "Bar Chart";
bc.set_dimensions(0, 0, 40, 20);
bc.bar_width = 5;
bc.bar_color = tui::RED;
bc.label_style.foreground = tui::BLUE;
bc.number_style.foreground = tui::YELLOW;
bool quit = false;
tui::Event event;
// Add bar chart widget to the window
window.add(bc);
while(!quit) {
if(window.poll_event(event)) {
if(event.type == tui::KEYDOWN) {
switch(event.key) {
case 'q':
quit = true;
break;
}
}
}
window.render();
}
window.close();
return 0;
}