【问题标题】:TradingView Chart doesnt show upTradingView 图表不显示
【发布时间】:2019-07-24 05:03:24
【问题描述】:

谁能告诉我为什么我的 TradingView 图表不显示?我得到一个没有图表显示的空白页面。

我按照这里的所有说明进行安装:

https://github.com/tradingview/lightweight-charts/blob/master/docs/README.md

这是我的 1 页独立文件内容....

<!DOCTYPE html>
<html>
<body>
<script src="https://unpkg.com/lightweight-charts/dist/lightweight-charts.standalone.production.js">
    const chart = LightweightCharts.createChart(document.body, { width: 400, height: 300 });
    const lineSeries = chart.addLineSeries();
    lineSeries.setData([
        { time: '2019-04-11', value: 80.01 },
        { time: '2019-04-12', value: 96.63 },
        { time: '2019-04-13', value: 76.64 },
        { time: '2019-04-14', value: 81.89 },
        { time: '2019-04-15', value: 74.43 },
        { time: '2019-04-16', value: 80.01 },
        { time: '2019-04-17', value: 96.63 },
        { time: '2019-04-18', value: 76.64 },
        { time: '2019-04-19', value: 81.89 },
        { time: '2019-04-20', value: 74.43 },
    ]);
</script>
</body>
</html>

【问题讨论】:

    标签: javascript html tradingview-api


    【解决方案1】:

    你需要在你的html页面的&lt;head&gt;中导入js脚本,然后像这样在body中运行你的javascript:

    <!DOCTYPE html>
    <html>
      <head>
        <script src="https://unpkg.com/lightweight-charts/dist/lightweight-charts.standalone.production.js"></script>
      </head>
    <body>
    <script>
        const chart = LightweightCharts.createChart(document.body, { width: 400, height: 300 });
        const lineSeries = chart.addLineSeries();
        lineSeries.setData([
            { time: '2019-04-11', value: 80.01 },
            { time: '2019-04-12', value: 96.63 },
            { time: '2019-04-13', value: 76.64 },
            { time: '2019-04-14', value: 81.89 },
            { time: '2019-04-15', value: 74.43 },
            { time: '2019-04-16', value: 80.01 },
            { time: '2019-04-17', value: 96.63 },
            { time: '2019-04-18', value: 76.64 },
            { time: '2019-04-19', value: 81.89 },
            { time: '2019-04-20', value: 74.43 },
        ]);
    </script>
      
    </body>
    </html>

    【讨论】:

    • 添加 javascript 文件 {{ url_for('static', filename='chart.js') }} 不起作用。但是按照您的代码,它可以正常工作。有什么原因吗
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多