#!/usr/bin/env python # coding=utf-8 from __future__ import unicode_literals import os import sys import json import codecs import pandas as pd import numpy as np from nose.tools import eq_ from pyecharts import Bar, Map from test.constants import CLOTHES TITLE = "柱状图数据堆叠示例" def create_a_bar(title): v1 = [5, 20, 36, 10, 75, 90] v2 = [10, 25, 8, 60, 20, 80] bar = Bar(title) bar.add("商家A", CLOTHES, v1, is_stack=True) bar.add("商家B", CLOTHES, v2, is_stack=True) return bar def test_embed_option(): bar = create_a_bar(TITLE) html = bar.render_embed() json_encoded_title = json.dumps(TITLE) assert json_encoded_title in html assert "" not in html assert "
" not in html def test_notebook_render(): bar = create_a_bar(TITLE) html = bar._repr_html_() json_encoded_title = json.dumps(TITLE) assert json_encoded_title in html assert "require.config" in html assert "function(ec)" in html def test_notebook_dom(): bar = create_a_bar(TITLE) html = bar._render_notebook_dom_() assert bar._chart_id in html assert str(bar.width) in html assert str(bar.height) in html assert "