If you have not yet done so, you can create a chart embed here.
There are two types of chart embeds: iframe and Web Component
iframe
Iframe code can be placed anywhere in your HTML code with no additional scripts.
You can style the iframe with CSS just like any other HTML element.
Example:
A Web Component is a new web technology to create reusable custom elements with their functionality encapsulated away from the rest of your code.
For the Chart Web Component, you can modify any property on the element to have it update in real-time. You can also listen to the onUpdate event to get price information as the chart updates.
<body><!-- Example of a button that a user can click to change the type of the chart dynamically --> <buttonclass="theme-btn"style="margin-bottom: 1rem;">Change Chart Type</button> <divstyle="max-width: 1000px; height: 600px"> <chart-embedchain="bsc"address="0xB09FE1613fE03E7361319d2a43eDc17422f36B09"charttype="candles"theme="dark" ></chart-embed> </div> <scriptasynctype="module">//load script and register chartimport { register } from"https://public.bog-general-api.com/static/chart/main.js";register("chart-embed");//query HTML elementsconstbutton=document.querySelector(".theme-btn")constembed=document.querySelector("chart-embed")//setup listener to change chart propsbutton.onclick= ()=>{consttype=embed.getAttribute("charttype");if(type ==='candles'){embed.setAttribute("charttype","line") }else{embed.setAttribute("charttype","candles") } } </script> </body>
Listening To Chart Update
<body><!-- Chart Container--> <divclass="chart-container"style="max-width: 1000px; height: 600px"> <chart-embedchain="bsc"address="0xB09FE1613fE03E7361319d2a43eDc17422f36B09"charttype="candles"theme="dark" ></chart-embed> </div><!-- Info Panel --> <divclass="info-panel"></div> <scriptasynctype="module">//load script and register chartimport { register } from"https://public.bog-general-api.com/static/chart/main.js";register("chart-embed");constinfoPanel=document.querySelector(".info-panel")constembed=document.querySelector("chart-embed")embed.addEventListener("onUpdate",(e)=>{//get update info from the eventconstupdateInfo=e.detail[0];//combine object into string of htmlconsthtml=Object.entries(updateInfo).reduce( (acc,[key,value]) => acc +`<div><span>${key}</span>: ${value}</div>`,"")//set to info panelinfoPanel.innerHTML = html }) </script> </body>