Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any charting library in elixir?

I want to plot a bar graph in elixir and save it as an image.

Is there any good charting library for doing this ?

I tried searching on elixir.libhunt.com and github.com/h4cc/awesome-elixir, but didn't find a single package for my need.

Thanks in advance.

like image 722
vinzee93 Avatar asked Dec 07 '16 04:12

vinzee93


2 Answers

Yes - you can interface to gnuplot with gnuplot-elixir

As as example, to generate the bar graph in this answer - the code would be:

import Gnuplot

chart = [
      [:set, :term, :png, :size, '512,512'],
      [:set, :output, Path.join("/tmp", "barchart.PNG")],
      [:set, :boxwidth, 0.5],
      ~w(set style fill solid)a,
      [:plot, "-", :using, '1:3:xtic(2)', :with, :boxes]
    ]

dataset = [[0, "label", 100], [1, "label2", 450], [2, "bar label", 75]]

plot(chart, [dataset])

like image 149
devstopfix Avatar answered Nov 18 '22 16:11

devstopfix


I don't think there's any such control for Elixir--nothing native anyway. Graphics is not exactly in Elixir's wheelhouse. However, I think you could probably build something yourself with wxErlang. You can see what sorts of things you can do with wxErlang in Elixir by typing :wx.demo() from within iex. I don't know of a graph primitive in wxErlang but it may be that I simply haven't found it yet.

like image 24
Onorio Catenacci Avatar answered Nov 18 '22 18:11

Onorio Catenacci