def punch_chart(user): cigarettes = DBSession.query(Cigarette).filter_by(user=user.user_name).all() chart_data = collections.defaultdict(lambda: [0]*24) for cigarette in cigarettes: dow = cigarette.date.strftime('%A') hour = cigarette.date.hour chart_data[dow][hour] += 1 chart = Dot(DotConfig()) days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] for dow in days: chart.add(dow, chart_data[dow]) return chart.render(is_unicode=True)
def test_dot(): dot = Dot(logarithmic=True) dot.x_labels = map(str, range(4)) dot.add('a', [1, lnk(3, 'Foo'), 5, 3]) dot.add('b', [2, -2, 0, 2, .1]) dot.add('c', [5, 1, 50, lnk(3, 'Bar')]) dot.add('d', [-5, 5, lnk(0, 'Babar'), 3]) return dot.render_response()
def test_dot(): dot = Dot() dot.x_labels = map(str, range(4)) dot.add('a', [1, lnk(3, 'Foo'), 5, 3]) dot.add('b', [2, 2, 0, 2]) dot.add('c', [5, 1, 5, lnk(3, 'Bar')]) dot.add('d', [5, 5, lnk(0, 'Babar'), 3]) return dot.render_response()
def test_dot(): dot = Dot(logarithmic=True) dot.x_labels = map(str, range(4)) dot.add("a", [1, lnk(3, "Foo"), 5, 3]) dot.add("b", [2, -2, 0, 2, 0.1]) dot.add("c", [5, 1, 50, lnk(3, "Bar")]) dot.add("d", [-5, 5, lnk(0, "Babar"), 3]) return dot.render_response()
def test_dot(): dot = Dot() dot.x_labels = map(str, range(4)) dot.add("a", [1, lnk(3, "Foo"), 5, 3]) dot.add("b", [2, 2, 0, 2]) dot.add("c", [5, 1, 5, lnk(3, "Bar")]) dot.add("d", [5, 5, lnk(0, "Babar"), 3]) return dot.render_response()