def grid_mutil_yaxis() -> Grid:
    x_data = ["{}月".format(i) for i in range(1, 13)]
    bar = (Bar().add_xaxis(x_data).add_yaxis(
        "蒸发量",
        [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3],
        yaxis_index=0,
        color="#d14a61",
    ).add_yaxis(
        "降水量",
        [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],
        yaxis_index=1,
        color="#5793f3",
    ).extend_axis(yaxis=opts.AxisOpts(
        name="蒸发量",
        type_="value",
        min_=0,
        max_=250,
        position="right",
        axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(
            color="#d14a61")),
        axislabel_opts=opts.LabelOpts(formatter="{value} ml"),
    )).extend_axis(yaxis=opts.AxisOpts(
        type_="value",
        name="温度",
        min_=0,
        max_=25,
        position="left",
        axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(
            color="#675bba")),
        axislabel_opts=opts.LabelOpts(formatter="{value} °C"),
        splitline_opts=opts.SplitLineOpts(
            is_show=True, linestyle_opts=opts.LineStyleOpts(opacity=1)),
    )).set_global_opts(
        yaxis_opts=opts.AxisOpts(
            name="降水量",
            min_=0,
            max_=250,
            position="right",
            offset=80,
            axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(
                color="#5793f3")),
            axislabel_opts=opts.LabelOpts(formatter="{value} ml"),
        ),
        title_opts=opts.TitleOpts(title="Grid-多 Y 轴示例"),
        tooltip_opts=opts.TooltipOpts(trigger="axis",
                                      axis_pointer_type="cross"),
    ))

    line = (Line().add_xaxis(x_data).add_yaxis(
        "平均温度",
        [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2],
        yaxis_index=2,
        color="#675bba",
        label_opts=opts.LabelOpts(is_show=False),
    ))

    bar.overlap(line)
    return Grid().add(bar,
                      opts.GridOpts(pos_left="5%", pos_right="20%"),
                      is_control_axis_index=True)
Ejemplo n.º 2
0
def draw_tendency(month, day):
    dates = ['1-%d' % i for i in range(16, day + 1)]
    v0 = [4, 17, 59, 78, 92, 149, 131, 259, 444, 688, 769, 1771, 1459, 1576]
    v1 = [4, 17, 59, 77, 72, 105, 69, 105, 180, 323, 371, 1291, 840, 1032]
    c = (Line().add_xaxis(dates).add_yaxis(
        "全国新增确诊病例",
        v0,
        is_smooth=True,
        linestyle_opts=opts.LineStyleOpts(width=4, color='#B44038'),
        itemstyle_opts=opts.ItemStyleOpts(
            color='#B44038', border_color="#B44038",
            border_width=5)).add_yaxis(
                "湖北新增确诊病例",
                v1,
                is_smooth=True,
                linestyle_opts=opts.LineStyleOpts(width=2, color='6FA0A7'),
                label_opts=opts.LabelOpts(position='bottom'),
                itemstyle_opts=opts.ItemStyleOpts(
                    color='#6FA0A7', border_color="#6FA0A7",
                    border_width=3)).set_global_opts(
                        title_opts=opts.TitleOpts(title=""),
                        yaxis_opts=opts.AxisOpts(
                            type_="log",
                            name="y",
                            splitline_opts=opts.SplitLineOpts(is_show=True),
                            is_scale=True,
                            axisline_opts=opts.AxisLineOpts(is_show=False))))
    c.render('charts/%d%d-新增病例趋势图.html' % (month, day))
    return c
Ejemplo n.º 3
0
def draw_line2(title, x_axis, y_name1, y_data1, y_name2, y_data2):
    c = (Line().add_xaxis(xaxis_data=x_axis).add_yaxis(
        series_name=y_name1,
        y_axis=y_data1,
        symbol="circle",
        symbol_size=10,
        is_symbol_show=True,
        label_opts=opts.LabelOpts(is_show=True),
        linestyle_opts=opts.LineStyleOpts(width=3)).add_yaxis(
            series_name=y_name2,
            y_axis=y_data2,
            symbol="circle",
            symbol_size=10,
            is_symbol_show=True,
            label_opts=opts.LabelOpts(is_show=True),
            linestyle_opts=opts.LineStyleOpts(width=3)).set_global_opts(
                tooltip_opts=opts.TooltipOpts(is_show=False),
                xaxis_opts=opts.AxisOpts(
                    type_="category",
                    axislabel_opts=opts.LabelOpts(rotate=-30),
                ),
                yaxis_opts=opts.AxisOpts(
                    type_="value",
                    axistick_opts=opts.AxisTickOpts(is_show=True),
                    splitline_opts=opts.SplitLineOpts(is_show=True),
                ),
                title_opts=opts.TitleOpts(title=title),
            ))
    return c
Ejemplo n.º 4
0
def line_smooth(index, data, name) -> Line:
    c = (
        Line(init_opts=opts.InitOpts(
            theme=ThemeType.ROMANTIC,
            # width="100%",
            height="500px",
        )).add_xaxis(index).add_yaxis(
            "Sentiment value",
            data,
            is_smooth=True,
            is_connect_nones=True,
            yaxis_index=0).extend_axis(yaxis=opts.AxisOpts(
                name="Stock K-line",
                is_scale=True,
                position="right",
                axisline_opts=opts.AxisLineOpts(
                    linestyle_opts=opts.LineStyleOpts(color="#675bba")),
                splitline_opts=opts.SplitLineOpts(
                    is_show=True, linestyle_opts=opts.LineStyleOpts(
                        opacity=1)),
            )).set_global_opts(
                xaxis_opts=opts.AxisOpts(is_scale=True),
                yaxis_opts=opts.AxisOpts(
                    name="Sentiment Value",
                    is_scale=True,
                    splitarea_opts=opts.SplitAreaOpts(
                        is_show=True,
                        areastyle_opts=opts.AreaStyleOpts(opacity=1))),
                datazoom_opts=[opts.DataZoomOpts(pos_bottom="-2%")],
                title_opts=opts.TitleOpts(title="Sentiment Analysis : " +
                                          name),
                tooltip_opts=opts.TooltipOpts(trigger="axis",
                                              axis_pointer_type="line"),
            ))
    return c
Ejemplo n.º 5
0
def uv_line_chart() -> Line:
    """
    UV折线图,包括总 UV、新用户 UV、注册 UV
    """
    xaxis = get_xaxis_days()

    uv_all_redis_keys = [settings.REDIS_UV_ALL_KEY % day for day in xaxis]
    uv_new_redis_keys = [settings.REDIS_UV_NEW_KEY % day for day in xaxis]
    uv_reg_redis_keys = [settings.REDIS_REG_KEY % day for day in xaxis]

    uv_all = R.mget(*uv_all_redis_keys)
    uv_new = R.mget(*uv_new_redis_keys)
    uv_reg = R.mget(*uv_reg_redis_keys)

    line = (Line().add_xaxis(xaxis).add_yaxis(
        "总用户数(访问设备)", uv_all, is_connect_nones=True, is_smooth=True).add_yaxis(
            "新用户数(一周未访问)", uv_new, is_connect_nones=True,
            is_smooth=True).add_yaxis(
                "注册用户数", uv_reg, is_connect_nones=True,
                is_smooth=True).set_global_opts(
                    title_opts=options.TitleOpts(title="用户数走势"),
                    yaxis_opts=options.AxisOpts(
                        is_scale=True,
                        splitline_opts=options.SplitLineOpts(is_show=True)),
                    tooltip_opts=options.TooltipOpts(trigger='axis'),
                ).dump_options())
    return line
Ejemplo n.º 6
0
def api_profile_line_chart() -> Line:
    """
    接口平均耗时
    :return:
    """
    xaxis = get_xaxis_days(days=10)

    apis = list(filter(lambda x: x, R.smembers(settings.REDIS_API_KEY)))

    line = (Line().add_xaxis(xaxis).set_global_opts(
        title_opts=options.TitleOpts(title="API 耗时走势"),
        yaxis_opts=options.AxisOpts(
            is_scale=True, splitline_opts=options.SplitLineOpts(is_show=True)),
        tooltip_opts=options.TooltipOpts(trigger='axis'),
    ))
    for api in apis:
        if api in get_profile_apis():
            api_redis_keys = [
                settings.REDIS_API_AVG_KEY % (api, day) for day in xaxis
            ]
            api_profile = R.mget(*api_redis_keys)
            line.add_yaxis(api,
                           api_profile,
                           is_connect_nones=True,
                           is_smooth=True,
                           label_opts=options.LabelOpts(is_show=False))

    return line.dump_options()
Ejemplo n.º 7
0
def bar(df, datatype='ABS', show_label=False, label_rotate=90) -> Bar:
    axislabel_format = '{value}'
    if datatype in ['SHARE', 'GR']:
        df = df.multiply(100).round(2)
        axislabel_format = '{value}%'
    if df.empty is False:
        bar = (
            Bar()
                .add_xaxis(df.index.tolist())
        )
        for i, item in enumerate(df.columns):
            bar.add_yaxis(item,
                          df[item].values.tolist(),
                          label_opts=opts.LabelOpts(is_show=show_label),
                          )
        bar.set_global_opts(
            # title_opts=opts.TitleOpts(title='Trend', pos_left='center'),
            legend_opts=opts.LegendOpts(pos_top='5%', pos_left='10%', pos_right='60%'),
            toolbox_opts=opts.ToolboxOpts(is_show=True),
            tooltip_opts=opts.TooltipOpts(trigger='axis',
                                          axis_pointer_type='cross',
                                          ),
            xaxis_opts=opts.AxisOpts(type_='category',
                                     boundary_gap=True,
                                     axislabel_opts=opts.LabelOpts(rotate=label_rotate),
                                     splitline_opts=opts.SplitLineOpts(is_show=False,
                                                                       linestyle_opts=opts.LineStyleOpts(
                                                                           type_='dotted',
                                                                           opacity=0.5,
                                                                       )
                                                                       )
                                     ),
            yaxis_opts=opts.AxisOpts(type_="value",
                                     axislabel_opts=opts.LabelOpts(formatter=axislabel_format),
                                     # axistick_opts=opts.AxisTickOpts(is_show=True),
                                     splitline_opts=opts.SplitLineOpts(is_show=True,
                                                                       linestyle_opts=opts.LineStyleOpts(
                                                                           type_='dotted',
                                                                           opacity=0.5,
                                                                       )
                                                                       )
                                     ),
        )
    else:
        bar = (Bar())

    return bar
Ejemplo n.º 8
0
def books_pubdate_scatter(id, num) -> Scatter:
    (time,times,num) = books_pubdate(id, num)
    if time == 0:
        return 0
    x_data = list(map(str, times.keys()))
    y_data = list(map(str, times.values()))

    c = (
        Scatter()  # init_opts=opts.InitOpts(width="1600px", height="1000px")
        .add_xaxis(xaxis_data=x_data)
        .add_yaxis(
            series_name="图书数",
            y_axis=y_data,
            symbol_size=20,
            label_opts=opts.LabelOpts(is_show=False),
        )
        .set_series_opts()
        .set_global_opts(
            title_opts=opts.TitleOpts(title="图书发行趋势", subtitle="数据量:" + str(num),),
            xaxis_opts=opts.AxisOpts(
                splitline_opts=opts.SplitLineOpts(is_show=True),
                name="图书发行时间"
            ),
            yaxis_opts=opts.AxisOpts(
                #             type_="value",
                name="图书数量",
                name_gap=50,
                name_rotate=90,
                name_location="center",
                axistick_opts=opts.AxisTickOpts(is_show=True),
                splitline_opts=opts.SplitLineOpts(is_show=True),
            ),
            tooltip_opts=opts.TooltipOpts(is_show=True),
            visualmap_opts=opts.VisualMapOpts(type_="size", max_=5, min_=1),
            toolbox_opts=opts.ToolboxOpts(is_show=True,pos_left="95%",
                                          feature={
                                              "dataZoom": {"yAxisIndex": "none"},
                                              "dataView": {},
                                              "restore": {},
                                              "saveAsImage": {},
                                          },
                                          ),
        )
        .dump_options_with_quotes()
    )
    return c
Ejemplo n.º 9
0
def s_4():
    with open(r'pro.csv', 'r') as f:
        reader = csv.reader(f)
        result = list(reader)
    pro_list = [i[0] for i in result]
    total_list = [float(i[1]) for i in result]
    p = (EffectScatter(init_opts=opts.InitOpts(
        width='1200px', height='800px')).add_xaxis(pro_list).add_yaxis(
            "交易额", total_list,
            label_opts=opts.LabelOpts(is_show=False)).set_global_opts(
                title_opts=opts.TitleOpts(title="本年度交易额省份排名分析"),
                xaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(
                    is_show=True)),
                yaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(
                    is_show=True)),
            ))
    return p
Ejemplo n.º 10
0
 def k_line(self):
     # K线主图
     print(self.ds.code)
     k_line = (Kline(init_opts=INIT_OPTS).add_xaxis(
         xaxis_data=self.datetime).add_yaxis(
             series_name=self.code,
             y_axis=self.ohlc,
             itemstyle_opts=opts.ItemStyleOpts(
                 color="#ef232a",
                 color0="#14b143",
                 border_color="#ef232a",
                 border_color0="#14b143",
             ),
             markpoint_opts=opts.MarkPointOpts(data=[
                 opts.MarkPointItem(type_="max", name="最大值"),
                 opts.MarkPointItem(type_="min", name="最小值"),
             ]),
         ).set_global_opts(
             title_opts=opts.TitleOpts(title=self.code, pos_left="0"),
             xaxis_opts=opts.AxisOpts(
                 type_="category",
                 is_scale=True,
                 boundary_gap=False,
                 axisline_opts=opts.AxisLineOpts(is_on_zero=False),
                 splitline_opts=opts.SplitLineOpts(is_show=False),
                 split_number=20,
                 min_="dataMin",
                 max_="dataMax",
             ),
             yaxis_opts=opts.AxisOpts(
                 is_scale=True,
                 splitline_opts=opts.SplitLineOpts(is_show=True)),
             tooltip_opts=opts.TooltipOpts(trigger="axis",
                                           axis_pointer_type="line"),
             datazoom_opts=[
                 opts.DataZoomOpts(is_show=True,
                                   type_="inside",
                                   range_start=self.range_start,
                                   range_end=100),
                 opts.DataZoomOpts(is_show=True,
                                   pos_bottom="-1%",
                                   range_start=self.range_start,
                                   range_end=100),
             ],
         ))
     return k_line
Ejemplo n.º 11
0
def draw_tendency(month, day):
    dates = ['1-%d' % i for i in range(22, 31 + 1)]
    dates.extend(['2-%02d' % i for i in range(1, day)])
    v0 = [
        131, 259, 444, 688, 769, 1771, 1459, 1737, 1982, 2102, 2590, 2829,
        3235, 3887, 3143, 3399, 2656, 3062, 2478, 2015, 15152, 5090, 2641,
        2009, 2051, 1886, 1749, 385
    ]
    v1 = [
        69, 105, 180, 323, 371, 1291, 840, 1032, 1220, 1347, 1921, 2103, 2345,
        3156, 2447, 2841, 2147, 2618, 2097, 1638, 14840, 4823, 2420, 1843,
        1933, 1807, 1693, 349
    ]
    v2 = [v0[i] - v1[i] for i in range(len(v0))]
    print(v2)
    c = (Line(init_opts=opts.InitOpts(
        width='1000px', height='500px')).add_xaxis(dates).add_yaxis(
            "全国新增确诊病例",
            v0,
            is_smooth=True,
            linestyle_opts=opts.LineStyleOpts(width=4, color='#B44038'),
            itemstyle_opts=opts.ItemStyleOpts(
                color='#B44038', border_color="#B44038",
                border_width=5)).add_yaxis(
                    "湖北新增确诊病例",
                    v1,
                    is_smooth=True,
                    linestyle_opts=opts.LineStyleOpts(width=2,
                                                      color='#4E87ED'),
                    label_opts=opts.LabelOpts(position='bottom'),
                    itemstyle_opts=opts.ItemStyleOpts(
                        color='#4E87ED',
                        border_color="#4E87ED",
                        border_width=3)).add_yaxis(
                            "其他省份新增病例",
                            v2,
                            is_smooth=True,
                            linestyle_opts=opts.LineStyleOpts(width=2,
                                                              color='#F1A846'),
                            label_opts=opts.LabelOpts(position='bottom'),
                            itemstyle_opts=opts.ItemStyleOpts(
                                color='#F1A846',
                                border_color="#F1A846",
                                border_width=3)).set_global_opts(
                                    title_opts=opts.TitleOpts(title=""),
                                    yaxis_opts=opts.AxisOpts(
                                        max_=16000,
                                        min_=10,
                                        type_="log",
                                        name="y",
                                        splitline_opts=opts.SplitLineOpts(
                                            is_show=True),
                                        is_scale=True,
                                        axisline_opts=opts.AxisLineOpts(
                                            is_show=False))))
    root = 'html-charts/%d%d' % (month, day)
    create_dir(root)
    c.render('%s/新增病例趋势图.html' % root)
Ejemplo n.º 12
0
def china_daily_map(wb):
    ws_china_confirmed = wb['中国每日累计确诊数据']
    ws_china_surplus = wb['中国每日现有确诊数据']
    ws_china_crued = wb['中国每日累计治愈数据']
    ws_china_died = wb['中国每日累计死亡数据']

    ws_china_confirmed.delete_rows(1)
    ws_china_surplus.delete_rows(1)
    ws_china_crued.delete_rows(1)
    ws_china_died.delete_rows(1)

    x_date = []
    y_china_confirmed = []
    y_china_surplus = []
    y_china_crued = []
    y_china_died = []

    for china_confirmed in ws_china_confirmed.values:
        y_china_confirmed.append(china_confirmed[1])
    for china_surplus in ws_china_surplus.values:
        y_china_surplus.append(china_surplus[1])
    for china_crued in ws_china_crued.values:
        x_date.append(china_crued[0])
        y_china_crued.append(china_crued[1])
    for china_died in ws_china_died.values:
        y_china_died.append(china_died[1])
    x_date = clean_date(x_date)

    fi_map = (Line(init_opts=opts.InitOpts(height='420px')).add_xaxis(
        xaxis_data=x_date).add_yaxis(
            series_name='中国累计确诊人数',
            y_axis=y_china_confirmed,
            label_opts=opts.LabelOpts(is_show=False),
        ).add_xaxis(xaxis_data=x_date).add_yaxis(
            series_name='中国现有确诊人数',
            y_axis=y_china_surplus,
            label_opts=opts.LabelOpts(is_show=False),
        ).add_yaxis(
            series_name='中国累计治愈人数',
            y_axis=y_china_crued,
            label_opts=opts.LabelOpts(is_show=False),
        ).add_yaxis(
            series_name='中国累计死亡人数',
            y_axis=y_china_died,
            label_opts=opts.LabelOpts(is_show=False),
        ).set_global_opts(
            title_opts=opts.TitleOpts(title='中国COVID-19每日数据走势'),
            legend_opts=opts.LegendOpts(pos_bottom="bottom",
                                        orient='horizontal'),
            tooltip_opts=opts.TooltipOpts(trigger='axis'),
            yaxis_opts=opts.AxisOpts(
                type_='value',
                axistick_opts=opts.AxisTickOpts(is_show=True),
                splitline_opts=opts.SplitLineOpts(is_show=True),
            ),
            xaxis_opts=opts.AxisOpts(type_='category', boundary_gap=False),
        ).dump_options_with_quotes())
    return fi_map
Ejemplo n.º 13
0
def foreign_daily_map(wb):
    ws_foreign_confirmed = wb['境外每日累计确诊数据']
    ws_foreign_surplus = wb['境外每日现有确诊数据']
    ws_foreign_crued = wb['境外每日累计治愈数据']
    ws_foreign_died = wb['境外每日累计死亡数据']

    ws_foreign_confirmed.delete_rows(1)
    ws_foreign_surplus.delete_rows(1)
    ws_foreign_crued.delete_rows(1)
    ws_foreign_died.delete_rows(1)

    x_date = []  # 日期
    y_foreign_confirmed = []  # 累计确诊
    y_foreign_surplus = []
    y_foreign_crued = []  # 累计治愈
    y_foreign_died = []  # 累计死亡

    for foreign_confirmed in ws_foreign_confirmed.values:
        y_foreign_confirmed.append(foreign_confirmed[1])
    for foreign_surplus in ws_foreign_surplus.values:
        y_foreign_surplus.append(foreign_surplus[1])
    for foreign_crued in ws_foreign_crued.values:
        x_date.append(foreign_crued[0])
        y_foreign_crued.append(foreign_crued[1])
    for foreign_died in ws_foreign_died.values:
        y_foreign_died.append(foreign_died[1])
    x_date = clean_date(x_date)

    fte_map = (Line(init_opts=opts.InitOpts(height='420px')).add_xaxis(
        xaxis_data=x_date).add_yaxis(
            series_name="境外累计确诊人数",
            y_axis=y_foreign_confirmed,
            label_opts=opts.LabelOpts(is_show=False),
        ).add_xaxis(xaxis_data=x_date).add_yaxis(
            series_name="境外现有确诊人数",
            y_axis=y_foreign_surplus,
            label_opts=opts.LabelOpts(is_show=False),
        ).add_yaxis(
            series_name="境外累计治愈人数",
            y_axis=y_foreign_crued,
            label_opts=opts.LabelOpts(is_show=False),
        ).add_yaxis(
            series_name="境外累计死亡人数",
            y_axis=y_foreign_died,
            label_opts=opts.LabelOpts(is_show=False),
        ).set_global_opts(
            title_opts=opts.TitleOpts(title="境外COVID-19每日数据走势"),
            legend_opts=opts.LegendOpts(pos_bottom="bottom",
                                        orient='horizontal'),
            tooltip_opts=opts.TooltipOpts(trigger="axis"),
            yaxis_opts=opts.AxisOpts(
                type_="value",
                axistick_opts=opts.AxisTickOpts(is_show=True),
                splitline_opts=opts.SplitLineOpts(is_show=True),
            ),
            xaxis_opts=opts.AxisOpts(type_="category", boundary_gap=False),
        ).dump_options_with_quotes())
    return fte_map
Ejemplo n.º 14
0
def echarts_line(df, datatype="ABS"):
    axislabel_format = "{value}"
    if datatype in ["SHARE", "GR"]:
        df = df.multiply(100).round(2)
        axislabel_format = "{value}%"
    if df.empty is False:
        line = (
            Line()  # init_opts=opts.InitOpts(width="1200px", height="700px")
            .add_xaxis(df.index.strftime("%Y-%m").tolist())
            .set_global_opts(
                # title_opts=opts.TitleOpts(title='Trend', pos_left='center'),
                legend_opts=opts.LegendOpts(pos_top="5%", pos_left="10%", pos_right="60%"),
                toolbox_opts=opts.ToolboxOpts(is_show=True),
                tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="cross",),
                xaxis_opts=opts.AxisOpts(
                    type_="category",
                    boundary_gap=False,
                    splitline_opts=opts.SplitLineOpts(
                        is_show=True, linestyle_opts=opts.LineStyleOpts(type_="dotted", opacity=0.5,),
                    ),
                ),
                yaxis_opts=opts.AxisOpts(
                    type_="value",
                    axislabel_opts=opts.LabelOpts(formatter=axislabel_format),
                    # axistick_opts=opts.AxisTickOpts(is_show=True),
                    splitline_opts=opts.SplitLineOpts(
                        is_show=True, linestyle_opts=opts.LineStyleOpts(type_="dotted", opacity=0.5,),
                    ),
                ),
            )
        )
        for i, item in enumerate(df.columns):
            line.add_yaxis(
                item,
                df[item],
                # symbol='circle',
                symbol_size=8,
                label_opts=opts.LabelOpts(is_show=False),
                linestyle_opts=opts.LineStyleOpts(width=3),
                itemstyle_opts=opts.ItemStyleOpts(border_width=1, border_color="", border_color0="white"),
            )
    else:
        line = Line()

    return line
def line_base():
    c = (
        Scatter().add_xaxis(Faker.choose()).add_yaxis(
            "商家A", Faker.values()).set_global_opts(
                # 显示标题
                title_opts=opts.TitleOpts(title="Scatter-基本示例"),
                # 显示网格线
                xaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(
                    is_show=True)),
                yaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(
                    is_show=True)),
                # 显示可视化图形条
                visualmap_opts=opts.VisualMapOpts(max_=150),
            ))

    # 绘制图片
    pic = c.render()
    return pic
Ejemplo n.º 16
0
    def p_kdj_macd(self, echarts_data, ktype='d'):
        """
        p_kdj_macd的百分比图
        """
        bar = (
            Bar()
                .add_xaxis(xaxis_data=echarts_data['date'])
                .add_yaxis(
                series_name="P_MACD_KDJ",
                y_axis=echarts_data['p_kdj_macd_%s' % ktype],
                xaxis_index=2,
                yaxis_index=2,
                label_opts=opts.LabelOpts(is_show=False),
                itemstyle_opts=opts.ItemStyleOpts(
                    color=JsCode(
                        """
                            function(params) {
                                var colorList;
                                if (params.data >= 0) {
                                  colorList = '#ef232a';
                                } else {
                                  colorList = '#14b143';
                                }
                                return colorList;
                            }
                            """
                    )
                ),
            )
                .set_global_opts(
                xaxis_opts=opts.AxisOpts(
                    type_="category",
                    grid_index=2,
                    axislabel_opts=opts.LabelOpts(is_show=False),

                    # axisline_opts=opts.AxisLineOpts(is_on_zero=False),
                    axistick_opts=opts.AxisTickOpts(is_show=False),  # 不显示刻度
                    # splitline_opts=opts.SplitLineOpts(is_show=False),   # 不显示刻度
                    # axislabel_opts=opts.LabelOpts(is_show=False),
                    # split_number=20,
                ),
                yaxis_opts=opts.AxisOpts(
                    grid_index=2,
                    split_number=4,
                    axisline_opts=opts.AxisLineOpts(is_on_zero=False),
                    axistick_opts=opts.AxisTickOpts(is_show=False),
                    splitline_opts=opts.SplitLineOpts(is_show=False),
                    axislabel_opts=opts.LabelOpts(is_show=True),
                ),
                legend_opts=opts.LegendOpts(is_show=False),
                # title_opts=opts.TitleOpts(subtitle="KDJ_MACD"),
                title_opts=opts.TitleOpts(subtitle="P_KDJ_M_%s" % ktype, pos_top="52%"),  # 标题
                # legend_opts=opts.LegendOpts(pos_top="45%"),  # 图例位置
            )
        )

        return bar
Ejemplo n.º 17
0
def get_scatter(data_dict, title, save_path):
    scatter = Scatter()

    for key, value_list in data_dict.items():
        nparray = np.array(value_list)
        scatter.add_xaxis(nparray[:, 0])
        scatter.add_yaxis(key, nparray[:, 1])

    scatter.set_global_opts(
        title_opts=opts.TitleOpts(title=""),
        xaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(
            is_show=True)),
        yaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(
            is_show=True)),
    )

    scatter.width = "1600px"
    scatter.height = "650px"
    scatter.render("data/analysis/{0}/{1}.html".format(save_path, title))
Ejemplo n.º 18
0
def show_scatter():
    scatter = (
        Scatter(init_opts=opts.InitOpts(width="1600px", height="1000px")).
        add_xaxis(xaxis_data=co_friend_count).add_yaxis(
            series_name="Covid",
            y_axis=covid_polarity,
            symbol="triangle",
            symbol_size=15,
            label_opts=opts.LabelOpts(is_show=False),
        ).add_xaxis(xaxis_data=cr_friend_count).add_yaxis(
            series_name="Crime",
            y_axis=crime_polarity,
            symbol="circle",
            symbol_size=15,
            label_opts=opts.LabelOpts(is_show=False),
        ).set_series_opts().set_global_opts(
            title_opts=opts.TitleOpts(
                title="Twitter Friend Count VS Polarity"),
            xaxis_opts=opts.AxisOpts(
                name='Friend Count',
                name_location='middle',
                name_gap=20,
                type_="value",
                splitline_opts=opts.SplitLineOpts(is_show=True)),
            yaxis_opts=opts.AxisOpts(
                name='Polarity',
                name_location='middle',
                name_gap=20,
                type_="value",
                axistick_opts=opts.AxisTickOpts(is_show=True),
                splitline_opts=opts.SplitLineOpts(is_show=True),
            ),
            # tooltip_opts=opts.TooltipOpts(is_show=False),
            toolbox_opts=opts.ToolboxOpts(),
            visualmap_opts=opts.VisualMapOpts(
                type_="color",
                max_=1,
                min_=-1,
                range_text=['Positive', 'Negative'],
            ),
        ))
    return scatter
Ejemplo n.º 19
0
 def get_volome(self, xdatas, vols, kdatas):
     bar = (
         Bar(init_opts=opts.InitOpts())
             .add_xaxis(xaxis_data=xdatas)
             .add_yaxis(
             series_name="Volume",
             yaxis_data=[
                 [i, vols[i], 1 if kdatas[i][0] < kdatas[i][1] else -1]
                 for i in range(len(kdatas))
             ],
             #         yaxis_data = vols,
             xaxis_index=1,
             yaxis_index=1,
             label_opts=opts.LabelOpts(is_show=False)
         )
             .set_global_opts(
             xaxis_opts=opts.AxisOpts(
                 type_="category",
                 is_scale=True,
                 grid_index=1,
                 boundary_gap=False,
                 axisline_opts=opts.AxisLineOpts(is_on_zero=False),
                 axistick_opts=opts.AxisTickOpts(is_show=False),
                 splitline_opts=opts.SplitLineOpts(is_show=False),
                 axislabel_opts=opts.LabelOpts(is_show=False),
                 split_number=20,
                 min_="dataMin",
                 max_="dataMax",
             ),
             yaxis_opts=opts.AxisOpts(
                 grid_index=1,
                 is_scale=True,
                 split_number=2,
                 axislabel_opts=opts.LabelOpts(is_show=False),
                 axisline_opts=opts.AxisLineOpts(is_show=True),
                 axistick_opts=opts.AxisTickOpts(is_show=True),
                 splitline_opts=opts.SplitLineOpts(is_show=True),
             ),
             legend_opts=opts.LegendOpts(is_show=False),
         )
     )
     return bar
Ejemplo n.º 20
0
def bar_with_custom_splitline():
    bar = Bar(
        init_opts=opts.InitOpts(theme='light', width='1000px', height='600px'))
    bar.add_xaxis(Faker.choose())
    bar.add_yaxis('A', Faker.values())
    bar.add_yaxis('B', Faker.values())
    # x,y轴翻转
    bar.set_global_opts(yaxis_opts=opts.AxisOpts(
        splitline_opts=opts.SplitLineOpts(
            is_show=True, linestyle_opts=opts.LineStyleOpts(type_='dotted'))))
    return bar
