tradingview / charting-library-examples

Examples of Charting Library integrations with other libraries, frameworks and data transports
MIT License
1.44k stars 768 forks source link

Datafeeds undefined in vuejs #312

Open chaithu4k opened 2 years ago

chaithu4k commented 2 years ago

Hi Team,

Our porject is based on vuejs with larvel.. when we are trying to implement chart its throwing datafeeds undefined.

i have added charting_library and datafeeds in public floder

In APP.vue

const chartBundleScript = document.createElement("script"); chartBundleScript.type = "text/javascript"; chartBundleScript.src = /resources/assets/src/public/datafeeds/udf/dist/bundle.js; document.getElementsByTagName("head")[0].appendChild(chartBundleScript);

    const chartScript = document.createElement("script");
    chartScript.type = "text/javascript";
    chartScript.src = `/resources/assets/src/public/charting_library/charting_library.standalone.js`;
    document.getElementsByTagName("head")[0].appendChild(chartScript);

I can see its reflected in browser..

`

`

can someone please help me in implementing charting library

keyhan-picasso commented 2 years ago

Hi, same problem here TypeError: Cannot read properties of undefined (reading 'UDFCompatibleDatafeed')

I've tried anything I could think of or find on the internet, but I keep getting Datafeeds undefined,

also I couldn't run vue example due to deprecated node-sass!

keyhan-picasso commented 2 years ago

Hi again,

I fixed my issue by adding both scripts to index.html

<script type="text/javascript" src="/charting_library/charting_library.standalone.js"></script>
<script type="text/javascript" src="/datafeeds/udf/dist/bundle.js"></script>

and another error that I was dealing with: Uncaught SyntaxError: Unexpected token '<' (at bundle.js:1:1) which was caused by relative paths for my scripts, fixed it by changing ./public to /public