Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line chart generated image that will be sent through email

I want to create a line chart similar below:

Line Chart

I just wonder if there are available framework or API available in ASP.NET MVC that generates chart images since my goal is to send this via email. I'm thinking if I can just put something like <img src="http://imageapi.com?date1=20170101&date=20170130" /> then api will be handling the chart image generation.

On searching, I found a lot of chart framework using javascript but I doubt it will properly work on different email clients.

Thanks a lot!

like image 637
Sherwin Avatar asked Feb 24 '17 06:02

Sherwin


2 Answers

Google Image Charts will do that. Pass data and display settings via the URL, and it will return an image.

eg.

<img src="https://chart.googleapis.com/chart?cht=lc&chd=t:30,10,45,38,25|10,20,10,20,10&chls=2.0,0.0,0.0&chs=200x125&chg=0,20,3,3,10,20&chxt=x,y&chxl=0:|Week1|Week2|Week3|Week4|Week5|1:|0|20|40|60|80|100&chs=800x300&chm=o,ff9900,0,-1,10.0|d,ff0000,1,-1,10.0&chco=FFC6A5,DEBDDE&chdl=Click|GRU" />

produces this chart:

They provide a playground for testing: https://developers.google.com/chart/image/docs/chart_playground

Note however that Google are not maintaining it further, but have no plans to remove this functionality:

While the dynamic and interactive Google Charts are actively maintained, we officially deprecated the static Google Image Charts way back in 2012. This gives us the right to turn it off without notice, although we have no plans to do so.

like image 63
K Scandrett Avatar answered Oct 22 '22 07:10

K Scandrett


What is your design ? Your chart must be generated in web page,then it must be having html generated. If no html is generated and only image is generated then this is best. now you can send same content in.

If image is not generated then again you have 2 option here i) Send complete html in email body along with concern js/css ii) you can convert those html into image using(say c#) then send mail.

Please mention your complete scenario.

like image 22
KumarHarsh Avatar answered Oct 22 '22 06:10

KumarHarsh