def analysisCity(province):
    friends_info = get_friends_info()
    df = pd.DataFrame(friends_info)
    temp1 = df.query('province == "%s"' % province)
    city_count = temp1.groupby('city',
                               as_index=True)['city'].count().sort_values()
    attr = list(
        map(lambda x: '%s市' % x if x != '' else '未知', list(city_count.index)))
    value = list(city_count)
    # 画图
    page = Page()
    style = Style(width=1100, height=600)
    style_middle = Style(width=900, height=500)
    chart1 = Map('%s好友分布' % province, **style.init_style)
    chart1.add('',
               attr,
               value,
               maptype='%s' % province,
               is_label_show=True,
               is_visualmap=True,
               visual_text_color='#000')
    page.add(chart1)
    chart2 = Bar('%s好友分布柱状图' % province, **style_middle.init_style)
    chart2.add('',
               attr,
               value,
               is_stack=True,
               is_convert=True,
               label_pos='inside',
               is_label_show=True)
    page.add(chart2)
    page.render('analysisCity.html')
Exemple #2
0
def create_charts():
    users = get_friends()
    page = Page()
    style = Style(width=1100, height=600)
    style_middle = Style(width=900, height=500)
    data = sex_stats(users)
    attr, value = data
    chart = Pie('微信性别')  # title_pos='center'
    chart.add('', attr, value, center=[50, 50],
              radius=[30, 70], is_label_show=True, legend_orient='horizontal', legend_pos='center',
              legend_top='bottom', is_area_show=True)
    page.add(chart)
    data = prov_stats(users)
    attr, value = data
    chart = Map('中国地图', **style.init_style)
    chart.add('', attr, value, is_label_show=True, is_visualmap=True, visual_text_color='#000')
    page.add(chart)
    chart = Bar('柱状图', **style_middle.init_style)
    chart.add('', attr, value, is_stack=True, is_convert=True, label_pos='inside', is_legend_show=True,
              is_label_show=True)
    page.add(chart)
    data = gd_stats(users)
    attr, value = data
    chart = Map('河南', **style.init_style)
    chart.add('', attr, value, maptype='河南', is_label_show=True, is_visualmap=True, visual_text_color='#000')
    page.add(chart)
    chart = Bar('柱状图', **style_middle.init_style)
    chart.add('', attr, value, is_stack=True, is_convert=True, label_pos='inside', is_label_show=True)
    page.add(chart)
    page.render()
def analysisProvince():
    friends_info = get_friends_info()
    df = pd.DataFrame(friends_info)
    province_count = df.groupby(
        'province', as_index=True)['province'].count().sort_values()
    temp = list(
        map(lambda x: x if x != '' else '未知', list(province_count.index)))
    # 画图
    page = Page()
    style = Style(width=1100, height=600)
    style_middle = Style(width=900, height=500)
    attr, value = temp, list(province_count)
    chart1 = Map('好友分布(中国地图)', **style.init_style)
    chart1.add('',
               attr,
               value,
               is_label_show=True,
               is_visualmap=True,
               visual_text_color='#000')
    page.add(chart1)
    chart2 = Bar('好友分布柱状图', **style_middle.init_style)
    chart2.add('',
               attr,
               value,
               is_stack=True,
               is_convert=True,
               label_pos='inside',
               is_legend_show=True,
               is_label_show=True)
    page.add(chart2)
    page.render('analysisProvince.html')
Exemple #4
0
def test_timeline_pie():
    style = Style()
    pie_style = style.add(
        is_label_show=True,
        radius=[30, 55],
        rosetype="radius"
    )
    pie_1 = Pie("2012 年销量比例", "数据纯属虚构")
    pie_1.add("秋季", CLOTHES, [randint(10, 100) for _ in range(6)], **pie_style)

    pie_2 = Pie("2013 年销量比例", "数据纯属虚构")
    pie_2.add("秋季", CLOTHES, [randint(10, 100) for _ in range(6)], **pie_style)

    pie_3 = Pie("2014 年销量比例", "数据纯属虚构")
    pie_3.add("秋季", CLOTHES, [randint(10, 100) for _ in range(6)], **pie_style)

    pie_4 = Pie("2015 年销量比例", "数据纯属虚构")
    pie_4.add("秋季", CLOTHES, [randint(10, 100) for _ in range(6)], **pie_style)

    pie_5 = Pie("2016 年销量比例", "数据纯属虚构")
    pie_5.add("秋季", CLOTHES, [randint(10, 100) for _ in range(6)], **pie_style)

    timeline = Timeline(is_auto_play=True, timeline_bottom=0,
                        width=1200, height=600)
    timeline.add(pie_1, '2012 年')
    timeline.add(pie_2, '2013 年')
    timeline.add(pie_3, '2014 年')
    timeline.add(pie_4, '2015 年')
    timeline.add(pie_5, '2016 年')
Exemple #5
0
def create_geo_charts(data, title):
    '''地图'''
    page = Page()
    # 样式
    style = Style(title_color="#fff",
                  title_pos="center",
                  width=1200,
                  height=600,
                  background_color='#c4ccd3')
    # 创建地图模型
    chart = Geo(title, "", **style.init_style)
    # 数据 ['上海', '北京', '广州', '深圳', '苏州'] [5, 40, 10, 15, 5]
    attr, value = chart.cast(data)
    # 添加数据
    chart.add("",
              attr,
              value,
              maptype='china',
              is_visualmap=True,
              type="effectScatter",
              is_legend_show=False,
              geo_emphasis_color='c4ccd3',
              visual_text_color='#2f4554')

    page.add(chart)

    return page
def create_charts():
    page = Page()
    style = Style(width=WIDTH, height=HEIGHT)
    df = pd.read_csv('./data_cleaned.csv')
    table6 = pd.pivot_table(df,
                            values=['DISPOSE_UNIT_NAME'],
                            index=['INTIME_ARCHIVE_NUM'],
                            columns=['EVENT_TYPE_NAME'],
                            aggfunc='count',
                            fill_value=0)
    table6_2 = table6 / table6.sum()
    name = [i[1] for i in table6_2]
    value = [float(table6_2.values[0][j]) for j in range(len(name))]
    chart = Bar("超时结案", **style.init_style)
    chart.add("",
              name,
              value,
              is_datazoom_show=True,
              mark_line=["average"],
              is_stack=True,
              datazoom_type='both',
              datazoom_range=[10, 60])
    page.add(chart)

    return page
def plot_geolines(plotting_data, geo_cities_coords):
    # 设置画布的格式
    style = Style(title_pos="center", width=1000, height=800)

    # 部分地理轨迹图的格式
    style_geolines = style.add(
        is_label_show=True,
        line_curve=0.3,  # 轨迹线的弯曲度,0-1
        line_opacity=0.6,  # 轨迹线的透明度,0-1
        geo_effect_symbol='plane',  # 特效的图形,有circle,plane,pin等等
        geo_effect_symbolsize=10,  # 特效图形的大小
        geo_effect_color='#7FFFD4',  # 特效的颜色
        geo_effect_traillength=0.1,  # 特效图形的拖尾效果,0-1
        label_color=['#FFA500', '#FFF68F'],  # 轨迹线的颜色,标签点的颜色,
        border_color='#97FFFF',  # 边界的颜色
        geo_normal_color='#36648B',  # 地图的颜色
        label_formatter='{b}',  # 标签格式
        legend_pos='left')

    # 作图
    geolines = GeoLines('出行轨迹图', **style.init_style)
    geolines.add(
        '从北京出发',
        plotting_data,
        maptype='china',  # 地图的类型,可以是省的地方,如'广东',也可以是地市,如'东莞'等等
        geo_cities_coords=geo_cities_coords,
        **style_geolines)

    # 发布,得到图形的html文件
    geolines.render()
