绘图折线图在 python 烧瓶中没有完美显示

问题描述

我在 python 中创建了一个 plotly 折线图,它将被解析到我的 html 文件中。当我使用 fig.show() 打印结果时,没问题。但是当我尝试将其解析为 html 文件时,图表并没有像这张图片那样完美显示

enter image description here

这是 fig.show() 的图表:

enter image description here

这是代码

df = pd.read_csv('tes3.csv',header=None,names=["Keyword","Tanggal","Tweet","Sentimen"])
    df['Tanggal'] = pd.to_datetime(df['Tanggal'],errors='coerce')


    mask = df['Keyword']==que
    result = df[mask].groupby([pd.Grouper(key='Tanggal',freq='60s'),'Sentimen']).count().unstack(fill_value=0).stack().reset_index()
    result = result.rename(columns={"Keyword": "Jumlah Sentimen","Tanggal":"Waktu"})
    time_series = result["Waktu"][result['Sentimen']==0].reset_index(drop=True)

    fig = px.line(result,x='Waktu',\
        y="Jumlah Sentimen",color="Sentimen")
    fig.show()        
    
    dataa = [fig]
    graphJSON = json.dumps(dataa,cls=plotly.utils.PlotlyJSONEncoder)
    return render_template("fortabel.html",headings=headings,data=data,que=que,graph_values=graph_values,layout=layout,graphJSON=graphJSON)

这是 html 文件

<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://d14fo0winaifog.cloudfront.net/plotly-basic.js"></script>
</head>
<div id="chart" class="chart"  style="margin-top: 30px; text-align: center;">
    <script type="text/javascript">
        
        var graphs = {{graphJSON | safe}};
       
        Plotly.newPlot('chart',graphs,{});        

    </script>

我该如何解决

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...