From 53f77c50ad867b111a86c91a073ee33122ca9376 Mon Sep 17 00:00:00 2001 From: Adelson Date: Thu, 23 Feb 2023 00:06:34 -0300 Subject: [PATCH 1/2] =?UTF-8?q?Ajustes=20nos=20dados=20dos=20gr=C3=A1ficos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sloth/app/templates/app/charts.html | 813 ++++++++++++++++++---------- sloth/core/statistics.py | 2 +- 2 files changed, 514 insertions(+), 301 deletions(-) diff --git a/sloth/app/templates/app/charts.html b/sloth/app/templates/app/charts.html index 676e526..29dd9ae 100644 --- a/sloth/app/templates/app/charts.html +++ b/sloth/app/templates/app/charts.html @@ -1,311 +1,524 @@ + + + + +
{{ data }}
+
{{ data.series }}
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + - - - + // Stacked Vertical Bars + series = []; + for (let i = 0; i < y.length; i++) { + series.push({ + name: y[i], + type: 'bar', + stack: 'total', + label: {show: true}, + emphasis: {focus: 'series'}, + data: data[i] + }); + } + option = { + title: {text: 'Stacked Vertical Bars'}, + tooltip: {trigger: 'axis', axisPointer: {type: 'shadow'}}, + legend: {}, + xAxis: {type: 'category', data: x}, + yAxis: {type: 'value'}, + series: series, + color: color + }; + echarts.init(document.getElementById('main6')).setOption(option); -
-
-
-
-
-
-
-
-
-
-
-
-
-
+ // Horizontal Bars + series = []; + for (let i = 0; i < y.length; i++) { + series.push({ + name: y[i], + type: 'bar', + label: {show: true}, + emphasis: {focus: 'series'}, + data: data[i] + }); + } + option = { + title: {text: 'Horizontal Bars'}, + tooltip: {trigger: 'axis', axisPointer: {type: 'shadow'}}, + legend: {}, + grid: {left: '3%', right: '4%', bottom: '3%', containLabel: true}, + xAxis: {type: 'value', boundaryGap: [0, 0.01]}, + yAxis: {type: 'category', data: x}, + series: series, + color: color + }; + echarts.init(document.getElementById('main7')).setOption(option); - diff --git a/sloth/core/statistics.py b/sloth/core/statistics.py index bd84d79..3f1edf4 100644 --- a/sloth/core/statistics.py +++ b/sloth/core/statistics.py @@ -254,7 +254,7 @@ def normalize(self, series): return data def chart(self, name='bar'): - self.metadata['template'] = 'app/charts.html'.format(name) + self.metadata['template'] = 'app/charts.html' self.metadata['chart'] = name return self From 9ce1af3edb1594556d68708af838e50dc4494f13 Mon Sep 17 00:00:00 2001 From: Adelson Date: Thu, 23 Feb 2023 18:10:48 -0300 Subject: [PATCH 2/2] =?UTF-8?q?Refatora=C3=A7=C3=A3o=20do=20js=20do=20echa?= =?UTF-8?q?rt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sloth/app/templates/app/charts.html | 856 +++++++++++++--------------- sloth/core/statistics.py | 33 +- 2 files changed, 409 insertions(+), 480 deletions(-) diff --git a/sloth/app/templates/app/charts.html b/sloth/app/templates/app/charts.html index 29dd9ae..8597c04 100644 --- a/sloth/app/templates/app/charts.html +++ b/sloth/app/templates/app/charts.html @@ -3,7 +3,7 @@ diff --git a/sloth/core/statistics.py b/sloth/core/statistics.py index 3f1edf4..3d100ee 100644 --- a/sloth/core/statistics.py +++ b/sloth/core/statistics.py @@ -253,22 +253,43 @@ def normalize(self, series): )) return data - def chart(self, name='bar'): + def chart(self, name='line'): self.metadata['template'] = 'app/charts.html' self.metadata['chart'] = name return self + def line_chart(self): + return self.chart('line') + + def stacked_line_chart(self): + return self.chart('stacked_line') + + def area_chart(self): + return self.chart('area') + + def stacked_area_chart(self): + return self.chart('stacked_area') + + def bar_chart(self): + return self.chart('vertical_bar') + + def stacked_bar_chart(self): + return self.chart('stacked_vertical_bar') + + def horizontal_bar_chart(self): + return self.chart('horizontal_bar') + + def stacked_horizontal_bar_chart(self): + return self.chart('stacked_horizontal_bar') + def pie_chart(self): return self.chart('pie') def donut_chart(self): return self.chart('donut') - def bar_chart(self): - return self.chart('bar') - - def column_chart(self): - return self.chart('column') + def radial_chart(self): + return self.chart('radial') def nex_color(self): color = colors()[self.cursor]