Exemple #8
0
def create_charts():
    page = Page()
    conn=mysql2pd('140.143.161.111', '3306', 'mm', 'root', 'a091211')
    data=conn.doget("select 监测点,AQI指数,`PM2.5`,PM10,Co,No2,So2,O3,updata_time from aqi")
    conn.close()
    ps=data['监测点'].drop_duplicates().values
    ts=data['updata_time'].drop_duplicates().values
    cs=['AQI指数','PM2.5','PM10','Co','No2','So2','O3']
    for p in ps:
        res = []
        data1=data[data['监测点']==p]
        for i,c in enumerate(cs):
            for x,t in enumerate(ts):
                data2=data1[data1['updata_time']==t]
                for l in list(data2[c].values):
                    res.append([i,x,l])
        style = Style(
            width=WIDTH, height=HEIGHT
        )
        chart = Bar3D(p, **style.init_style)
        chart.add(p, ts, cs, [{'name':ts[d[1]],'value':[d[1], d[0], d[2]]} for d in res],
                  is_visualmap=True, visual_range=[0, 180],
                  visual_range_color=RANGE_COLOR,
                  grid3d_width=80, grid3d_depth=80)
        page.add(chart)
    return page
Exemple #9
0
def generate_3d_bar_chart():
    data = pd.read_excel(input_file_path + '每日销量.xlsx', sheet_name=0)
    print(data.head())
    x_axis = data['week'].tolist()
    data['week'] = data['week'].str.replace('week', '').map(int) - 1
    data = data.set_index('week')
    y_axis = data.columns.tolist()
    data.columns = range(0, 7)
    data = data.stack().reset_index()
    data.columns = ['week', 'day', 'amount']
    print(data.head())
    style = Style(
        title_color='#A52A2A',
        title_pos='center',
        width=900,
        height=1100,
        background_color='#ABABAB'
    )
    style_3d = style.add(
        is_visualmap=True,
        visual_range=[0, 120],
        visual_range_color=['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf',
                            '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026'],
        grid3d_width=200,
        grid3d_depth=80,
        xaxis_label_textcolor='#fff',
        is_grid3d_rotate=True,
        legend_pos='right'
    )
    bar3d = Bar3D('全年产量情况', **style.init_style)
    bar3d.add('每日产量', x_axis, y_axis, data.values.tolist(), **style_3d)
    bar3d.render(output_file_path + 'htmls/全年产量情况3D柱状图.html')
Exemple #10
0
    def getView(self):
        db = DBUtils()
        sql = 'select city from comment'
        city = db.selectallInfo(sql)
        print(city)
        for i in city:
            citys.append(i[0])
        data = []
        for item in self.all_list(citys):
            data.append((item, self.all_list(citys)[item]))
        style = Style(title_color="#fff",
                      title_pos="center",
                      width=950,
                      height=650,
                      background_color="#404a59")

        geo = Geo("《西红市首富》粉丝人群地理位置", "刘宏伟", **style.init_style)

        attr, value = geo.cast(data)

        geo.add("",
                attr,
                value,
                visual_range=[
                    0,
                ],
                visual_text_color="#fff",
                symbol_size=20,
                is_visualmap=True,
                is_piecewise=True,
                visual_split_number=5)
        geo.render('../templates/render.html')
Exemple #11
0
def ewide2(request):
    template = loader.get_template('ewpyecharts.html')

    style = Style(
        title_top="#fff",
        title_pos="center",
        width=1200,
        height=600,
        background_color="#404a59"
    )

    data_guangzhou = [
        ["广州", "上海"],
        ["广州", "北京"],
        ["广州", "南京"],
        ["广州", "重庆"],
        ["广州", "兰州"],
        ["广州", "杭州"]
    ]
    geolines = GeoLines("水务地图可视化--点线图", **style.init_style)
    geolines.add("从广州出发", data_guangzhou, is_legend_show=False)

    context = dict(
        myechart=geolines.render_embed(),
        host=REMOTE_HOST,
        script_list=geolines.get_js_dependencies()
    )
    return HttpResponse(template.render(context, request))
