def test_config(): class LolConfig(Config): js = ["http://l:2343/svg.jquery.js", "http://l:2343/pygal-tooltips.js"] stacked = StackedBar(LolConfig()) stacked.add("1", [1, 2, 3]) stacked.add("2", [4, 5, 6]) return stacked.render_response()
def test_config(): class LolConfig(Config): js = ['http://l:2343/2.0.x/pygal-tooltips.js'] stacked = StackedBar(LolConfig()) stacked.add('1', [1, 2, 3]) stacked.add('2', [4, 5, 6]) return stacked.render_response()
def test_config(): class LolConfig(Config): js = ['http://l:2343/svg.jquery.js', 'http://l:2343/pygal-tooltips.js'] stacked = StackedBar(LolConfig()) stacked.add('1', [1, 2, 3]) stacked.add('2', [4, 5, 6]) return stacked.render_response()
def __init__(self): StackedBar.__init__(self, style=CUSTOM_STYLE, order_min=1, show_legend=False) self.x_title = str(date.today().year) self.title = "Monthly history" moods = OrderedDict() for label in MoodItem.objects.order_by("order"): moods[label.name] = [None] * 12 self.x_labels = map(str, range(1, 13)) for item in Mood._get_collection().aggregate([{ "$match": { "user": bson.objectid.ObjectId(str(current_user.id)) } }, { "$lookup": { "from": "mood_item", "localField": "mood", "foreignField": "_id", "as": "mood" } }, { "$group": { "_id": { "mood": "$mood.name", "color": "$mood.color", "month": { "$month": "$date" }, "year": { "$year": "$date" } }, "count": { "$sum": 1 } } }]): moods[item["_id"]["mood"][0]][item["_id"]["month"] - 1] = { "value": item["count"], "color": item["_id"]["color"][0] } self.range = (0, 31) for m in moods.keys(): self.add(m, moods[m])
def __init__(self): StackedBar.__init__(self, style=CUSTOM_STYLE, order_min=1, show_legend=False) self.x_title = str(date.today().year) self.title = "Monthly history" moods = OrderedDict() for label in MoodItem.objects.order_by("order"): moods[label.name] = [None] * 12 self.x_labels = map(str, range(1, 13)) for item in Mood._get_collection().aggregate([{"$match": {"user": bson.objectid.ObjectId(str(current_user.id))}}, {"$lookup": { "from": "mood_item", "localField": "mood", "foreignField": "_id", "as": "mood"}}, {"$group": {"_id": {"mood": "$mood.name", "color": "$mood.color", "month": {"$month": "$date"}, "year": {"$year": "$date"}}, "count": {"$sum": 1}}}]): moods[item["_id"]["mood"][0]][item["_id"]["month"] - 1] = {"value": item["count"], "color": item["_id"]["color"][0]} self.range = (0, 31) for m in moods.keys(): self.add(m, moods[m])
def test_config(): class LolConfig(Config): js = ['http://l:2343/2.0.x/pygal-tooltips.js'] stacked = StackedBar(LolConfig()) stacked.add('', [1, 2, 3]) stacked.add('My beautiful serie of 2019', [4, 5, 6]) return stacked.render_response()
def test_bar_print_values_position(): bar = StackedBar(print_values=True, print_values_position='top', zero=2, style=styles['default']( value_font_family='googlefont:Raleway', value_font_size=46)) bar.add('1', [1, -2, 3]) bar.add('2', [4, -5, 6]) bar.x_labels = [2, 4, 6] bar.x_labels_major = [4] return bar.render_response()
def test_config(): class LolConfig(Config): js = ["http://l:2343/2.0.x/pygal-tooltips.js"] stacked = StackedBar(LolConfig()) stacked.add("", [1, 2, 3]) stacked.add("My beautiful serie of 2019", [4, 5, 6]) return stacked.render_response()
def test_bar_print_values_position(): bar = StackedBar( print_values=True, print_values_position="top", zero=2, style=styles["default"](value_font_family="googlefont:Raleway", value_font_size=46), ) bar.add("1", [1, -2, 3]) bar.add("2", [4, -5, 6]) bar.x_labels = [2, 4, 6] bar.x_labels_major = [4] return bar.render_response()
def test_stacked_reverse(): stacked = StackedBar(stack_from_top=True) stacked.add('1', [1, 2, 3]) stacked.add('2', [4, 5, 6]) return stacked.render_response()
def test_stacked(): stacked = StackedBar() stacked.add('1', [1, 2, 3]) stacked.add('2', [4, 5, 6]) return stacked.render_response()