create account

Programming My Own Trading Chart - Part 29 - Picture Perfect by leoplaw

View this thread on: hive.blogpeakd.comecency.com
· @leoplaw · (edited)
$3.71
Programming My Own Trading Chart - Part 29 - Picture Perfect
![TradeX-chart image export](https://files.peakd.com/file/peakd-hive/leoplaw/23tGRcb11JruswWWUGAELvfqkRtSrYNfGqnKFvMH5R1DBCYn4WjG1uECanc24dYsMuzkQ.png)

With a project this size, one thing always leads to another. There are so many rabbit holes to lose oneself in.

I started the research for implementing pixel perfect hit detection for the chart, as currently the calculations are prone to rounding errors which add up over many iterations, ultimately creating a sub optimal user experience.

The chart already has an extremely flexible multi-layered canvas class. The task is now to work hit detection layers into this. But more on that topic for another post. What this led to, was me finally implementing a chart image snapshot export; something I'd been putting off for a long time.

In theory it should be straight forward, because, that chart already has all of the layers for each chart component, all I needed to do was composite them together on a larger canvas, and then pass that to the code that would turn that into a format the browser could work with as a download.

In practice it was straight forward! Which left me wondering why I avoided it for so long.

So now it is as simple as ``chart.downloadImage()`` to save a ``.png`` image file to your local storage.

There is also a related ``toImageURL()`` call that then can be passed to other HTML elements as an image source, or passed on to other API calls.

The chart's development progress is accelerating now, because so many of the fundamentals are now in place, which means I'm starting to fill i the gaps, rather than working on the foundations.

In the coming posts, I'll fill you in on the big leap forward that is coming.

Available on GitHub and NPM

GitHub
https://github.com/tradex-app/TradeX-chart

NPM
https://www.npmjs.com/package/tradex-chart

Documentation - WIP
https://tradex-chart.guildmedia.net/reference/api-examples/#download-image
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorleoplaw
permlinkprogramming-my-own-trading-chart-part-29-picture-perfect
categoryhive-169321
json_metadata{"app":"peakd/2023.7.1","format":"markdown","tags":["programming","development","javascript","trading","crypto"],"users":[],"image":["https://files.peakd.com/file/peakd-hive/leoplaw/23tGRcb11JruswWWUGAELvfqkRtSrYNfGqnKFvMH5R1DBCYn4WjG1uECanc24dYsMuzkQ.png"]}
created2023-08-08 20:21:06
last_update2023-08-09 08:36:45
depth0
children1
last_payout2023-08-15 20:21:06
cashout_time1969-12-31 23:59:59
total_payout_value1.840 HBD
curator_payout_value1.868 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,925
author_reputation189,628,210,789,149
root_title"Programming My Own Trading Chart - Part 29 - Picture Perfect"
beneficiaries
0.
accounthive-169321
weight200
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id126,067,373
net_rshares8,134,554,284,585
author_curate_reward""
vote details (62)
@hivebuzz ·
Congratulations @leoplaw! You received a personal badge!

<table><tr><td>https://images.hive.blog/70x70/http://hivebuzz.me/badges/birthday-7.png</td><td>Happy Hive Birthday! You are on the Hive blockchain for 7 years!</td></tr></table>

<sub>_You can view your badges on [your board](https://hivebuzz.me/@leoplaw) and compare yourself to others in the [Ranking](https://hivebuzz.me/ranking)_</sub>


**Check out our last posts:**
<table><tr><td><a href="/hive-102201/@hivebuzz/wc2023-recap-day19"><img src="https://images.hive.blog/64x128/https://files.peakd.com/file/peakd-hive/hivebuzz/48kBuTQSRzzteFSojBm1d421vrXMUPHxq7Z9WdpwpNn3E59JAC8rn6ViEafBFPvgkJ.png"></a></td><td><a href="/hive-102201/@hivebuzz/wc2023-recap-day19">Women's World Cup Contest - Round of 16 - Recap of Day 4</a></td></tr><tr><td><a href="/hive-102201/@hivebuzz/wc2023-recap-day18"><img src="https://images.hive.blog/64x128/https://files.peakd.com/file/peakd-hive/hivebuzz/48Un9NAH7ZfZnA9knFJEpZP535q8FcWMEcDkbL9RGeKkRETzuZYYduq2hqyVUwGWfT.png"></a></td><td><a href="/hive-102201/@hivebuzz/wc2023-recap-day18">Women's World Cup Contest - Round of 16 - Recap of Day 3</a></td></tr><tr><td><a href="/hive-102201/@hivebuzz/wc2023-recap-day17"><img src="https://images.hive.blog/64x128/https://files.peakd.com/file/peakd-hive/hivebuzz/48TozstqJfBJAmxL9tcSzUVfRpM7MJ9zhx4efy5S343UMDsA7Sc2oJopDLZ1f7X1LR.png"></a></td><td><a href="/hive-102201/@hivebuzz/wc2023-recap-day17">Women's World Cup Contest - Round of 16 - Recap of Day 2</a></td></tr></table>
properties (22)
authorhivebuzz
permlinknotify-leoplaw-20230810t080522
categoryhive-169321
json_metadata{"image":["http://hivebuzz.me/notify.t6.png"]}
created2023-08-10 08:05:21
last_update2023-08-10 08:05:21
depth1
children0
last_payout2023-08-17 08:05:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,519
author_reputation370,708,462,589,164
root_title"Programming My Own Trading Chart - Part 29 - Picture Perfect"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id126,116,699
net_rshares0