Esempio n. 1
0
    def get_graph(self):
        data = self.get_data()
        if data:
            max_value = max([value[1] for value in data if value[1] is not None])
        else:
            max_value = 0.5

        my_style = DefaultStyle()
        my_style.font_family = 'googlefont:Roboto'
        my_style.foreground = 'black'
        my_style.foreground_strong = 'white'
        my_style.title_font_size = 18
        my_style.background = "#4285f4"

        if max_value <= 1 and max_value >= 0.5:
            my_range = (0, 1)
        else:
            my_range = (0, max_value * 2)
        graph = pygal.DateTimeLine(
            x_value_formatter=lambda dt: dt.strftime('%d.%m.%Y, %H:%M:%S'),
            range=my_range,
            title="{} \n From {} to {}".format(self.field_name, self.start, self.end),
            style = my_style,
            show_legend = False,
            interpolate = 'cubic',
            dots_size=2
        )
        graph.add(self.field, data)
        return graph.render_django_response()
Esempio n. 2
0
  }
  {{ id }}.dot {
  }
  {{ id }}.color-0 {
  }
  {{ id }} text {
  }
  
"""

default_config.css.append('inline:' + custom_css)

default_style = DefaultStyle()
default_style.label_font_size = 7
default_style.plot_background='#F9F9F9'
default_style.background='#F9F9F9'
default_style.legend_font_size = 7
default_config.style = default_style


def get_rect_attributes(rect):
  attrib_dict = {s.attrib['class']: s.text for s in rect.itersiblings()}
  prevrect = rect.getprevious()
  if prevrect.attrib['class'] == 'label':
      attrib_dict['label'] = prevrect.text    
  return attrib_dict

def get_tooltip_label(attrib_dict):
  LF = "\n"
  label = "" + attrib_dict['label'] + LF + \
          "Sample: " + attrib_dict['x_label'] + LF + \
Esempio n. 3
0
  }
  {{ id }}.dot {
  }
  {{ id }}.color-0 {
  }
  {{ id }} text {
  }
  
"""

default_config.css.append('inline:' + custom_css)

default_style = DefaultStyle()
default_style.label_font_size = 7
default_style.plot_background = '#F9F9F9'
default_style.background = '#F9F9F9'
default_style.legend_font_size = 7
default_config.style = default_style


def get_rect_attributes(rect):
    attrib_dict = {s.attrib['class']: s.text for s in rect.itersiblings()}
    prevrect = rect.getprevious()
    if prevrect.attrib['class'] == 'label':
        attrib_dict['label'] = prevrect.text
    return attrib_dict


def get_tooltip_label(attrib_dict):
    LF = "\n"
    label = "" + attrib_dict['label'] + LF + \
Esempio n. 4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function

from collections import defaultdict
from collections import OrderedDict
from pygal.style import DefaultStyle
from datetime import datetime
from datetime import timedelta

import pygal
import json
import sys

yellow_style = DefaultStyle()
yellow_style.background = '#EBB82B'


def load_data(filename):
    with open(filename, 'r') as f:
        data = json.load(f)

    return data


def count_words(data):
    word_db = defaultdict(int)
    user_db = defaultdict(int)
    comments = 0
    for stage in data.values():
        for comment in stage['comments']: