So I was trying out the Chart helpers in the System.Web.Helpers namespace.
I make the chart in a .cshtml view but I wanted to keep it in the ViewModel instead.
No problem except for when I'm trying to render it as a smaller image in the website.
I thought the cleanest solution would be to create one shared partial view to render graphs from models
@model System.Web.Helpers.Chart @Model.Write()
And then render this partial view somehow in the proper websites. I tried a few versions but can't seem to get it to work.
<div> <h2>Some header above a graph</h2> <img src="@Html.Partial("_graph", Model.TheChart)" /> </div>
This doesn't work and I'm not certain how to do this. Only think I can think of now is making all models with charts inherit an Interface that exposes Chart and let that be the model for _graph.cshtml.
<img src="_graph.cshtml" />
But not sure if the this uses the Model.