GithubHelp home page GithubHelp logo

Comments (2)

sunhailin-Leo avatar sunhailin-Leo commented on June 12, 2024

@EnjoyLeole

  • 检查顺序:
    • 查看浏览器控制台有没有错误提示
    • 给出截图或复现问题的代码

from pyecharts.

EnjoyLeole avatar EnjoyLeole commented on June 12, 2024

经测试,应该是使用双坐标轴导致的问题
用于双坐标轴绘制的函数在一般情况下使用正常,但在Gird中出现问题
函数如下:

def add_dual_line(self, line_series, label='', line_series2=None, label2='', index=0):
    """ 输入series"""
    if isinstance(line_series, pd.Series):
        x_axis = [x for x in line_series.index]
    else:
        x_axis = range(len(line_series))
    symbol = 'emptyCircle'
    if 'ma' in label:
        symbol = 'None'

    line_series = [LineItem(value=x, symbol=symbol) for x in line_series]
    line_opacity = 0.8

    line = Line(init_opts=opts.InitOpts(f'{PAGE_WIDTH}px'))
    line.add_xaxis(xaxis_data=x_axis)
    line.extend_axis(yaxis=opts.AxisOpts(name=label, type_='value', position="left", ))
    line.add_yaxis(
        series_name=label,
        y_axis=line_series,
        # symbol=symbol,
        # xaxis_index=index,
        # yaxis_index=index,
        # is_smooth=True,
        # linestyle_opts=opts.LineStyleOpts(width=2, opacity=line_opacity),
        label_opts=opts.LabelOpts(is_show=False),
    )
    line.set_global_opts(
        title_opts=opts.TitleOpts(title=label, is_show=True),
        xaxis_opts=opts.AxisOpts(
            type_='category',
            is_scale=True,
            boundary_gap=False,
            axisline_opts=opts.AxisLineOpts(is_on_zero=False),
            axistick_opts=opts.AxisTickOpts(is_show=False),
            splitline_opts=opts.SplitLineOpts(is_show=True),
            axislabel_opts=opts.LabelOpts(is_show=True),
            split_number=20,
            min_="dataMin",
            max_="dataMax",
        ),
        yaxis_opts=opts.AxisOpts(
            is_scale=True,
            split_number=2,
            position='left',
            axisline_opts=opts.AxisLineOpts(is_show=False),
            axistick_opts=opts.AxisTickOpts(is_show=False),
            splitline_opts=opts.SplitLineOpts(is_show=True),
            axislabel_opts=opts.LabelOpts(is_show=True),
        ),
        tooltip_opts=opts.TooltipOpts(
            trigger="axis",
            axis_pointer_type="cross",
            background_color="rgba(245, 245, 245, 0.8)",
            border_width=1,
            border_color="#ccc",
            textstyle_opts=opts.TextStyleOpts(color="#000"),
        ),
        legend_opts=opts.LegendOpts(is_show=True, orient='vertical', pos_left='right', pos_bottom='10%'), )
    if line_series2 is not None:
        line.extend_axis(yaxis=opts.AxisOpts(name=label2, type_='value', position="right", ))
        line2 = Line(init_opts=opts.InitOpts(f'{PAGE_WIDTH}px'))
        line2.add_xaxis(xaxis_data=x_axis)
        line2.extend_axis(yaxis=opts.AxisOpts(name=label2, type_='value', position="right", ))
        line2.add_yaxis(
            series_name=label2,
            y_axis=[x for x in line_series2],
            xaxis_index=index + 1,
            yaxis_index=index + 1,
            is_smooth=True,
            is_hover_animation=False,
            is_connect_nones=True,
            linestyle_opts=opts.LineStyleOpts(width=2, opacity=line_opacity),
            label_opts=opts.LabelOpts(is_show=False),
        )
        line2.set_global_opts(
            yaxis_opts=opts.AxisOpts(
                is_scale=True,
                split_number=2,
                position='right',
                axisline_opts=opts.AxisLineOpts(is_show=False),
                axistick_opts=opts.AxisTickOpts(is_show=False),
                splitline_opts=opts.SplitLineOpts(is_show=True),
                axislabel_opts=opts.LabelOpts(is_show=True),
            ), )
        # legend_opts=opts.LegendOpts(is_show=True, pos_left='right', pos_bottom='10%'), )
        line.overlap(line2)
    return line

不显示的浏览器报错如下:

echarts.min.js:45 Uncaught TypeError: Cannot read properties of undefined (reading 'type')
at Object.reset (echarts.min.js:45:352188)
at t.ty [as _reset] (echarts.min.js:45:174667)
at t._doReset (echarts.min.js:45:135579)
at t.perform (echarts.min.js:45:134592)
at echarts.min.js:45:172579
at echarts.min.js:35:8394
at Map.forEach ()
at t.each (echarts.min.js:35:8369)
at echarts.min.js:45:172420
at Array.forEach ()

from pyecharts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.