一个公开的图表库,支持任意站点的CORS,你可以在本地使用和构建
具体方法,可以参考官方文档 Hosting-Library-Cross-Origin
/charting_library/broker-sample/dist/bundle.js/udf/dist/bundle.js使用路径/p/,在后面接入url含http开头。
比如/p/https://www.ibkr.com.cn/
这能帮你绕过CORS,但是有白名单限制
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ibkr-gateway-tv</title>
</head>
<body style="margin: 0;">
<div id="tv_chart_container" style="margin: 0;"></div>
<script type="module">
import { widget as tvwidget } from 'https://tv-chart-lib.pages.dev/charting_library/charting_library.esm.js';
window.addEventListener('DOMContentLoaded', () => {
const widget = new tvwidget({
datafeed: Datafeed,
// debug: true,
container: 'tv_chart_container',
library_path: 'https://tv-chart-lib.pages.dev/charting_library/',
fullscreen: true,
autosize: true,
symbol: 'AAPL',
interval: '1D',
locale: 'zh',
timezone: 'Asia/Shanghai',
symbol_search_request_delay: 2000,
theme: 'dark',
widgetbar: {
details: true, watchlist: true, news: true, datawindow: true
},
enabled_features: [],
disabled_features: [],
});
});
</script>
</body>
</html>
持续更新中