I\'m attempting to build a stock chart using Microsoft\'s charting library.
I\'m using this code to create the chart in my view:
@{
System.Web.H
I was able to work around this issue by building the chart myself, bypassing the helper.
using (Chart chart = new Chart())
{
chart.Width = 600;
chart.Height = 400;
chart.RenderType = RenderType.BinaryStreaming;
chart.Palette = ChartColorPalette.Bright;
chart.ChartAreas.Add("Top");
chart.ChartAreas.Add("Bottom");
chart.Series.Add("Price");
chart.Series.Add("Volume");
chart.Series["Price"].ChartArea = "Top";
chart.Series["Volume"].ChartArea = "Bottom";
chart.Series["Price"].ChartType = SeriesChartType.Stock;
chart.Series["Volume"].ChartType = SeriesChartType.Column;
for (int x = 0; x < data.Quotes.Count / 2; x++)
{
Quote quote = data.Quotes[x];
chart.Series["Price"].Points.AddXY(quote.Date, quote.Open, quote.High, quote.Low, quote.Close);
chart.Series["Volume"].Points.AddXY(quote.Date, quote.Volume);
}
using (MemoryStream memStream = new MemoryStream())
{
chart.SaveImage(memStream, ChartImageFormat.Jpeg);
return File(memStream.ToArray(), "image/jpeg");
}
}
This code is in my controller, and no view exists for it, because it is returning an actual image resource.