Beispiel #1
0
def test_no_data():
    line = Line()
    q = line.render_pyquery()
    assert q(".text-overlay text").text() == "No data"
    line.no_data_text = u("þæ®þ怀&ij¿’€")
    q = line.render_pyquery()
    assert q(".text-overlay text").text() == u("þæ®þ怀&ij¿’€")
Beispiel #2
0
def test_no_data():
    line = Line()
    q = line.render_pyquery()
    assert q(".text-overlay text").text() == "No data"
    line.no_data_text = u("þæ®þ怀&ij¿’€")
    q = line.render_pyquery()
    assert q(".text-overlay text").text() == u("þæ®þ怀&ij¿’€")
Beispiel #3
0
def test_human_readable():
    line = Line()
    line.add("_", [10 ** 4, 10 ** 5, 23 * 10 ** 4])
    q = line.render_pyquery()
    assert q(".axis.y text").map(texts) == list(map(str, map(float, range(20000, 240000, 20000))))
    line.human_readable = True
    q = line.render_pyquery()
    assert q(".axis.y text").map(texts) == list(map(lambda x: "%dk" % x, range(20, 240, 20)))
Beispiel #4
0
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
Beispiel #5
0
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
Beispiel #6
0
def test_show_dots():
    line = Line()
    line.add('_', [1, 2, 3])
    q = line.render_pyquery()
    assert len(q(".dots")) == 3
    line.show_dots = False
    q = line.render_pyquery()
    assert len(q(".dots")) == 0
Beispiel #7
0
def test_show_dots():
    line = Line()
    line.add('_', [1, 2, 3])
    q = line.render_pyquery()
    assert len(q(".dots")) == 3
    line.show_dots = False
    q = line.render_pyquery()
    assert len(q(".dots")) == 0
Beispiel #8
0
def test_human_readable():
    line = Line()
    line.add('_', [10 ** 4, 10 ** 5, 23 * 10 ** 4])
    q = line.render_pyquery()
    assert q(".axis.y text").map(texts) == list(map(
        str, list(map(float, list(range(20000, 240000, 20000))))))
    line.human_readable = True
    q = line.render_pyquery()
    assert q(".axis.y text").map(texts) == ['%dk' % x for x in range(20, 240, 20)]
Beispiel #9
0
def test_human_readable():
    line = Line()
    line.add('_', [10**4, 10**5, 23 * 10**4])
    q = line.render_pyquery()
    assert q(".axis.y text").map(texts) == list(
        map(str, map(float, range(20000, 240000, 20000))))
    line.human_readable = True
    q = line.render_pyquery()
    assert q(".axis.y text").map(texts) == list(
        map(lambda x: '%dk' % x, range(20, 240, 20)))
Beispiel #10
0
def test_human_readable():
    """Test human readable option"""
    line = Line()
    line.add('_', [10 ** 4, 10 ** 5, 23 * 10 ** 4])
    q = line.render_pyquery()
    assert q(".axis.y text").map(texts) == list(map(
        str, map(float, range(20000, 240000, 20000))))
    line.human_readable = True
    q = line.render_pyquery()
    assert q(".axis.y text").map(texts) == list(map(
        lambda x: '%dk' % x, range(20, 240, 20)))
Beispiel #11
0
def test_human_readable():
    """Test human readable option"""
    line = Line()
    line.add('_', [10 ** 4, 10 ** 5, 23 * 10 ** 4])
    q = line.render_pyquery()
    assert q(".axis.y text").map(texts) == list(map(
        str, range(20000, 240000, 20000)))

    line.value_formatter = formatters.human_readable

    q = line.render_pyquery()
    assert q(".axis.y text").map(texts) == list(map(
        lambda x: '%dk' % x, range(20, 240, 20)))
Beispiel #12
0
def test_only_major_dots():
    line = Line(show_only_major_dots=True,)
    line.add('test', range(12))
    line.x_labels = map(str, range(12))
    line.x_labels_major = ['1', '5', '11']
    q = line.render_pyquery()
    assert len(q(".dots")) == 3
Beispiel #13
0
def test_only_major_dots_count():
    line = Line(show_only_major_dots=True)
    line.add('test', range(12))
    line.x_labels = map(str, range(12))
    line.x_labels_major_count = 2
    q = line.render_pyquery()
    assert len(q(".dots")) == 2
Beispiel #14
0
def test_only_major_dots():
    line = Line(show_only_major_dots=True, )
    line.add('test', range(12))
    line.x_labels = map(str, range(12))
    line.x_labels_major = ['1', '5', '11']
    q = line.render_pyquery()
    assert len(q(".dots")) == 3
Beispiel #15
0
def test_only_major_dots_every():
    """Test major dots"""
    line = Line(show_only_major_dots=True, x_labels_major_every=3)
    line.add('test', range(12))
    line.x_labels = map(str, range(12))
    q = line.render_pyquery()
    assert len(q(".dots")) == 4
Beispiel #16
0
def test_only_major_dots_count():
    line = Line(show_only_major_dots=True)
    line.add('test', range(12))
    line.x_labels = map(str, range(12))
    line.x_labels_major_count = 2
    q = line.render_pyquery()
    assert len(q(".dots")) == 2
Beispiel #17
0
def test_simple_line():
    """Simple line test"""
    line = Line()
    rng = range(-30, 31, 5)
    line.add('test1', [cos(x / 10) for x in rng])
    line.add('test2', [sin(x / 10) for x in rng])
    line.add('test3', [cos(x / 10) - sin(x / 10) for x in rng])
    line.x_labels = map(str, rng)
    line.title = "cos sin and cos - sin"
    q = line.render_pyquery()
    assert len(q(".axis.x")) == 1
    assert len(q(".axis.y")) == 1
    assert len(q(".plot .series path")) == 3
    assert len(q(".legend")) == 3
    assert len(q(".x.axis .guides")) == 13
    assert len(q(".y.axis .guides")) == 13
    assert len(q(".dots")) == 3 * 13
    assert q(".axis.x text").map(texts) == [
        '-30', '-25', '-20', '-15', '-10', '-5', '0', '5', '10', '15', '20',
        '25', '30'
    ]
    assert q(".axis.y text").map(texts) == [
        '-1.2', '-1', '-0.8', '-0.6', '-0.4', '-0.2', '0', '0.2', '0.4', '0.6',
        '0.8', '1', '1.2'
    ]
    assert q(".title").text() == 'cos sin and cos - sin'
    assert q(".legend text").map(texts) == ['test1', 'test2', 'test3']
Beispiel #18
0
def test_simple_line():
    """Simple line test"""
    line = Line()
    rng = range(-30, 31, 5)
    line.add('test1', [cos(x / 10) for x in rng])
    line.add('test2', [sin(x / 10) for x in rng])
    line.add('test3', [cos(x / 10) - sin(x / 10) for x in rng])
    line.x_labels = map(str, rng)
    line.title = "cos sin and cos - sin"
    q = line.render_pyquery()
    assert len(q(".axis.x")) == 1
    assert len(q(".axis.y")) == 1
    assert len(q(".plot .series path")) == 3
    assert len(q(".legend")) == 3
    assert len(q(".x.axis .guides")) == 13
    assert len(q(".y.axis .guides")) == 13
    assert len(q(".dots")) == 3 * 13
    assert q(".axis.x text").map(texts) == [
        '-30', '-25', '-20', '-15', '-10', '-5',
        '0', '5', '10', '15', '20', '25', '30']
    assert q(".axis.y text").map(texts) == [
        '-1.2', '-1', '-0.8', '-0.6', '-0.4', '-0.2',
        '0', '0.2', '0.4', '0.6', '0.8', '1', '1.2']
    assert q(".title").text() == 'cos sin and cos - sin'
    assert q(".legend text").map(texts) == ['test1', 'test2', 'test3']
Beispiel #19
0
def test_value_formatter():
    line = Line(value_formatter=lambda x: str(x) + u('‰'))
    line.add('_', [10 ** 4, 10 ** 5, 23 * 10 ** 4])
    q = line.render_pyquery()
    assert len(q(".y.axis .guides")) == 11
    assert q(".axis.y text").map(texts) == list(map(
        lambda x: str(x) + u('‰'), map(float, range(20000, 240000, 20000))))
Beispiel #20
0
def test_only_major_dots_every():
    """Test major dots"""
    line = Line(show_only_major_dots=True, x_labels_major_every=3)
    line.add('test', range(12))
    line.x_labels = map(str, range(12))
    q = line.render_pyquery()
    assert len(q(".dots")) == 4
Beispiel #21
0
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
Beispiel #22
0
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
Beispiel #23
0
def test_one_dot():
    line = Line()
    line.add('one dot', [12])
    line.x_labels = ['one']
    q = line.render_pyquery()
    assert len(q(".axis.x")) == 1
    assert len(q(".axis.y")) == 1
    assert len(q(".y.axis .guides")) == 1
Beispiel #24
0
def test_one_dot():
    line = Line()
    line.add('one dot', [12])
    line.x_labels = ['one']
    q = line.render_pyquery()
    assert len(q(".axis.x")) == 1
    assert len(q(".axis.y")) == 1
    assert len(q(".y.axis .guides")) == 1
Beispiel #25
0
def test_logarithmic_bad_interpolation():
    try:
        import scipy
    except ImportError:
        return
    line = Line(logarithmic=True, interpolate='cubic')
    line.add('_', [.001, .00000001, 1])
    q = line.render_pyquery()
    assert len(q(".y.axis .guides")) == 40
Beispiel #26
0
def test_not_equal_x_labels():
    line = Line()
    line.add('test1', range(100))
    line.x_labels = map(str, range(11))
    q = line.render_pyquery()
    assert len(q(".dots")) == 100
    assert len(q(".axis.x")) == 1
    assert q(".axis.x text").map(texts) == ['0', '1', '2', '3', '4', '5', '6',
                                            '7', '8', '9', '10']
Beispiel #27
0
def test_not_equal_x_labels():
    line = Line()
    line.add('test1', range(100))
    line.x_labels = map(str, range(11))
    q = line.render_pyquery()
    assert len(q(".dots")) == 100
    assert len(q(".axis.x")) == 1
    assert q(".axis.x text").map(texts) == ['0', '1', '2', '3', '4', '5', '6',
                                            '7', '8', '9', '10']
Beispiel #28
0
def test_logarithmic_bad_interpolation():
    try:
        import scipy
    except ImportError:
        return
    line = Line(logarithmic=True, interpolate='cubic')
    line.add('_', [.001, .00000001, 1])
    q = line.render_pyquery()
    assert len(q(".y.axis .guides")) == 40
Beispiel #29
0
def test_serie_precedence_over_global_config():
    """Test that per serie configuration overide global configuration"""
    chart = Line(stroke=False)
    chart.add('1', s1, stroke=True)
    chart.add('2', s2)
    q = chart.render_pyquery()
    assert len(q('.serie-0 .line')) == 1
    assert len(q('.serie-1 .line')) == 0
    assert len(q('.serie-0 .dot')) == 5
    assert len(q('.serie-1 .dot')) == 6
Beispiel #30
0
def test_global_config():
    """Test global configuration"""
    chart = Line(stroke=False)
    chart.add('1', s1)
    chart.add('2', s2)
    q = chart.render_pyquery()
    assert len(q('.serie-0 .line')) == 0
    assert len(q('.serie-1 .line')) == 0
    assert len(q('.serie-0 .dot')) == 5
    assert len(q('.serie-1 .dot')) == 6
Beispiel #31
0
def test_serie_config():
    """Test per serie configuration"""
    chart = Line()
    chart.add('1', s1, stroke=False)
    chart.add('2', s2)
    q = chart.render_pyquery()
    assert len(q('.serie-0 .line')) == 0
    assert len(q('.serie-1 .line')) == 1
    assert len(q('.serie-0 .dot')) == 5
    assert len(q('.serie-1 .dot')) == 6
Beispiel #32
0
def test_serie_precedence_over_global_config():
    """Test that per serie configuration overide global configuration"""
    chart = Line(stroke=False)
    chart.add('1', s1, stroke=True)
    chart.add('2', s2)
    q = chart.render_pyquery()
    assert len(q('.serie-0 .line')) == 1
    assert len(q('.serie-1 .line')) == 0
    assert len(q('.serie-0 .dot')) == 5
    assert len(q('.serie-1 .dot')) == 6
Beispiel #33
0
def test_serie_config():
    """Test per serie configuration"""
    chart = Line()
    chart.add('1', s1, stroke=False)
    chart.add('2', s2)
    q = chart.render_pyquery()
    assert len(q('.serie-0 .line')) == 0
    assert len(q('.serie-1 .line')) == 1
    assert len(q('.serie-0 .dot')) == 5
    assert len(q('.serie-1 .dot')) == 6
Beispiel #34
0
def test_global_config():
    """Test global configuration"""
    chart = Line(stroke=False)
    chart.add('1', s1)
    chart.add('2', s2)
    q = chart.render_pyquery()
    assert len(q('.serie-0 .line')) == 0
    assert len(q('.serie-1 .line')) == 0
    assert len(q('.serie-0 .dot')) == 5
    assert len(q('.serie-1 .dot')) == 6
Beispiel #35
0
def test_human_readable():
    line = Line()
    line.add('_', [10 ** 4, 10 ** 5, 23 * 10 ** 4])
    # q = line.render_pyquery()
    # assert q(".axis.y text").map(texts) == map(
        # str, range(20000, 240000, 20000))
    line.human_readable = True
    q = line.render_pyquery()
    assert q(".axis.y text").map(texts) == map(
        lambda x: '%dk' % x, range(20, 240, 20))
Beispiel #36
0
def test_logarithmic():
    line = Line(logarithmic=True)
    line.add('_', [1, 10 ** 10, 1])
    q = line.render_pyquery()
    assert len(q(".axis.x")) == 0
    assert len(q(".axis.y")) == 1
    assert len(q(".plot .series path")) == 1
    assert len(q(".legend")) == 1
    assert len(q(".x.axis .guides")) == 0
    assert len(q(".y.axis .guides")) == 51
    assert len(q(".dots")) == 3
Beispiel #37
0
def test_int_x_labels():
    """Test x_labels"""
    line = Line()
    line.add('test1', range(100))
    line.truncate_label = -1
    line.x_labels = list(range(11))
    q = line.render_pyquery()
    assert len(q(".dots")) == 100
    assert len(q(".axis.x")) == 1
    assert q(".axis.x text").map(texts) == [
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
Beispiel #38
0
def test_line():
    line = Line()
    rng = [8, 12, 23, 73, 39, 57]
    line.add('Single serie', rng)
    line.title = "One serie"
    q = line.render_pyquery()
    assert len(q(".axis.x")) == 0
    assert len(q(".axis.y")) == 1
    assert len(q(".plot .series path")) == 1
    assert len(q(".x.axis .guides")) == 0
    assert len(q(".y.axis .guides")) == 7
Beispiel #39
0
def test_line():
    line = Line()
    rng = [8, 12, 23, 73, 39, 57]
    line.add('Single serie', rng)
    line.title = "One serie"
    q = line.render_pyquery()
    assert len(q(".axis.x")) == 0
    assert len(q(".axis.y")) == 1
    assert len(q(".plot .series path")) == 1
    assert len(q(".x.axis .guides")) == 0
    assert len(q(".y.axis .guides")) == 7
Beispiel #40
0
def test_int_x_labels():
    """Test x_labels"""
    line = Line()
    line.add('test1', range(100))
    line.truncate_label = -1
    line.x_labels = list(range(11))
    q = line.render_pyquery()
    assert len(q(".dots")) == 100
    assert len(q(".axis.x")) == 1
    assert q(".axis.x text").map(texts) == [
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
Beispiel #41
0
def test_logarithmic():
    line = Line(logarithmic=True)
    line.add('_', [1, 10**10, 1])
    q = line.render_pyquery()
    assert len(q(".axis.x")) == 0
    assert len(q(".axis.y")) == 1
    assert len(q(".plot .series path")) == 1
    assert len(q(".legend")) == 1
    assert len(q(".x.axis .guides")) == 0
    assert len(q(".y.axis .guides")) == 51
    assert len(q(".dots")) == 3
Beispiel #42
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
Beispiel #43
0
def test_line_secondary():
    line = Line()
    rng = [8, 12, 23, 73, 39, 57]
    line.add('First serie', rng)
    line.add('Secondary serie', map(lambda x: x * 2, rng), secondary=True)
    line.title = "One serie"
    q = line.render_pyquery()
    assert len(q(".axis.x")) == 0
    assert len(q(".axis.y")) == 1
    assert len(q(".plot .series path")) == 2
    assert len(q(".x.axis .guides")) == 0
    assert len(q(".y.axis .guides")) == 7
Beispiel #44
0
def test_serie_config():
    s1 = [1, 3, 12, 3, 4]
    s2 = [7, -4, 10, None, 8, 3, 1]

    chart = Line()
    chart.add('1', s1)
    chart.add('2', s2)
    q = chart.render_pyquery()
    assert len(q('.serie-0 .line')) == 1
    assert len(q('.serie-1 .line')) == 1
    assert len(q('.serie-0 .dot')) == 5
    assert len(q('.serie-1 .dot')) == 6

    chart = Line(stroke=False)
    chart.add('1', s1)
    chart.add('2', s2)
    q = chart.render_pyquery()
    assert len(q('.serie-0 .line')) == 0
    assert len(q('.serie-1 .line')) == 0
    assert len(q('.serie-0 .dot')) == 5
    assert len(q('.serie-1 .dot')) == 6

    chart = Line()
    chart.add('1', s1, stroke=False)
    chart.add('2', s2)
    q = chart.render_pyquery()
    assert len(q('.serie-0 .line')) == 0
    assert len(q('.serie-1 .line')) == 1
    assert len(q('.serie-0 .dot')) == 5
    assert len(q('.serie-1 .dot')) == 6

    chart = Line(stroke=False)
    chart.add('1', s1, stroke=True)
    chart.add('2', s2)
    q = chart.render_pyquery()
    assert len(q('.serie-0 .line')) == 1
    assert len(q('.serie-1 .line')) == 0
    assert len(q('.serie-0 .dot')) == 5
    assert len(q('.serie-1 .dot')) == 6
Beispiel #45
0
def test_line_secondary():
    """Test line with a secondary serie"""
    line = Line()
    rng = [8, 12, 23, 73, 39, 57]
    line.add('First serie', rng)
    line.add('Secondary serie', map(lambda x: x * 2, rng), secondary=True)
    line.title = "One serie"
    q = line.render_pyquery()
    assert len(q(".axis.x")) == 0
    assert len(q(".axis.y")) == 1
    assert len(q(".plot .series path")) == 2
    assert len(q(".x.axis .guides")) == 0
    assert len(q(".y.axis .guides")) == 7
Beispiel #46
0
def test_serie_config():
    s1 = [1, 3, 12, 3, 4]
    s2 = [7, -4, 10, None, 8, 3, 1]

    chart = Line()
    chart.add('1', s1)
    chart.add('2', s2)
    q = chart.render_pyquery()
    assert len(q('.serie-0 .line')) == 1
    assert len(q('.serie-1 .line')) == 1
    assert len(q('.serie-0 .dot')) == 5
    assert len(q('.serie-1 .dot')) == 6

    chart = Line(stroke=False)
    chart.add('1', s1)
    chart.add('2', s2)
    q = chart.render_pyquery()
    assert len(q('.serie-0 .line')) == 0
    assert len(q('.serie-1 .line')) == 0
    assert len(q('.serie-0 .dot')) == 5
    assert len(q('.serie-1 .dot')) == 6

    chart = Line()
    chart.add('1', s1, stroke=False)
    chart.add('2', s2)
    q = chart.render_pyquery()
    assert len(q('.serie-0 .line')) == 0
    assert len(q('.serie-1 .line')) == 1
    assert len(q('.serie-0 .dot')) == 5
    assert len(q('.serie-1 .dot')) == 6

    chart = Line(stroke=False)
    chart.add('1', s1, stroke=True)
    chart.add('2', s2)
    q = chart.render_pyquery()
    assert len(q('.serie-0 .line')) == 1
    assert len(q('.serie-1 .line')) == 0
    assert len(q('.serie-0 .dot')) == 5
    assert len(q('.serie-1 .dot')) == 6
Beispiel #47
0
def test_logarithmic_small_scale():
    line = Line(logarithmic=True)
    line.add('_', [1 + 10**10, 3 + 10**10, 2 + 10**10])
    q = line.render_pyquery()
    assert len(q(".y.axis .guides")) == 21
Beispiel #48
0
def test_logarithmic_big_scale():
    line = Line(logarithmic=True)
    line.add('_', [10**-10, 10**10, 1])
    q = line.render_pyquery()
    assert len(q(".y.axis .guides")) == 41
Beispiel #49
0
def test_logarithmic_bad_interpolation():
    line = Line(logarithmic=True, interpolate='cubic')
    line.add('_', [.001, .00000001, 1])
    q = line.render_pyquery()
    assert len(q(".y.axis .guides")) == 41
Beispiel #50
0
def test_logarithmic_small_scale():
    """Test logarithmic with a small range of values"""
    line = Line(logarithmic=True)
    line.add('_', [1 + 10 ** 10, 3 + 10 ** 10, 2 + 10 ** 10])
    q = line.render_pyquery()
    assert len(q(".y.axis .guides")) == 11
Beispiel #51
0
def test_logarithmic_big_scale():
    """Test logarithmic option with a large range of value"""
    line = Line(logarithmic=True)
    line.add('_', [10 ** -10, 10 ** 10, 1])
    q = line.render_pyquery()
    assert len(q(".y.axis .guides")) == 21
Beispiel #52
0
def test_logarithmic_bad_interpolation():
    """Test interpolation option with a logarithmic chart"""
    line = Line(logarithmic=True, interpolate='cubic')
    line.add('_', [.001, .00000001, 1])
    q = line.render_pyquery()
    assert len(q(".y.axis .guides")) == 41
Beispiel #53
0
def test_no_dot():
    """Line test with an empty serie"""
    line = Line()
    line.add('no dot', [])
    q = line.render_pyquery()
    assert q(".text-overlay text").text() == 'No data'
Beispiel #54
0
# This file is test file for NoneMaxSolved
# I have modified the line.py and passed other test
# This test is for us to test whether the none value
# in the Log graph will be max or not (issue #309)

from __future__ import division

from pygal import Line

chart = Line(title='test', logarithmic=True)
chart.add('test 1', [None, -38, 48, 4422, 35586, 1003452, 225533])
chart.add('test 2', [1, 40, 20, 38, 2937, 20399, 3947])
q = chart.render_pyquery()
assert len(q(".dots")) == 12
Beispiel #55
0
def test_only_major_dots_no_labels():
    """Test major dots with no labels"""
    line = Line(show_only_major_dots=True)
    line.add('test', range(12))
    q = line.render_pyquery()
    assert len(q(".dots")) == 12
Beispiel #56
0
def test_only_major_dots_no_labels():
    """Test major dots with no labels"""
    line = Line(show_only_major_dots=True)
    line.add('test', range(12))
    q = line.render_pyquery()
    assert len(q(".dots")) == 12
Beispiel #57
0
def test_logarithmic_big_scale():
    """Test logarithmic option with a large range of value"""
    line = Line(logarithmic=True)
    line.add('_', [10**-10, 10**10, 1])
    q = line.render_pyquery()
    assert len(q(".y.axis .guides")) == 21
Beispiel #58
0
def test_no_dot():
    """Line test with an empty serie"""
    line = Line()
    line.add('no dot', [])
    q = line.render_pyquery()
    assert q(".text-overlay text").text() == 'No data'
Beispiel #59
0
def test_logarithmic_small_scale():
    """Test logarithmic with a small range of values"""
    line = Line(logarithmic=True)
    line.add('_', [1 + 10**10, 3 + 10**10, 2 + 10**10])
    q = line.render_pyquery()
    assert len(q(".y.axis .guides")) == 11