def create_charts(data):
    # data字典格式(三个表的情况下):
    # {'charcloud':[str:表一的前描述,str:表一的后描述,数据1,数据2,...,数据n],'...':[...]}
    html = ''
    page = Page()
    style = Style(width=900, height=600)
    # 本页面包含:1:所有字的词云charcloud(两个数据chars,values)、
    # 表一:
    # 获取表一的数据
    html_before = data['charcloud'][0]
    html_after = data['charcloud'][1]
    chars = data['charcloud'][2]
    values = data['charcloud'][3]
    wordcloud = WordCloud("唐诗用字云图", **style.init_style)
    wordcloud.add("字云",
                  chars,
                  values,
                  word_size_range=[10, 100],
                  shape='pentagon')
    java_script = wordcloud.render_embed()
    html += html_before + java_script + html_after
    page.add(wordcloud)
    # 表二:
    html_before = data['chartop10'][0]
    html_after = data['chartop10'][1]
    chars = data['chartop10'][2]
    values = data['chartop10'][3]
    bar = Bar("唐诗高频十字", **style.init_style)
    bar.add("柱状图", chars, values)
    java_script = bar.render_embed()
    html += html_before + java_script + html_after
    page.add(bar)
    # 表三:
    html_before = data['frequency&times'][0]
    html_after = data['frequency&times'][1]
    keys = data['frequency&times'][2]
    values = data['frequency&times'][3]
    line = Line("唐诗字频-字数", **style.init_style)
    line.add("字频--字数",
             keys,
             values,
             is_smooth=True,
             is_fill=True,
             area_opacity=0.2,
             is_datazoom_show=True,
             datazoom_type="both",
             datazoom_range=[0, 60],
             xaxis_interval=1,
             yaxis_formatter="字",
             xaxis_name="频次",
             yaxis_name="字数",
             xaxis_name_pos="end",
             yaxis_name_pos="end",
             is_more_utils=True)
    java_script = line.render_embed()
    html += html_before + java_script + html_after
    page.add(line)
    # 最后
    script = page.get_js_dependencies()
    return html, script
Exemple #13
0
def render_city(cities):
    # 对城市数据和坐标文件中的地名进行处理
    handle(cities)
    data = Counter(cities).most_common()  # 使用Counter类统计出现的次数,并转换为元组列表
    print(data)

    # 定义样式
    style = Style(title_color='#fff',
                  title_pos='center',
                  width=1200,
                  height=600,
                  background_color='#404a59')

    # 根据城市数据生成地理坐标图
    geo = Geo('《悲伤逆流成河》粉丝位置分布', **style.init_style)
    attr, value = geo.cast(data)
    geo.add('',
            attr,
            value,
            visual_range=[0, 600],
            visual_text_color='#fff',
            symbol_size=15,
            is_visualmap=True,
            is_piecewise=True,
            visual_split_number=10)
    geo.render(d + '/picture/geo.html')
Exemple #14
0
    def escape(self):
        echart_unsupported_city = [
        "菏泽市", "襄阳市", "恩施州", "湘西州","阿坝州", "延边州",
        "甘孜州", "凉山州", "黔西南州", "黔东南州", "黔南州", "普洱市", "楚雄州", "红河州",
        "文山州", "西双版纳州", "大理州", "德宏州", "怒江州", "迪庆州", "昌都市", "山南市",
        "林芝市", "临夏州", "甘南州", "海北州", "黄南州", "海南州", "果洛州", "玉树州", "海西州",
        "昌吉州", "博州", "克州", "伊犁哈萨克州"]

        data = []
        
        for index, row in df_aqi.iterrows():
            city = row['city']
            aqi = row['aqi']
            if city=='长沙市':
                print(city)
                localAQI=aqi
            if city in echart_unsupported_city:
                continue
        for index, row in df_aqi.iterrows():
            city = row['city']
            aqi = row['aqi']
            if city in echart_unsupported_city:
                continue
            if aqi < localAQI and aqi<20 :
                data.append( ['长沙',city] )
                global lastcity
                lastcity=city
                                
        style = Style(
            title_top="#fff",
            title_pos = "center",
            title_color="#fff",
            width=425,
            height=730,
            background_color="#404a59"
        )
        
        style_geo = style.add(
            is_label_show=True,
            line_curve=0.2,#线条曲度
            line_opacity=0.6,
            legend_text_color="#fff",#图例文字颜色
            legend_pos="right",#图例位置
            geo_effect_symbol="plane",#特效形状
            geo_effect_symbolsize=15,#特效大小
            label_color=['#a6c84c', '#ffa022', '#46bee9'],
            label_pos="right",
            label_formatter="{b}",#//标签内容格式器
            label_text_color="#fff",
        )
        print(data)
        print(lastcity)
        geolines = GeoLines("逃离路线", **style.init_style)
        geolines.add("出发", data, **style_geo)
        geolines.render('aqi.html')
        
        self.webView.load(QUrl("file:///D:/源代码/aqi.html"))
        #self.webView.reload()
        self.webView.repaint()
        self.webView.update()
Exemple #15
0
def create_charts():
    page = Page()

    style = Style(
        width=1100, height=600
    )

    name = [
        'Sam S Club', 'Macys', 'Amy Schumer', 'Jurassic World',
        'Charter Communications', 'Chick Fil A', 'Planet Fitness',
        'Pitch Perfect', 'Express', 'Home', 'Johnny Depp', 'Lena Dunham',
        'Lewis Hamilton', 'KXAN', 'Mary Ellen Mark', 'Farrah Abraham',
        'Rita Ora', 'Serena Williams', 'NCAA baseball tournament', 'Point Break']
    value = [
        10000, 6181, 4386, 4055, 2467, 2244, 1898, 1484, 1112,
        965, 847, 582, 555, 550, 462, 366, 360, 282, 273, 265]
    chart = WordCloud("词云图-默认形状", **style.init_style)
    chart.add("", name, value, word_size_range=[30, 100], rotate_step=66)
    page.add(chart)

    chart = WordCloud("词云图-自定义形状", **style.init_style)
    chart.add("", name, value, word_size_range=[30, 100], shape='diamond')
    page.add(chart)

    return page
Exemple #16
0
def Pie():
	from pyecharts import Pie,Style

	def cut(value):
		if '中国' in value:
			return '中国'
		else:
			value = value.split(',')[0]
			return value
	file['areas'] = file['areas'].apply(cut)
	attr = file['areas'].value_counts().index.tolist()
	valu = file['areas'].value_counts().tolist()

	style = Style(
		title_pos = 'center',
		title_top = 'bottom',
		width = 900,
		height = 500,
		background_color = 'white')
	pie_style = style.add(
		legend_pos = 'center',
		#radius=[40, 75],
		label_color = [],
		label_text_color ='',
		is_label_show=True,#显示图例  数据
		)

	pie = Pie("areas:","",**style.init_style)
	pie.add("",attr,valu,**pie_style)
	pie.render('pie.html')
Exemple #17
0
def Bar():
	from pyecharts import Bar,Style

	def cut(value):
		if '中国' in value:
			return '中国'
		else:
			value = value.split(',')[0]
			return value
	file['areas'] = file['areas'].apply(cut)
	attr = file['areas'].value_counts().index.tolist()
	valu = file['areas'].value_counts().tolist()

	style = Style(
		title_pos = 'center',
		width = 900,
		height = 500,
		background_color = 'white')
	bar_style = style.add(
		legend_pos = 'bottom',
		label_color = ['yellow'],
		label_text_color ='blue',
		is_label_show=None,#显示图例  数据
		mark_point=['max'],
		mark_line=['average'])
	bar = Bar("地区分布:","",**style.init_style)#标题和副标题
	bar.add("",attr,valu,**bar_style)
	#is_convert = True 换x y轴
	bar.render('bar.html')
Exemple #18
0
def line_ssdd(attr_v1_v2: List[Tuple[str, int, int]], chart_name: str,
              v1_name: str, v2_name: str) -> line.Line:
    """
    生成一个折线图-数据堆叠图
    :param attr_v1_v2: 包含想要显示的数据列表
    :param chart_name: 图表名
    :param v1_name: 数据一名
    :param v2_name: 数据二名
    """
    style = Style(width=WIDTH, height=HEIGHT)
    attr = [a[0] for a in attr_v1_v2]
    v1 = [v[1] for v in attr_v1_v2]
    v2 = [v[2] for v in attr_v1_v2]
    # chart = Line(chart_name, **style.init_style)
    # chart.add(v1_name, attr, v1, is_label_show=True, is_smooth=True)
    # chart.add(v2_name, attr, v2, is_label_show=True, is_smooth=True)

    chart = Line(chart_name, **style.init_style)
    chart.add(v1_name, attr, v1, mark_point=["average"])
    chart.add(v2_name,
              attr,
              v2,
              is_smooth=True,
              mark_line=["max", "average"],
              is_more_utils=True)

    return chart
Exemple #19
0
def geo_qgtd(attr_v1: List[Tuple[str, int]], chart_name: str,
             v1_name: str) -> geo.Geo:
    """
    生成全国地图-数据通道图
    :param attr_v1: 主要数据
    :param chart_name: 图表名
    :param v1_name: 数据一名
    """
    style = Style(title_color="#fff",
                  title_pos="center",
                  width=900,
                  height=600,
                  background_color='#404a59')
    # chart = Map(chart_name, **style.init_style)
    # chart.add(v1_name, attr, value, maptype='china', is_visualmap=True,
    #           visual_text_color='#000')
    chart = Geo(chart_name, "", **style.init_style)
    attr, value = chart.cast(attr_v1)
    chart.add(v1_name,
              attr,
              value,
              visual_range=[0, 70000],
              visual_text_color="#fff",
              is_legend_show=False,
              symbol_size=15,
              is_visualmap=True,
              tooltip_formatter='{b}',
              label_emphasis_textsize=15,
              label_emphasis_pos='right',
              type='effectScatter')

    return chart
Exemple #20
0
def test_timeline_pie():
    style = Style()
    pie_style = style.add(is_label_show=True,
                          radius=[30, 55],
                          rosetype="radius")
    pie_1 = Pie("2012 年销量比例", "数据纯属虚构")
    pie_1.add("秋季", CLOTHES, [randint(10, 100) for _ in range(6)], **pie_style)

    pie_2 = Pie("2013 年销量比例", "数据纯属虚构")
    pie_2.add("秋季", CLOTHES, [randint(10, 100) for _ in range(6)], **pie_style)

    pie_3 = Pie("2014 年销量比例", "数据纯属虚构")
    pie_3.add("秋季", CLOTHES, [randint(10, 100) for _ in range(6)], **pie_style)

    pie_4 = Pie("2015 年销量比例", "数据纯属虚构")
    pie_4.add("秋季", CLOTHES, [randint(10, 100) for _ in range(6)], **pie_style)

    pie_5 = Pie("2016 年销量比例", "数据纯属虚构")
    pie_5.add("秋季", CLOTHES, [randint(10, 100) for _ in range(6)], **pie_style)

    timeline = Timeline(is_auto_play=True,
                        timeline_bottom=0,
                        width=1200,
                        height=600)
    timeline.add(pie_1, "2012 年")
    timeline.add(pie_2, "2013 年")
    timeline.add(pie_3, "2014 年")
    timeline.add(pie_4, "2015 年")
    timeline.add(pie_5, "2016 年")
    assert len(timeline._option.get("baseOption").get("series")) == 0
    timeline.render()
Exemple #21
0
def create_charts():
    page = Page()

    style = Style(width=WIDTH, height=HEIGHT)

    attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
    value = [20, 40, 60, 80, 100, 120]
    chart = Funnel("漏斗图示例", **style.init_style)
    chart.add("商品",
              attr,
              value,
              is_label_show=True,
              label_pos="inside",
              label_text_color="#fff")
    page.add(chart)

    chart = Funnel("漏斗图示例", title_pos='center', **style.init_style)
    chart.add("商品",
              attr,
              value,
              is_label_show=True,
              label_pos="outside",
              legend_orient='vertical',
              legend_pos='left')
    page.add(chart)

    return page
Exemple #22
0
def create_charts_pie():
    #pie
    page = Page()

    style = Style(width=1100, height=900)
    data = pd.read_csv(
        '/Users/fxm/PycharmProjects/fo/data/结果/名+标点_class_1213.csv')
    ks1, vs1 = [], []
    for k, v in countit(data['d'].values).items():
        ks1.append(k)
        vs1.append(v)
    ks2, vs2 = [], []
    for k, v in countit(data['e'].values).items():
        ks2.append(k)
        vs2.append(v)
    chart = Pie("类别分布", title_pos='center', **style.init_style)
    chart.add("",
              ks2,
              vs2,
              radius=[60, 80],
              is_label_show=True,
              is_legend_show=False)
    chart.add("",
              ks1,
              vs1,
              radius=[0, 50],
              is_label_show=True,
              is_legend_show=False,
              label_pos='inside')
    page.add(chart)

    return page
Exemple #23
0
def create_line(title, line_data, show_avg=True, attr=None):
    # 横竖坐标的大小
    style = Style(width=800, height=600)

    chart = Line(title, **style.init_style)

    if len(line_data) == 0:
        return

    if attr is None:
        attr = []
        size = len(line_data[0].dataList)
        for i in range(1, size + 1):
            cur = u"第 " + str(i) + u" 次"
            attr.append(cur)

    for data in line_data:
        if show_avg is True:
            chart.add(data.phone_type,
                      attr,
                      data.dataList,
                      is_label_show=True,
                      mark_line=["average"])
        else:
            chart.add(data.phone_type, attr, data.dataList, is_label_show=True)
    return chart
Exemple #24
0
def plot():
    for item in all_list(city):

        data.append((item, all_list(city)[item]))

        style = Style(title_color="#fff",
                      title_pos="center",
                      width=1200,
                      height=600,
                      background_color="#404a59")

    geo = Geo("《邪不压正》粉丝人群地理位置", "数据来源:量子皮皮马", **style.init_style)

    attr, value = geo.cast(data)

    geo.add("",
            attr,
            value,
            visual_range=[0, 20],
            visual_text_color="#fff",
            symbol_size=20,
            is_visualmap=True,
            is_piecewise=True,
            visual_split_number=4)
    geo.render("plot.html")
def visualize(df, name):
    # 导入自定义的地点经纬度
    geo_cities_coords = {
        df.iloc[i]['poi_name']: [df.iloc[i]['lng'], df.iloc[i]['lat']]
        for i in range(len(df))
    }  # 根据文件大小生成字典
    attr = list(df['poi_name'])  # 字典的每个键值
    value = list(df['poi_porb'])  # 由于量值的太大,换算以下(散点的颜色就是和这个想关的)
    style = Style(title_color="#fff",
                  title_pos="center",
                  width=1200,
                  height=600,
                  background_color="#404a59")

    # 可视化
    geo = Geo(name, **style.init_style)
    geo.add("",
            attr,
            value,
            visual_range=[0.2, 1],
            symbol_size=10,
            visual_text_color="#fff",
            is_piecewise=True,
            is_visualmap=True,
            maptype='北京',
            visual_split_number=10,
            geo_cities_coords=geo_cities_coords)
    return geo
Exemple #26
0
def test_style():
    style = Style(title_pos="center")
    s1 = style.add(is_random=True, label_pos="top")
    assert style.init_style['title_pos'] == "center"
    assert style.init_style.get('title', None) is None
    assert s1['is_random'] is True
    assert s1['label_pos'] == "top"
