Esempio n. 1
0
def test_bar(gapminder):

    #Bar
    p1 = kk.bar(gapminder,
               'year',
               y='pop',
               c='continent',
               how='mean',
               stacked=True,
               annotate=True)
    opt1 = read_option_tests('bar.json')
    assert_barline_data(p1, opt1)

    #Bar with x-axis and category
    p2 = kk.bar(gapminder,'year',c='continent',stacked=True)
    opt2 = read_option_tests('bar_x_c.json')
    assert_barline_data(p2, opt2)


    # Bar Annotate All
    p3 = kk.bar(gapminder,
               'year',
               y='pop',
               c='continent',
               how='mean',
               stacked=True,
               annotate='all')
    opt3 = read_option_tests('/bar_ann_all.json')
    assert_barline_data(p3, opt3)

    p4 = kk.bar(gapminder,'continent',y='gdpPercap',how='mean')
    opt4 = {'legend': {'data': []},
                             'series': [{'data': [4426.026, 8955.554, 802.675,
                                                  3255.367, 19980.596],
                               'name': 'continent',
                               'type': 'bar'}],
                             'title': {'text': ''},
                             'tooltip': {'axisPointer': {'type': ''}},
                             'xAxis': {'data': ['Africa', 'Americas', 'Asia',
                                                'Europe', 'Oceania']},
                             'yAxis': {}}
    assert_barline_data(p4, opt4, test_legend=False) 
Esempio n. 2
0
def test_read_df(gapminder):

    africa = kk.bar(gapminder[gapminder.continent == 'Africa'], 'year')
    asia = africa.read_df(gapminder[gapminder.continent == 'Asia'])
    africa_opt = africa.option
    asia_opt = asia.option

    africa_opt.pop('series')
    asia_opt.pop('series')

    assert africa_opt == asia_opt
Esempio n. 3
0
def test_read_df(gapminder):

    africa = kk.bar(gapminder[gapminder.continent == 'Africa'], 'year')
    asia = africa.read_df(gapminder[gapminder.continent == 'Asia'])
    africa_opt = africa.option
    asia_opt = asia.option

    africa_opt.pop('series')
    asia_opt.pop('series')

    assert africa_opt == asia_opt
Esempio n. 4
0
def test_trendline(gapminder):

    # p = kk.bar(gapminder,'year',how='mean',y='pop',trendline=True)
    p1 = kk.bar(gapminder,'year',how='mean',y='pop',trendline=True)
    opt1 = read_option_tests('bar_year_pop_mean_trendline.json')

    assert_barline_data(p1, opt1, test_legend=False)
    assert p1.option['series'][-1]['data'] == opt1['series'][-1]['data']
    assert p1.option['series'][-1]['name'] == 'trendline'
    assert p1.option['series'][-1]['type'] == 'line'
    assert p1.option['series'][-1]['lineStyle'] == {'normal': {'color': '#000'}}

    p2 = kk.bar(gapminder,'year',how='mean',y='pop',trendline=True,
                c='continent',stacked=True)
    opt2 = read_option_tests('bar_year_pop_mean_continent_trendline.json')
    assert_barline_data(p2, opt2)
    assert p2.option['series'][-1]['data'] == opt2['series'][-1]['data']

    try:
        kk.bar(gapminder,'year',how='mean',y='pop',trendline=True,c='continent')
    except ValueError:
        pass
Esempio n. 5
0
def test_full_bar_line(gapminder):
    bar = kk.bar(gapminder,'year',c='continent',y='pop',how='mean',
                 stacked=True,full=True,annotate='all')
    line = kk.line(gapminder,'year',c='continent',y='pop',how='mean',
           stacked=True,full=True,annotate='all')
   
    for i in range(len(bar.option['series'])):
        bar.option['series'][i].pop('type')
        line.option['series'][i].pop('type')

        bar.option['series'][i].pop('label')
        line.option['series'][i].pop('label')

    true_option = read_option_tests('full_bar_line.json')

    assert_barline_data(bar, true_option)
    assert_barline_data(line, true_option)
Esempio n. 6
0
def bar_simple(df_simple):
    return kk.bar(df_simple, 'x')
Esempio n. 7
0
def bar_simple(df_simple):
    return kk.bar(df_simple, 'x')