title: Showing System.Web.Helpers.Chart in a partial view from the model
body: <p>So I was trying out the Chart helpers in the System.Web.Helpers namespace.</p>
  
  <p>according to <a href="http://www.asp.net/web-pages/tutorials/data/7-displaying-data-in-a-chart" rel="nofollow">http://www.asp.net/web-pages/tutorials/data/7-displaying-data-in-a-chart</a></p>
  
  <p>I make the chart in a .cshtml view but I wanted to keep it in the ViewModel instead.</p>
  
  <p>No problem except for when I'm trying to render it as a smaller image in the website.</p>
  
  <p>I thought the cleanest solution would be to create one shared partial view to render graphs from models</p>
  
  <p>_graph.cshtml</p>
  
  <pre><code>@model System.Web.Helpers.Chart
  
  @Model.Write()
  </code></pre>
  
  <p>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.</p>
  
  <p>Website.cshtml</p>
  
  <pre><code>&lt;div&gt;
      &lt;h2&gt;Some header above a graph&lt;/h2&gt;
      &lt;img src="@Html.Partial("_graph", Model.TheChart)" /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>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.</p>
  
  <pre><code>&lt;img src="_graph.cshtml" /&gt;
  </code></pre>
  
  <p>But not sure if the this uses the Model.</p>
  
  <p>Any opinions?</p>