Exemple #27
0
def create_charts():
    page = Page()

    style = Style(width=900, height=600, title_pos='center')
    w = '雷音'
    res = {}

    for rt, ds, ffs in os.walk('/Users/fxm/经语料/T_out/'):
        for d in ds:
            if int(d.replace('T', '')) < 18:
                for rr, dd, ff in os.walk(rt + d):
                    for f in ff:
                        with open(rr + '/' + f, encoding='utf8') as file:
                            ss = file.read()
                            jm = re.search('title:(.*)\s', ss).group(1)
                            try:
                                res[jm] += ss.count(w)
                            except:
                                res[jm] = ss.count(w)
    res = sorted(res.items(), key=lambda x: x[1], reverse=True)[:50]
    attr = [x[0] for x in res]
    v1 = [x[1] for x in res]
    chart = Bar("雷音-經目出現頻次圖", **style.init_style)
    # chart.add("", attr, v1, xaxis_interval=0, xaxis_rotate=30,yaxis_rotate=30)
    chart.add("",
              attr,
              v1,
              is_label_show=True,
              is_datazoom_show=True,
              xaxis_rotate=30,
              xaxis_interval=0)
    page.add(chart)
    return page
def my_Geolines():
    style = Style(title_top="#fff",
                  title_pos="center",
                  width=1200,
                  height=600,
                  background_color="#404a59")

    style_geo = style.add(
        is_label_show=True,
        line_curve=0.2,
        line_opacity=0.6,
        legend_text_color="#eee",
        legend_pos="right",
        geo_effect_symbol="plane",
        geo_effect_symbolsize=15,
        label_color=['#a6c84c', '#ffa022', '#46bee9'],
        label_pos="right",
        label_formatter="{b}",
        label_text_color="#eee",
    )
    data_guangzhou = [["珠海", "番禺区", 55], ["番禺区", "天河区", 6], ["天河区", "南昌", 259]]
    geolines = GeoLines("GeoLines 示例", **style.init_style)
    geolines.add("从广州出发",
                 data_guangzhou,
                 tooltip_formatter="{a} : {c}",
                 **style_geo)
    geolines.render()
Exemple #29
0
def ewide5(request):

    template = loader.get_template('ewpyecharts.html')
    style = Style(title_top="#fff",
                  title_pos="center",
                  width=1200,
                  height=600,
                  background_color="#404a59")
    style_geo = style.add(
        is_label_show=True,
        line_curve=0.2,
        line_opacity=0.6,
        legend_text_color="#eee",
        legend_pos="right",
        geo_effect_symbol="plane",
        geo_effect_symbolsize=15,
        label_color=['#a6c84c', '#ffa022', '#46bee9'],
        label_pos="right",
        label_formatter="{b}",
        label_text_color="#eee",
    )
    data_guangzhou = [["广州", "上海"], ["广州", "北京"], ["广州", "南京"], ["广州", "重庆"],
                      ["广州", "兰州"], ["广州", "杭州"]]
    data_beijing = [["北京", "上海"], ["北京", "广州"], ["北京", "南京"], ["北京", "重庆"],
                    ["北京", "兰州"], ["北京", "杭州"]]
    geolines1 = GeoLines("GeoLines 示例", **style.init_style)
    geolines1.add("从广州出发", data_guangzhou, **style_geo)
    geolines1.add("从北京出发", data_beijing, **style_geo)

    # geo.show_config()
    context = dict(myechart=geolines1.render_embed(),
                   host=REMOTE_HOST,
                   script_list=geolines1.get_js_dependencies())
    return HttpResponse(template.render(context, request))
Exemple #30
0
def creat_lan_charts(data_list):
    page = Page()
    style = Style(title_color="#fff",
                  title_pos="center",
                  width=1200,
                  height=600,
                  background_color='#404a59')

    chart = Geo("python", "python-city", **style.init_style)
    attr, value = chart.cast(data_list)
    chart.add("",
              attr,
              value,
              visual_range=[0, 200],
              visual_text_color="#fff",
              is_legend_show=False,
              symbol_size=15,
              is_visualmap=True,
              tooltip_formatter='{b}',
              label_emphasis_textsize=15,
              label_emphasis_pos='right')
    page.add(chart)

    chart = Geo("全国主要城市空气质量", "data from pm2.5", **style.init_style)
    attr, value = chart.cast(data_list)
    chart.add("",
              attr,
              value,
              type="heatmap",
              is_visualmap=True,
              visual_range=[0, 200],
              visual_text_color='#fff',
              is_legend_show=False)
    page.add(chart)
    return page