我正在使用tv-chart.html制作图表,并且在我在工具中加载数据时遇到问题。在这里我通过"加载数据。 datafeed:new Datafeeds.UDFCompatibleDatafeed(http://localhost:8066/candles/JSP/candlestickXml.jsp")"像这样:
TradingView.onready(function() {
var widget = new TradingView.widget({
fullscreen: true,
symbol: 'DESCO',
interval: 'D',
container_id: "tv_chart_container",
// BEWARE: no trailing slash is expected in feed URL
datafeed: new Datafeeds.UDFCompatibleDatafeed(http: //localhost:8066/candles/JSP/candlestickXml.jsp"),
library_path: "./charting_library/",
locale: "ja",
// Regression Trend-related functionality is not implemented yet, so it's hidden for a while
drawings_access: {
type: 'black',
tools: [{
name: "Regression Trend"
}]
},
disabled_features: ["use_localstorage_for_settings"],
});
})
以下数据调用js文件chartig_library.min.js代码是这个
function inherit(g, f) {
onready: function(a) {
window.addEventListener ? window.addEventListener("DOMContentLoaded", a, !1) : window.attachEvent("onload", a)
},
widget: function(a) {
this.id = d.gId();
if (!a.datafeed) throw "Datafeed is not defined";
var b = {
width: 800,
height: 500,
symbol: "AA",
interval: "D",
timezone: "",
container: "",
path: "",
locale: "en",
toolbar_bg: void 0,
hideSymbolSearch: !1,
hideSideToolbar: !1,
enabledStudies: [],
enabledDrawings: [],
disabledDrawings: [],
disabledStudies: [],
drawingsAccess: void 0,
studiesAccess: void 0,
widgetbar: {
datawindow: !1,
details: !1,
watchlist: !1,
watchlist_settings: {
default_symbols: []
}
},
overrides: {},
studiesOverrides: {},
fullscreen: !1,
disabledFeatures: [],
enabledFeatures: [],
indicators_file_name: null,
debug: !1,
time_frames: [{
text: "5y",
resolution: "W"
}, {
text: "1y",
resolution: "W"
}, {
text: "6m",
resolution: "120"
}, {
text: "3m",
resolution: "60"
}, {
text: "1m",
resolution: "30"
}, {
text: "5d",
resolution: "5"
}, {
text: "1d",
resolution: "1"
}],
client_id: "0",
user_id: "0",
charts_storage_url: void 0,
logo: {}
},
e = {
width: a.width,
height: a.height,
symbol: a.symbol,
interval: a.interval,
timezone: a.timezone,
container: a.container_id,
path: a.library_path,
locale: a.locale,
toolbar_bg: a.toolbar_bg,
hideSymbolSearch: a.hide_symbol_search || a.hideSymbolSearch,
hideSideToolbar: a.hide_side_toolbar,
enabledStudies: a.enabled_studies,
disabledStudies: a.disabled_studies,
enabledDrawings: a.enabled_drawings,
disabledDrawings: a.disabled_drawings,
drawingsAccess: a.drawings_access,
studiesAccess: a.studies_access,
widgetbar: a.widgetbar,
overrides: a.overrides,
studiesOverrides: a.studies_overrides,
savedData: a.saved_data || a.savedData,
snapshotUrl: a.snapshot_url,
uid: this.id,
datafeed: a.datafeed,
disableLogo: a.disable_logo || a.disableLogo,
logo: a.logo,
fullscreen: a.fullscreen,
disabledFeatures: a.disabled_features,
enabledFeatures: a.enabled_features,
indicators_file_name: a.indicators_file_name,
debug: a.debug,
client_id: a.client_id,
user_id: a.user_id,
charts_storage_url: a.charts_storage_url
};
g(e);
this.options = $.extend(!0, b, e);
this.options.time_frames =
a.time_frames || b.time_frames;
a.preset && (a = a.preset, f[a] ? (a = f[a], this.options.disabledFeatures = 0 < this.options.disabledFeatures.length ? this.options.disabledFeatures.concat(a.disabledFeatures) : a.disabledFeatures, this.options.enabledFeatures = 0 < this.options.enabledFeatures.length ? this.options.enabledFeatures.concat(a.enabledFeatures) : a.enabledFeatures) : console.warn("Unknown preset: `" + a + "`"));
this._ready_handlers = [];
this.create()
}
};
d.widget.prototype = {
_messageTarget: function() {
return d.gEl(this.id).contentWindow
},
_autoResizeChart: function() {
var a = d.gEl(this.id);
this.options.fullscreen && (a.style.height = window.innerHeight + "px", a.style.width = window.innerWidth + "px")
},
create: function() {
var a = this.render(),
b = this,
e;
this.options.container ? d.gEl(this.options.container).innerHTML = a : document.write(a);
this._autoResizeChart();
window.addEventListener("resize", function(a) {
b._autoResizeChart()
});
e = d.gEl(this.id);
this.postMessage = d.postMessageWrapper(e.contentWindow, this.id);
d.bindEvent(e, "load", function() {
b.postMessage.get("widgetReady", {}, function() {
var a;
b._ready = !0;
for (a = b._ready_handlers.length; a--;) b._ready_handlers[a].call(b);
b.postMessage.post(e.contentWindow, "initializationFinished");
d.gEl(b.id).contentWindow.Z16.subscribe("chart_load_requested", function(a) {
b.load(JSON.parse(a.content), a)
})
})
})
},
render: function() {
window[this.options.uid] = {
datafeed: this.options.datafeed,
overrides: this.options.overrides,
studiesOverrides: this.options.studiesOverrides,
disabledFeatures: this.options.disabledFeatures,
enabledFeatures: this.options.enabledFeatures,
enabledDrawings: this.options.enabledDrawings,
disabledDrawings: this.options.disabledDrawings
};
var a = (this.options.path || "") + "static/tv-chart.html#localserver=1&symbol=" + encodeURIComponent(this.options.symbol) + "&interval=" + encodeURIComponent(this.options.interval) + (this.options.toolbar_bg ? "&toolbarbg=" + this.options.toolbar_bg.replace("#", "") : "") + "&hideSymbolSearch=" + this.options.hideSymbolSearch + "&hideSideToolbar=" + this.options.hideSideToolbar + "&enabledStudies=" + encodeURIComponent(JSON.stringify(this.options.enabledStudies)) +
"&disabledStudies=" + encodeURIComponent(JSON.stringify(this.options.disabledStudies)) + (this.options.studiesAccess ? "&studiesAccess=" + encodeURIComponent(JSON.stringify(this.options.studiesAccess)) : "") + "&widgetbar=" + encodeURIComponent(JSON.stringify(this.options.widgetbar)) + (this.options.drawingsAccess ? "&drawingsAccess=" + encodeURIComponent(JSON.stringify(this.options.drawingsAccess)) : "") + "&timeFrames=" + encodeURIComponent(JSON.stringify(this.options.time_frames)) + (this.options.hasOwnProperty("disableLogo") ?
"&disableLogo=" + encodeURIComponent(this.options.disableLogo) : "") + (this.options.hasOwnProperty("logo") ? "&logo=" + encodeURIComponent(JSON.stringify(this.options.logo)) : "") + "&locale=" + encodeURIComponent(this.options.locale) + "&uid=" + encodeURIComponent(this.options.uid) + "&clientId=" + encodeURIComponent(this.options.client_id) + "&userId=" + encodeURIComponent(this.options.user_id) + (this.options.charts_storage_url ? "&chartsStorageUrl=" + encodeURIComponent(this.options.charts_storage_url) : "") + (this.options.indicators_file_name ?
"&indicatorsFile=" + encodeURIComponent(this.options.indicators_file_name) : "") + "&debug=" + this.options.debug + (this.options.snapshotUrl ? "&snapshotUrl=" + encodeURIComponent(this.options.snapshotUrl) : "") + (this.options.timezone ? "&timezone=" + encodeURIComponent(this.options.timezone) : "");
this.options.savedData && (window.__TVSavedChart = this.options.savedData);
return '<iframe id="' + this.id + '" name="' + this.id + '" src="' + a + '"' + (this.options.fullscreen ? "" : ' width="' + this.options.width + '" height="' + this.options.height +
'"') + ' frameborder="0" allowTransparency="true" scrolling="no" allowfullscreen></iframe>'
此数据通过此js文件datafeed.js
提供数据我不明白问题是它无法加载数据。你能帮帮我吧吗?