czetsuya
czetsuya

Reputation: 5063

How to write an mvc chart into a view

First, I've already tried showing a graph using a FileContentResult and the write method. But I can't use both since my requirement requires me to show a grid on 1 tab and a graph on the next tab. So I need to store the graph in a ViewBag and render it to a view, but I'm unable to do that. Is there anyway around?

Note: I'm using the Chart object from System.Web.Helpers namespace.

Thanks,
czetsuya

Upvotes: 1

Views: 2061

Answers (4)

czetsuya
czetsuya

Reputation: 5063

I found a solution (without executing the same query), I stored the image in a cache and later refer to it via a unique key. Unfortunately, I needed to issue another http request for it. See post here: http://czetsuya-tech.blogspot.com/2012/02/how-to-render-chart-object-in-view-in.html

Upvotes: 0

jgauffin
jgauffin

Reputation: 101150

A chart is just an image. Link to it.

<img src="@Html.Action("ImageAction")" alt="Chart" />

Upvotes: 0

Yorgo
Yorgo

Reputation: 2678

you can use System.Web.Helpers namespace here an example:

http://msdn.microsoft.com/en-us/library/system.web.helpers.chart(v=vs.99).aspx

Upvotes: 0

x2.
x2.

Reputation: 9668

You can render chart as partial view.

Upvotes: 1

Related Questions