charting-library-examples
charting-library-examples copied to clipboard
Angular - there was an error when loading the library
Checklist
- [ *] This issue is NOT related to the charting library itself
Describe the bug
ERROR Error: Uncaught (in promise): Error: There was an error when loading the library. Usually this error means the library failed to load its static files. Check that the library files are available at localhost:4200//assets/charting_library/ or correct the library_path option. Error: There was an error when loading the library. Usually this error means the library failed to load its static files. Check that the library files are available at localhost:4200//assets/charting_library/ or correct the library_path option
Expected behavior
It should load the charting_library from assets folder.
Screenshots
Error:
Angular Assets folder:
Trading view constructor:
Additional context
Why is it not working? We are using the following build:
TT v26.003 (internal id e793d706 @ 2023-10-05T20:30:59.543Z)
It turned out that save_load_adapter service is causing the issue.
This is my constructor code:
const widgetOptions: TradingTerminalWidgetOptions = {
symbol: this._symbol,
datafeed: this.datafeed,
interval: this._interval,
container: this._chartId,
library_path: 'assets/charting_library/',
locale: getLanguageFromURL() || "en",
disabled_features: [
"open_account_manager",
"trading_account_manager",
"save_chart_properties_to_local_storage",
],
enabled_features: [
"study_templates",
"add_to_watchlist",
"chart_crosshair_menu",
"tick_resolution",
"use_localstorage_for_settings",
"pre_post_market_sessions",
"show_symbol_logos",
"watchlist_sections",
],
charts_storage_url: this._chartsStorageUrl,
charts_storage_api_version: this._chartsStorageApiVersion,
client_id: this._clientId,
user_id: this.user.uid,
fullscreen: this._fullscreen,
autosize: this._autosize,
theme: "dark",
overrides: {
"paneProperties.background": "#222736",
"scalesProperties.textColor": "#a6b0cf",
},
//debug: true,
news_provider: async (symbol, callback) => {
let newItem = await this.dataService.getTickerNews(symbol);
let result: NewsItem[] = [];
newItem.results.forEach((item) => {
let newsItem: NewsItem = {
published: moment(item.published_utc).valueOf(),
source: item.publisher.name,
title: item.title,
fullDescription: item.description,
shortDescription: item.description ?? "",
link: item.amp_url,
};
result.push(newsItem);
});
console.log(result, "news");
callback({
title: `Top Stories`,
newsItems: result,
});
},
symbol_search_request_delay: 1000,
custom_css_url: "../../../assets/scss/custom/components/_tvcharts.css",
widgetbar: {
news: true,
details: true,
watchlist: true,
datawindow: true
},
load_last_chart: true,
save_load_adapter: this.saveLoadAdapterService
};
const tvWidget = new widget(widgetOptions);
If i comment out save_load_adapter: this.saveLoadAdapterService
then it works just fine, does anyone know what could be the problem?
As shown in that example save_load_adapter
is expecting an object.
No idea if that's what you had but could be the reason for the error.