asp.net mvc 4 - Make chart using model -


a have following model

using system; using system.collections.generic; using system.componentmodel.dataannotations; using system.linq; using system.web;  namespace goonwork.models {     public class skill     {         [key]         public int id { get; set; }          public datetime addedon { get; set; }          public datetime modifiedon { get; set; }          public int? descriptionid { get; set; }          public virtual description descriptions { get; set; }          public int? levelid { get; set; }          public virtual level levels { get; set; }          public string userid { get; set; }          public virtual applicationuser user { get; set; }      } } 

and want create chart level (xfields) , description (yfields) skill model. fields description , level connected other tables. have chart view model

using system; using system.collections.generic; using system.linq; using system.web; using system.web.helpers;  namespace goonwork.models {     public class chartviewmodel     {         public chart chart { get; set; }     } }  

i write controller based on view model.

public class chartcontroller : controller     {         applicationdbcontext db = new applicationdbcontext();         // get: chart         public actionresult index()         {             var model = new chartviewmodel             {                 chart = getchart()             };             return view(model);         }         private chart getchart()         {             var user = user.identity.getusername();             var data = db.skills.where(x => x.user.username == user);             return new chart(600, 400, charttheme.blue)                 .addtitle("skills")                 .addlegend()                 .databindtable(data, "levelname")                 .addseries(                     "default",                     charttype: "bar",                     xvalue: data, xfield: "levelname",                     yvalues: data, yfields: "descriptionname"                     );         }     } 

and view of index()

@model goonwork.models.chartviewmodel @{     layout = null; } <!doctype html> <html> <head>     <meta name="viewport" content="width=device-width" />     <title>index</title> </head> <body>     <h2>our awesome chart!</h2>     @model.chart.write(format: "png") </body> </html> 

the problem don't know how create chart fields. or how modify getchart() function work properly. if can me, better.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -