def test_config_behaviours(): line1 = Line() line1.show_legend = False line1.fill = True line1.pretty_print = True line1.x_labels = ['a', 'b', 'c'] line1.add('_', [1, 2, 3]) l1 = line1.render() line2 = Line( show_legend=False, fill=True, pretty_print=True, x_labels=['a', 'b', 'c']) line2.add('_', [1, 2, 3]) l2 = line2.render() assert l1 == l2 class LineConfig(Config): show_legend = False fill = True pretty_print = True x_labels = ['a', 'b', 'c'] line3 = Line(LineConfig) line3.add('_', [1, 2, 3]) l3 = line3.render() assert l1 == l3 line4 = Line(LineConfig()) line4.add('_', [1, 2, 3]) l4 = line4.render() assert l1 == l4
def draw_number_line(name, list_x, list_y, max_y = 0): line = Line() line.disable_xml_declaration = True line.js = [] line.x_label_rotation = 45 line.x_labels_major_count = 31 #line.y_labels_major_every = 3 line.show_legend = False line.print_values = False line.print_zeroes = False line.width = 1280 line.height = 720 line.value_formatter = lambda x:str(int(x)) #line.major_label_font_size = 20 #line.print_zeroes = True line.show_minor_x_labels = False #line.show_minor_y_labels = True line.show_dots = False #line.interpolate = 'hermite' line.title = name list_int_y = [0] for y in list_y: if y != None: list_int_y.append(y) line.range = (0, max(int(max(list_int_y)*1.1), max_y)) line.x_labels = list_x #line.y_labels = map(lambda x:x*100, range(int((min(list_y)/100)-1), int((max(list_y)/100+4)))) line.add(name, list_y) return line.render()
def draw_price_line(name, list_x, list_y): line = Line() line.disable_xml_declaration = True line.js = [] line.x_label_rotation = 45 line.y_labels_major_every = 3 line.show_legend = False line.print_values = False line.width = 1280 line.height = 720 line.value_formatter = lambda x:str(int(x)) #line.major_label_font_size = 20 #line.print_zeroes = True #line.show_minor_x_labels = True #line.show_minor_y_labels = True line.title = name digital_y = list(filter(lambda x:x != None, list_y)) if digital_y == [] : digital_y = [0] line.range = (min(digital_y)-100, max(digital_y)+300) line.x_labels = list_x line.y_labels = map(lambda x:x*100, range(int((min(digital_y)/100)-1), int((max(digital_y)/100+4)))) line.add(name, list_y) return line.render()
def test_config_behaviours(): """Test that all different way to set config produce same results""" line1 = Line() line1.show_legend = False line1.fill = True line1.pretty_print = True line1.no_prefix = True line1.x_labels = ['a', 'b', 'c'] line1.add('_', [1, 2, 3]) l1 = line1.render() q = line1.render_pyquery() assert len(q(".axis.x")) == 1 assert len(q(".axis.y")) == 1 assert len(q(".plot .series path")) == 1 assert len(q(".legend")) == 0 assert len(q(".x.axis .guides")) == 3 assert len(q(".y.axis .guides")) == 11 assert len(q(".dots")) == 3 assert q(".axis.x text").map(texts) == ['a', 'b', 'c'] line2 = Line( show_legend=False, fill=True, pretty_print=True, no_prefix=True, x_labels=['a', 'b', 'c']) line2.add('_', [1, 2, 3]) l2 = line2.render() assert l1 == l2 class LineConfig(Config): show_legend = False fill = True pretty_print = True no_prefix = True x_labels = ['a', 'b', 'c'] line3 = Line(LineConfig) line3.add('_', [1, 2, 3]) l3 = line3.render() assert l1 == l3 line4 = Line(LineConfig()) line4.add('_', [1, 2, 3]) l4 = line4.render() assert l1 == l4 line_config = Config() line_config.show_legend = False line_config.fill = True line_config.pretty_print = True line_config.no_prefix = True line_config.x_labels = ['a', 'b', 'c'] line5 = Line(line_config) line5.add('_', [1, 2, 3]) l5 = line5.render() assert l1 == l5
def test_show_legend(): line = Line() line.add('_', [1, 2, 3]) q = line.render_pyquery() assert len(q(".legend")) == 1 line.show_legend = False q = line.render_pyquery() assert len(q(".legend")) == 0
def test_config_behaviours(): line1 = Line() line1.show_legend = False line1.fill = True line1.pretty_print = True line1.no_prefix = True line1.x_labels = ["a", "b", "c"] line1.add("_", [1, 2, 3]) l1 = line1.render() q = line1.render_pyquery() assert len(q(".axis.x")) == 1 assert len(q(".axis.y")) == 1 assert len(q(".plot .series path")) == 1 assert len(q(".legend")) == 0 assert len(q(".x.axis .guides")) == 3 assert len(q(".y.axis .guides")) == 21 assert len(q(".dots")) == 3 assert q(".axis.x text").map(texts) == ["a", "b", "c"] line2 = Line(show_legend=False, fill=True, pretty_print=True, no_prefix=True, x_labels=["a", "b", "c"]) line2.add("_", [1, 2, 3]) l2 = line2.render() assert l1 == l2 class LineConfig(Config): show_legend = False fill = True pretty_print = True no_prefix = True x_labels = ["a", "b", "c"] line3 = Line(LineConfig) line3.add("_", [1, 2, 3]) l3 = line3.render() assert l1 == l3 line4 = Line(LineConfig()) line4.add("_", [1, 2, 3]) l4 = line4.render() assert l1 == l4 line_config = Config() line_config.show_legend = False line_config.fill = True line_config.pretty_print = True line_config.no_prefix = True line_config.x_labels = ["a", "b", "c"] line5 = Line(line_config) line5.add("_", [1, 2, 3]) l5 = line5.render() assert l1 == l5