db_annotate
  • Overview
  • Repository
  • Tickets
  • Statistics
  • Projects

Repository

Remove matplotlib, update color and pie sizes

Parent commits : 29c3bb6944d99c6db24db0ba3064bb42d764329b,
Children commits : 140d3962d5918e97198b96947048cbae08ed02a3,

By Laurent Defert on 2015-01-11 17:34:41
Remove matplotlib, update color and pie sizes

Browse content
Difference with parent commit 29c3bb6944d99c6db24db0ba3064bb42d764329b
Files modified:
db_size.py
--- 
+++ 
@@ -4,11 +4,6 @@
 
 from pygal import Pie, Config
 from pygal.style import SolidColorStyle
-
-
-from matplotlib import colors
-from matplotlib.cm import get_cmap, ScalarMappable
-from matplotlib.pyplot import figure, savefig
 
 from output_file import OutputFile, OUTPUT_DIR
 
@@ -66,9 +61,12 @@
         self.mean_lines_size = {}
         self.pygal_config = Config()
         self.pygal_config.human_readable = True
+        self.pygal_config.legend_box_size = 24
         self.pygal_config.show_legend = True
         self.pygal_config.show_values = True
         self.pygal_config.style = SolidColorStyle
+        self.pygal_config.style.colors = ['#ff3000', '#ff8900', '#ffe500', \
+            '#b7ff3f', '#66ff90', '#18ffdd', '#00a4ff', '#0040ff', '#0000ec', '#00007f']
         self.pygal_config.truncate_labels = 9999999
         self.pygal_config.truncate_legend = 9999999
 
@@ -86,7 +84,7 @@
         else:
             self.mean_lines_size[table] = sizes[1] / float(sizes[2])
 
-    def _render_pie(self, values, labels, _colors, title, filename):
+    def _render_pie(self, values, labels, title, filename):
         pie_chart = Pie(config=self.pygal_config)
         pie_chart.title = title
         for label, val in zip(labels, values):
@@ -94,9 +92,6 @@
         pie_chart.render_to_file(filename)
 
     def render(self):
-        _colors = ScalarMappable(norm=colors.Normalize(vmin=0, vmax=TOP_N_VALUES + 0.5), cmap=get_cmap('jet'))
-        _colors = _colors.to_rgba(range(TOP_N_VALUES))
-        _colors = list(reversed(_colors))
         imgs = []
 
         for i, graph in enumerate(self.GRAPHS.keys()):
@@ -117,7 +112,7 @@
 
                 values = [val[1] for val in total_values]
                 labels = ['%s %s' % (val[0], humanize(val[1], self.GRAPHS[graph]['counter_type'])) for val in total_values]
-                self._render_pie(values, labels, _colors, title, filename)
+                self._render_pie(values, labels, title, filename)
 
             def grouped(iterable, n):
                 "s -> (s0,s1,s2,...sn-1), (sn,sn+1,sn+2,...s2n-1), (s2n,s2n+1,s2n+2,...s3n-1), ..."
@@ -134,5 +129,5 @@
                 values = [val for val in values if val[1] != 0]
                 _values = [val[1] for val in values]
                 labels = ['%s %s' % (val[0], humanize(val[1], self.GRAPHS[graph]['counter_type'])) for val in values]
-                self._render_pie(_values, labels, _colors, title, filename)
+                self._render_pie(_values, labels, title, filename)
         return imgs

Generated with KisssPM