Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular - there was an error when loading the library #366

Open
tradingproject19 opened this issue Dec 1, 2023 · 2 comments
Open

Angular - there was an error when loading the library #366

tradingproject19 opened this issue Dec 1, 2023 · 2 comments

Comments

@tradingproject19
Copy link

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:
image

Angular Assets folder:

image

Trading view constructor:
image

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)

@tradingproject19
Copy link
Author

tradingproject19 commented Dec 1, 2023

It turned out that save_load_adapter service is causing the issue.

image

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?

@romfrancois
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants