Using Microsoft Chart Control in ASP.NET MVC Returns a Blank Image -


using answer generating image controller this post, created controller action return chart image seen below (the x , y values there test data):

    public filecontentresult historychart()     {         chart chart = new chart();         string[] currencies = { "zar", "usd", "gbp", "jpy" };          foreach (string currency in currencies)         {             series series = new series(currency);             series.charttype = seriescharttype.fastline;             (int x = 0; x <= 30; x++)                 series.points.addxy(x, (x * 5));             chart.series.add(series);         }          using (memorystream ms = new memorystream())         {             chart.saveimage(ms, chartimageformat.png);             ms.seek(0, seekorigin.begin);              return file(ms.toarray(), "image/png", "mychart.png");         }     } 

the problem is, image controller returns blank (although return image)

im hoping simple have left out! input appreciated, thanks.

hope helps.....

i've had same problem:

it's colors, added code yours after having used example blog , deduced issue - 'thanks' everyone....

    public filecontentresult historychart()     {         chart chart = new chart();         **chart.backcolor = color.transparent;**          string[] currencies = { "zar", "usd", "gbp", "jpy" };          foreach (string currency in currencies)         {             series series = new series(currency);             series.charttype = seriescharttype.fastline;             (int x = 0; x <= 30; x++)                 series.points.addxy(x, (x * 5));             chart.series.add(series);         }          **chartarea ca1 = new chartarea("ca1");         ca1.backcolor = color.cyan;         chart.chartareas.add(ca1);**          using (memorystream ms = new memorystream())         {             chart.saveimage(ms, chartimageformat.png);             ms.seek(0, seekorigin.begin);              return file(ms.toarray(), "image/png", "mychart.png");         }     }  

also, need ensure controller has:

using system.drawing; using system.web.ui.webcontrols;

cheers all...

jk.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -