Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a C-callable library that can generate PNG from raw data?

I want to visualize a table of stock-price data as candlesticks; and as trend lines.

I'm looking for a C-callable library that will take as input raw price data and come out with a graphic file -- a picture -- that I can store someplace and then name in the HTML page that my CGI generates.

I suppose that there are many candidates. I find only three possibilities so far this morning:

  1. the boost graphics interface language
  2. imagemagick
  3. gnuplot
  4. I can also imagine drawing directly on the HTML5 canvas. I know less than nothing about that approach.

Can you recommend an approach/library that's straightforward, flexible, rich, and powerful?

like image 275
Pete Wilson Avatar asked Jan 17 '12 13:01

Pete Wilson


1 Answers

The GD library is useful for creating dynamic PNGs.

It is written in C, has good language bindings for PHP, Perl and many other languages, and there are some command line tools for shell programming.

See this question for C programming with GD:

Looking for GD tutorial in C/C++

A Perl library on top of GD that does what you want is here:

https://metacpan.org/pod/GD::Graph::candlesticks

The code sample in there is easy to read, even if you haven't tried perl yet. Then use it as a plain old CGI Script. Or try something more fancy.

Examples:

Candlestick

Trendline

like image 97
knb Avatar answered Sep 18 '22 22:09

knb