def year_line(): x = handle_memcache.get_value("year_name") y = handle_memcache.get_value("year_nums") line2 = ( Line() .set_global_opts( tooltip_opts=opts.TooltipOpts(is_show=False), xaxis_opts=opts.AxisOpts(type_="category"), yaxis_opts=opts.AxisOpts( type_="value", axistick_opts=opts.AxisTickOpts(is_show=True), splitline_opts=opts.SplitLineOpts(is_show=True), ), ) .add_xaxis(xaxis_data=x) .add_yaxis( series_name="", y_axis=y, symbol="emptyCircle", is_symbol_show=True, label_opts=opts.LabelOpts(is_show=False), ) # 设置 boundary_gap 的时候一定要放在最后一个配置项里, 不然会被覆盖 .dump_options_with_quotes() ) return line2
def orginize_bar() -> Bar: o_x = handle_memcache.get_value("org_name") o_y = handle_memcache.get_value("org_nums") c = ( Bar() .add_xaxis(o_x) .add_yaxis("机构", o_y, category_gap="60%") .set_series_opts( itemstyle_opts={ "normal": { "color": JsCode( """new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'rgba(0, 122, 255, 1)' }, { offset: 1, color: 'rgba(0, 77, 167, 1)' }], false)""" ), "barBorderRadius": [30, 30, 30, 30], "shadowColor": "rgb(0, 160, 221)", } } ) .set_global_opts( title_opts=opts.TitleOpts(title="机构"), xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=45)), ) .dump_options_with_quotes() ) return c
def qikan_bar() -> Bar: x = handle_memcache.get_value("qikan_name") y = handle_memcache.get_value("qikan_nums") c = ( Bar() .add_xaxis(x) .add_yaxis("期刊", y) .reversal_axis() .set_series_opts(label_opts=opts.LabelOpts(position="right")) .set_global_opts(title_opts=opts.TitleOpts(title="期刊数量展示")) .dump_options_with_quotes() ) return c
def author_bar() -> Bar: x = handle_memcache.get_value("author_name") y = handle_memcache.get_value("author_nums") c = ( Bar() .add_xaxis(x) .add_yaxis("作者", y) .set_global_opts( title_opts=opts.TitleOpts(title="作者数量", subtitle="相关文章数量"), # 设置标题 xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=45)), # 横轴设置字体倾斜45°,可显示全部作者名称 ) .dump_options_with_quotes() # 返回Json 格式的数据,前端解析调用 ) return c
def wordshow(): words_list = handle_memcache.get_value('words')[::-1][1:50] c = ( WordCloud() .add(series_name="热点分析", data_pair=words_list, word_size_range=[6, 66],shape="star") .set_global_opts( title_opts=opts.TitleOpts( title="热点分析", title_textstyle_opts=opts.TextStyleOpts(font_size=23) ), tooltip_opts=opts.TooltipOpts(is_show=True), ) .dump_options_with_quotes() ) return c
def xueke_pie(): data1 = handle_memcache.get_value("qikan_name") data2 = handle_memcache.get_value("qikan_nums") c = ( Pie() .add( "", [ list(z) for z in zip( data1, data2, ) ], center=["40%", "50%"], ) .set_global_opts( title_opts=opts.TitleOpts(title="期刊占比"), legend_opts=opts.LegendOpts(type_="scroll", pos_left="80%", orient="vertical"), ) .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}")) .dump_options_with_quotes() ) return c