Alternative to embeding TradingView coin price charts on HollaEx

I have an exchange built with HollaEx and got my token listed and everything is going well so far. I am currently working on a home page using wordpress separately for my project and would like to embed a chart for my token to the wordpress site. I need it to display the price of the token over the last 90 days. I played with tradingview but it seems too complicated and unnecessary for this. Is there any other way I can embed and/or share simpler charts without getting into major engineering?

1 Like

I made a simple embedded chart script in vanilla JS and html. It is using chartjs library and it should be easy to drop it as html to your wordpress. Just make sure chart.js and moment scripts are added like how I added them in the <head> tag.

The code gets the chart data for BTC/USDT from the HollaEx API (in your case I believe you should change the URL and the market to your token) between now and 90 days ago with daily resolution. It then populates the data in chartjs. Hope it helps!

<html>
<head>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"> </script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js"></script>
</head>
<body>
	<canvas id="myChart" style="width:100%;max-width:700px"></canvas>

	<script>

		(async() => {
			const days = 90;

			const response = await fetch(`https://api.hollaex.com/v2/chart?symbol=btc-usdt&resolution=1D&from=${moment().subtract(days, 'days').unix()}&to=${moment().unix()}`);

			// Storing data in form of JSON
			var data = await response.json();
			console.log(data);

			let xValues = [];
			let yValues = [];


			data.forEach(d => {
				xValues.push(moment(d.time).format('MMM-DD'));
				yValues.push(d.close);
			});

			console.log(xValues)
			console.log(yValues)

			var myChart = new Chart('myChart', {
				type: 'line',
				data: {
					labels: xValues,
					datasets: [{
						fill: false,
						borderColor: "rgba(255,0,0,0.5)",
						data: yValues
					}]
				}
			});

		})()


	</script>
</body>
</html>```
4 Likes

Created HTML file and tested it (see above), it is what Iā€™m looking for!

3 Likes