Ejemplo n.º 21
0
 def get(self, request, name='治愈人数'):
     from pyecharts.globals import CurrentConfig
     from pyecharts import options as opts
     from pyecharts.charts import Bar
     CurrentConfig.ONLINE_HOST = "https://cdn.jsdelivr.net/gh/pyecharts/pyecharts-assets@latest/assets/"
     data = ReadCsv(name).dump_as_json()
     c = (Bar(init_opts=opts.InitOpts(
         renderer="svg", width='400px', height='277px')).add_xaxis(
             data['labels']).add_yaxis(
                 "人数",
                 data['data'],
                 label_opts=opts.LabelOpts(
                     is_show=False, color='white')).set_series_opts(
                         itemstyle_opts={
                             "normal": {
                                 "barBorderRadius": [25, 25, 25, 25],
                                 "shadowColor": "#2f89cf",
                                 "color": "#2f89cf"
                             }
                         }).set_global_opts(
                             datazoom_opts=opts.DataZoomOpts(
                                 type_="inside"),
                             tooltip_opts=opts.TooltipOpts(
                                 is_show=True,
                                 trigger_on='mousemove|click',
                                 axis_pointer_type='shadow',
                                 trigger='axis'),
                             xaxis_opts=opts.AxisOpts(
                                 is_show=True,
                                 axislabel_opts=opts.LabelOpts(
                                     color='rgba(255,255,255,.6)'),
                                 axisline_opts=opts.AxisLineOpts(
                                     is_show=True,
                                     linestyle_opts=opts.LineStyleOpts(
                                         color='rgba(255,255,255,.1)',
                                         type_='solid',
                                         width=1))),
                             yaxis_opts=opts.AxisOpts(
                                 is_show=True,
                                 axislabel_opts=opts.LabelOpts(
                                     color='rgba(255,255,255,.6)'),
                                 axisline_opts=opts.AxisLineOpts(
                                     is_show=True,
                                     linestyle_opts=opts.LineStyleOpts(
                                         color='rgba(255,255,255,.1)',
                                         type_='solid',
                                         width=1)),
                                 splitline_opts=opts.SplitLineOpts(
                                     is_show=True,
                                     linestyle_opts=opts.LineStyleOpts(
                                         color='rgba(255,255,255,.1)'))),
                             legend_opts=opts.LegendOpts(is_show=False),
                         ))
     return Response(json.loads(c.dump_options()))
Ejemplo n.º 22
0
def paintCandlestick(bar_series, sample):
    x_data = ["2017-10-24", "2017-10-25", "2017-10-26", "2017-10-27"]
    y_data = [[20, 30, 10, 35], [40, 35, 30, 55], [33, 38, 33, 40],
              [40, 40, 32, 42]]

    (Candlestick(init_opts=opts.InitOpts(width="1440px", height="720px")).
     add_xaxis(xaxis_data=x_data).add_yaxis(
         series_name="", y_axis=y_data).set_series_opts().set_global_opts(
             yaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(
                 is_show=True, linestyle_opts=opts.LineStyleOpts(
                     width=1)))).render("basic_candlestick.html"))
Ejemplo n.º 23
0
def grid_mutil_yaxis(data, info):
    """折线图与柱状图"""
    try:
        x_data = data[0]
        bar = (Bar().add_xaxis(x_data).add_yaxis(
            info[0],
            list(map(lambda x: round(x, 1), data[1])),
            yaxis_index=0,
            color="#5793f3",
        ).extend_axis(yaxis=opts.AxisOpts(
            name=info[1],
            type_="value",
            min_=0,
            max_=max(data[2]) * 1.2,
            position="right",
            axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(
                color="#d14a61")),
            axislabel_opts=opts.LabelOpts(formatter="{value}"),
            splitline_opts=opts.SplitLineOpts(
                is_show=True, linestyle_opts=opts.LineStyleOpts(opacity=1)),
        )).set_global_opts(
            xaxis_opts=opts.AxisOpts(type_="category",
                                     axislabel_opts=opts.LabelOpts(
                                         rotate=30,
                                         interval=0,
                                         font_size=10,
                                         font_weight="bold")),
            yaxis_opts=opts.AxisOpts(
                name=info[0],
                max_=8,
                position="left",
                axisline_opts=opts.AxisLineOpts(
                    linestyle_opts=opts.LineStyleOpts(color="#5793f3")),
                axislabel_opts=opts.LabelOpts(formatter="{value}"),
            ),
            title_opts=opts.TitleOpts(title="生育率与GDP增长率对比图"),
            tooltip_opts=opts.TooltipOpts(trigger="axis",
                                          axis_pointer_type="cross"),
        ))
        line = (Line().add_xaxis(x_data).add_yaxis(
            "生育率",
            data[2],
            yaxis_index=1,
            color="#675bba",
            label_opts=opts.LabelOpts(is_show=False),
            linestyle_opts=opts.LineStyleOpts(width=4, opacity=1)))
        bar.overlap(line)
        log.info("折线图与柱状图创建成功")
        return Grid().add(bar,
                          opts.GridOpts(pos_left="5%", pos_right="20%"),
                          is_control_axis_index=True)
    except Exception as ex:
        log.error("折线图与柱状图创建失败: {0}".format(str(ex)))
        return None
Ejemplo n.º 24
0
    def line_bar_draw(data,html_name):
        x_data = data.index.tolist()
        bars = data.iloc[:,1].values.tolist()
        change = data.iloc[:,0].values.tolist()
        bar = (
            Bar(init_opts=opts.InitOpts(width="1200px", height="700px"))
            .add_xaxis(xaxis_data=x_data)
            .add_yaxis(
                series_name="Stock_Price",
                yaxis_data=bars,
                label_opts=opts.LabelOpts(is_show=False),
            )

            .extend_axis(
                yaxis=opts.AxisOpts(
                    name="Value_Series",
                    type_="value",
                )
            )
            .set_global_opts(
                tooltip_opts=opts.TooltipOpts(
                    is_show=True, trigger="axis", axis_pointer_type="cross"
                ),
                xaxis_opts=opts.AxisOpts(
                    type_="category",
                    axispointer_opts=opts.AxisPointerOpts(is_show=True, type_="shadow"),
                ),
                yaxis_opts=opts.AxisOpts(
                    name="Stock_Price",
                    type_="value",
                    axistick_opts=opts.AxisTickOpts(is_show=True),
                    splitline_opts=opts.SplitLineOpts(is_show=True),
                    axislabel_opts=opts.LabelOpts(formatter="¥ {value}"),
                ),
                datazoom_opts=[
                    opts.DataZoomOpts(range_start=0, range_end=100),
                    opts.DataZoomOpts(type_="inside", range_start=0, range_end=100),
                ],
            )
        )

        line = (
            Line()
            .add_xaxis(xaxis_data=x_data)
            .add_yaxis(
                series_name="Value_Series",
                yaxis_index=1,
                y_axis=change,
                label_opts=opts.LabelOpts(is_show=False),
            )
        )

        bar.overlap(line).render('./output/'+html_name+'.html')
Ejemplo n.º 25
0
def get_line_charts():
    line_chart_1 = (
        Line(init_opts=opts.InitOpts(width='500px', height='250px'))
            .add_xaxis(time_list)
            .add_yaxis(series_name="迁出指数",
                       y_axis=hubei_out_data,
                       # symbol="emptyCircle",
                       is_symbol_show=True,
                       is_smooth=True, )
            .add_yaxis(series_name="迁入指数",
                       y_axis=hubei_in_data,
                       # symbol="emptyCircle",
                       is_symbol_show=True,
                       is_smooth=True, )
            .set_global_opts(
            title_opts=opts.TitleOpts(title='01-01至03-10湖北省迁徙指数',
                                      pos_left='72%', pos_top='15%'),
            tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type='shadow'),
            legend_opts=opts.LegendOpts(is_show=True ,orient='horizontal', pos_left='75%', pos_top='20%'),
            yaxis_opts=opts.AxisOpts(
                name='迁徙指数',
                type_='value',
                axistick_opts=opts.AxisTickOpts(is_show=True),
                splitline_opts=opts.SplitLineOpts(is_show=True),
            )
        )
            .set_series_opts(label_opts=opts.LabelOpts(is_show=False), splitline_opts=opts.SplitLineOpts(is_show=True))

    )

    wordcloud = (
        WordCloud()
        .add(series_name="城市", data_pair=get_out_cities(), word_size_range=[10, 66],
             pos_left='-8%', pos_top='10%', shape='triangle-forward')
        .set_global_opts(
            title_opts=opts.TitleOpts(
                title="1-21湖北省迁出热门城市", pos_left='20%', pos_top='15%'
            ),
            tooltip_opts=opts.TooltipOpts(is_show=True),
        )
    )

    grid_chart = (
        Grid(init_opts=opts.InitOpts(width='1500px', height='700px'))
            .add(
            line_chart_1,
            grid_opts=opts.GridOpts(
                pos_left='65%', pos_right='80', pos_top='30%', pos_bottom='30%'
            )
    )
            .add(wordcloud, grid_opts=opts.GridOpts(pos_left="20%", pos_top="10%"))
    )
    return grid_chart
Ejemplo n.º 26
0
def bar1_line1_with_two_axis(x, y_bar, y_line, y_bar_name, y_line_name, sub_title, index, title_left, titel_top):
    bar = (
        Bar(init_opts=opts.InitOpts(width='600px', height='300px'))
            .add_xaxis(x)
            .add_yaxis(
                y_bar_name,
                y_bar,
                xaxis_index=index,  # 需要变动的,图层中第几条X轴
                yaxis_index=index * 2,  # 需要变动的,,图层中第几条Y轴
                color="#5793f3",
            )
            .set_global_opts(
            yaxis_opts=opts.AxisOpts(
                name=y_bar_name,
                min_=0,
                max_=25000,
                position="right",
                grid_index=index,  # 需要变动的 y轴
                axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(color="#5793f3")),
                axislabel_opts=opts.LabelOpts(formatter="{value}"),
            ),
            title_opts=opts.TitleOpts(title=sub_title, pos_left=title_left, pos_top=titel_top),
            tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="cross"),
            legend_opts=opts.LegendOpts(pos_left="40%", pos_bottom="0%"),  # 图例的位置
        )
            .extend_axis(
            yaxis=opts.AxisOpts(
                type_="value",
                name=y_line_name,
                min_=0,
                max_=3,
                position="left",
                axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(color="#675bba")),
                axislabel_opts=opts.LabelOpts(formatter="{value}"),
                splitline_opts=opts.SplitLineOpts(is_show=True, linestyle_opts=opts.LineStyleOpts(opacity=1)),
            )
        )
    )
    line = (
        Line()
            .add_xaxis(x)
            .add_yaxis(
                y_line_name,
                y_line,
                xaxis_index=index,  # 需要变动的,图层中第几条X轴
                yaxis_index=index * 2 + 1,  # 需要变动的,图层中第几条Y轴
                color="#675bba",
                label_opts=opts.LabelOpts(is_show=True),
                z_level=1  # z_level将折线图置于直方图之上,控制图表的显示层级,不然会被直方图遮挡
        )
    )
    overlap = bar.overlap(line)
    return overlap
Ejemplo n.º 27
0
def echarts_scatter(df):
    # x = df.iloc[:, 0]
    # y = df.iloc[:, 1]
    # n = 100 / np.log(df.shape[0])  # 动态散点大小
    n = 10  # 静态散点大小

    if df.empty is False:
        scatter = Scatter(init_opts=opts.InitOpts())
        for index, row in df.iterrows():
            x = int(row[0])
            y = int(row[1])
            scatter.add_xaxis(xaxis_data=[x])
            scatter.add_yaxis(
                series_name=index,
                y_axis=[y],
                symbol_size=n,
                label_opts=opts.LabelOpts(is_show=False),
            )
            scatter.set_series_opts()
        scatter.set_global_opts(
            xaxis_opts=opts.AxisOpts(
                type_="value",
                name="销售",
                splitline_opts=opts.SplitLineOpts(is_show=True),
            ),
            yaxis_opts=opts.AxisOpts(
                name="同比净增长",
                type_="value",
                axistick_opts=opts.AxisTickOpts(is_show=True),
                splitline_opts=opts.SplitLineOpts(is_show=True),
            ),
            tooltip_opts=opts.TooltipOpts(
                is_show=True, trigger="item", formatter="{a} <br/>{b}: {c}"
            ),
            # toolbox_opts=opts.ToolboxOpts(is_show=True),
            legend_opts=opts.LegendOpts(is_show=False),
        )
    else:
        scatter = Scatter()
    return scatter
Ejemplo n.º 28
0
def line_chart(request):
    x_data = tname_list
    c = (
        Line().add_xaxis(xaxis_data=x_data).add_yaxis(
            series_name="python",
            y_axis=so_dict['k1'],
            label_opts=opts.LabelOpts(is_show=False),
        ).add_yaxis(
            series_name="C",
            y_axis=so_dict['k2'],
            label_opts=opts.LabelOpts(is_show=False),
        ).add_yaxis(
            series_name="C#",
            y_axis=so_dict['k3'],
            label_opts=opts.LabelOpts(is_show=False),
        ).add_yaxis(
            series_name="C++",
            y_axis=so_dict['k4'],
            label_opts=opts.LabelOpts(is_show=False),
        ).add_yaxis(
            series_name="JAVA",
            y_axis=so_dict['k5'],
            label_opts=opts.LabelOpts(is_show=False),
        ).add_yaxis(
            series_name="javascript",
            y_axis=so_dict['k6'],
            label_opts=opts.LabelOpts(is_show=False),
        ).add_yaxis(
            series_name="PHP",
            y_axis=so_dict['k7'],
            label_opts=opts.LabelOpts(is_show=False),
        ).add_yaxis(
            series_name="VBS",
            y_axis=so_dict['k8'],
            label_opts=opts.LabelOpts(is_show=False),
        ).add_yaxis(
            series_name="易语言",
            y_axis=so_dict['k9'],
            label_opts=opts.LabelOpts(is_show=False),
        ).set_global_opts(
            title_opts=opts.TitleOpts(title=request.session['s'].stuName),
            tooltip_opts=opts.TooltipOpts(trigger="axis"),
            yaxis_opts=opts.AxisOpts(
                type_="value",
                axistick_opts=opts.AxisTickOpts(is_show=True),
                splitline_opts=opts.SplitLineOpts(is_show=True),
            ),
            xaxis_opts=opts.AxisOpts(type_="category", boundary_gap=False),
        )
        # .render("stacked_line_chart.html")
    )
    return HttpResponse(c.render_embed())
Ejemplo n.º 29
0
def paintGraph(contestInfo, starttime='2017-09', endtime='2020-07'):
    # 先根据指定的起始日期和截止日期构造需要的数据
    x, cf, ac, nc, jsk, total = [], [], [], [], [], []
    for key, value in sorted(contestInfo.items()):
        if key >= starttime and key <= endtime:
            x.append(key)
            cf.append({'value': value.get('cf', 0)})
            ac.append({'value': value.get('ac', 0)})
            nc.append({'value': value.get('nc', 0)})
            jsk.append({'value': value.get('jsk', 0)})
            total.append(value.get('total', 0))

    # print(total)

    # 绘制图表
    bar = Bar(
        init_opts=opts.InitOpts(theme=ThemeType.LIGHT, page_title='各年月比赛数量统计'))
    bar.set_global_opts(title_opts=opts.TitleOpts(title='各年月比赛数量统计'),
                        xaxis_opts=opts.AxisOpts(name='比赛年月'),
                        yaxis_opts=opts.AxisOpts(name='比赛数量统计'))
    bar.add_xaxis(x)
    bar.add_yaxis("CodeForces", cf, stack="stack1", category_gap="50%")
    bar.add_yaxis("NowCoder", nc, stack="stack1", category_gap="50%")
    bar.add_yaxis("AtCoder", ac, stack="stack1", category_gap="50%")
    bar.add_yaxis("计蒜客", jsk, stack="stack1", category_gap="50%")
    bar.set_series_opts(label_opts=opts.LabelOpts(
        position="inside",
        formatter=JsCode(
            "function(x){return x.data.value ? Number(x.data.value) : '';}"),
    ))

    line = Line()
    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),
        ),
    )
    line.add_xaxis(xaxis_data=x)
    line.add_yaxis(
        series_name="total",
        y_axis=total,
        symbol="Circle",
        is_symbol_show=True,
        label_opts=opts.LabelOpts(is_show=True),
    )

    # 将柱状图与折线图一起输出到html文件中
    bar.overlap(line).render('acmersite02.html')
Ejemplo n.º 30
0
 def MACD(self) -> Bar:
     c = (Bar().add_xaxis(self.dateindex).add_yaxis(
         "macd",
         round(self.data.MACD, self.precision).values.tolist(),
         stack="v",
         category_gap=2,
         itemstyle_opts=opts.ItemStyleOpts(color=JsCode("""
                             function(params) {
                                 var colorList;
                                 if (params.data >= 0) {
                                     colorList = '#ef232a';
                                 } else {
                                     colorList = '#14b143';
                                 }
                             return colorList;
                             }
                         """)),
     ).set_series_opts(label_opts=opts.LabelOpts(
         is_show=False)).set_global_opts(
             datazoom_opts=[
                 opts.DataZoomOpts(range_start=0, range_end=100)
             ],
             legend_opts=opts.LegendOpts(orient='vertical',
                                         pos_left="top",
                                         pos_top="70%"),
             xaxis_opts=opts.AxisOpts(
                 type_="category",
                 is_scale=True,
                 grid_index=1,
                 boundary_gap=False,
                 axisline_opts=opts.AxisLineOpts(is_on_zero=False),
                 axistick_opts=opts.AxisTickOpts(is_show=False),
                 splitline_opts=opts.SplitLineOpts(is_show=False),
                 axislabel_opts=opts.LabelOpts(is_show=False),
             )))
     dea = round(self.data.DEA, self.precision).values.tolist()
     dif = round(self.data.DIF, self.precision).values.tolist()
     macd_line = (Line().add_xaxis(self.dateindex).add_yaxis(
         "DIF",
         dif,
         is_symbol_show=False,
         label_opts=opts.LabelOpts(is_show=False),
         linestyle_opts=opts.LineStyleOpts(type_='solid', width=2),
     ).add_yaxis(
         "DEA",
         dea,
         is_symbol_show=False,
         label_opts=opts.LabelOpts(is_show=False)).set_series_opts(
             label_opts=opts.LabelOpts(is_show=False)).set_global_opts(
                 datazoom_opts=[opts.DataZoomOpts()], ))
     c.overlap(macd_line)
     return c