c# - MVC Chart just displaying text stream -


i trying put sort of dashboarding mvc application , cannot render chart correctly. seems display byte-stream rather image.

on main index page have button post controller acquire data (sample data in example) , update results section.

datapoint.cs

public class datapoint {     public datetime datemark { get; set; }     public int count { get; set; } } 

index.cshtml

@model ienumerable<charttest.models.datapoint>  @using (ajax.beginform("generate", new ajaxoptions() { insertionmode = insertionmode.replace, updatetargetid = "results" })) {     @html.antiforgerytoken()      <div class="form-horizontal">         <div class="panel-group">             <div class="panel panel-danger">                 <div class="panel-heading" style="background-color: #80929c; color: #f6e0c7">                     <div class="row">                          <!-- stuff user request information removed -->                          <div class="col-xs-12 col-sm-1">                             <div class="row">                                 <div class="col-sm-12" style="vertical-align: bottom">                                     <input type="submit" value="generate" class="btn btn-danger pull-right" />                                 </div>                             </div>                         </div>                     </div>                 </div>             </div>         </div>          <div class="panel-group" style="background-color: transparent; border: none; margin-top: 20px">             <div class="panel panel-danger" style="background-color: transparent; border: none">                 <div class="panel-heading" style="background-color: #80929c; color: #f6e0c7">                      <div id="results">  <!-- results placed here when button pressed -->                      </div>                 </div>             </div>         </div>     </div> } 

chart.cshtml

@model ienumerable<charttest.models.datapoint>  @{     var key = new chart(width: 600, height: 400)                       .addtitle("my data")                       .addseries("default",                                  xvalue: model, xfield: "datemark",                                  yvalues: model, yfields: "count")                       .write(); } 

homecontroller.cs

public class homecontroller : controller {     public actionresult index()     {         return view();     }      public actionresult generate()     {         list<models.datapoint> results = new list<models.datapoint>();          //         // go data here , add `results` list         //          return partialview("chart", results);     } } 

here's gets rendered

enter image description here

the issue chart not part of mvc web pages. won't merge chart writing raw image data view.

this article scott mitchell gives guide on how integrate web pages elements mvc project.

you have wrap chart view inside action, insert view containing image tag

<img src="@url.action("getchart")" /> 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -