asp.net mvc 3 areas - HighCharts -- MVC 3 Database -


i working dotnet.highcharts in visual studio 2010. creating mvc 3 web application. able highcharts working statically assigning data. able send data database highcharts displaying.

can create class control data , send class highcharts? if so, can tell me how this? also, if has working project demonstrates , willing share awesome.

i saw posted below class in question. however, don't know how use or send class highcharts script. appreciated.

class highchartspoint {     public double x {set; get;}     public double y {set; get;}     public string color {set; get;}     public string id {set; get;}     public string name {set; get;}     public bool sliced {set; get;} }  

edit

well, building web application display information data collected solar monitoring. power, voltage, current, , etc grouped combiner, inverter, , etc. believe x , y data. however, if simpler code via array of object, it. hope answered question. below model classes have data. not done them. still need add validation , change fields link other tables. link combiner_id field in power_string class id field in power_combiner class use: public virtual power_combiner combiner_id { get; set; }

public class aessmartentities : dbcontext {     public dbset<power_combiner> powercombiners { get; set; }     public dbset<power_combinerhistory> powercombinerhistorys { get; set; }     public dbset<power_coordinator> powercoordinators { get; set; }     public dbset<power_installation> powerinstallations { get; set; }     public dbset<power_inverter> powerinverters { get; set; }     public dbset<power_string> powerstrings { get; set; }     public dbset<power_stringhistory> powerstringhistorys { get; set; } }  public class power_combiner {     [scaffoldcolumn(false)]     public int id { get; set; }      [required]     [displayname("name")]     [stringlength(128, errormessage = "the 'name' cannot longer 128 characters")]     public string name { get; set; }      [required]     [displayname("mac address")]     [stringlength(24, errormessage = "the 'mac' cannot longer 24 characters")]     public string mac { get; set; }      [displayname("location")]     [stringlength(512, errormessage = "the 'name' cannot longer 512 characters")]     public string location { get; set; }      [displayname("power_installation")]     public int? installation_id { get; set; }      [displayname("power_inverter")]     public int? inverter_id { get; set; }      [displayname("power_coordinator")]     public int coordinator_id { get; set; }      [displayname("installation id")]     public virtual power_installation installation_ { get; set; }      [displayname("inverter id")]     public virtual power_inverter inverter_ { get; set; }      [displayname("coordinator id")]     public virtual power_coordinator coordinator_ { get; set; } }  public class power_combinerhistory {     [scaffoldcolumn(false)]     public int id { get; set; }      [required]     [displayname("voltage")]     public double voltage { get; set; }      [required]     [displayname("current")]     public double current { get; set; }      [required]     [displayname("temperature")]     public double temperature { get; set; }      [required]     [displayname("datetime")]     public datetime recordtime { get; set; }      [required]     [displayname("power_combiner")]     public int combiner_id { get; set; }      [displayname("combiner id")]     public virtual power_combiner combiner_ { get; set; } }  public class power_coordinator {     [scaffoldcolumn(false)]     public int id { get; set; }      [required]     [displayname("mac address")]     [stringlength(24, errormessage = "the 'mac' cannot longer 24 characters")]     public string mac { get; set; }      [required]     [displayname("report time")]     public datetime reporttime { get; set; }      [required]     [displayname("command")]     [stringlength(2, errormessage = "the 'command' cannot longer 2 characters")]     public string command { get; set; }      [required]     [displayname("collect time")]     public int collect_time { get; set; }      [required]     [displayname("interval time")]     public int interval_time { get; set; }      [displayname("power_installation")]     public int? installation_id { get; set; }      [displayname("installation id")]     public virtual power_installation installation_ { get; set; } }  public class power_installation {     [scaffoldcolumn(false)]     public int id { get; set; }      [required]     [displayname("name")]     [stringlength(128, errormessage = "the 'name' cannot longer 128 characters")]     public string name { get; set; }      [required]     [displayname("uuid")]     [stringlength(36, errormessage = "the 'uuid' cannot longer 36 characters")]     public string uuid { get; set; }      [displayname("description")]     [stringlength(512, errormessage = "the 'description' cannot longer 512 characters")]     public string description { get; set; }      [displayname("history time")]     public int historytime { get; set; } }  public class power_inverter {     [scaffoldcolumn(false)]     public int id { get; set; }      [required]     [displayname("name")]     [stringlength(128, errormessage = "the 'name' cannot longer 128 characters")]     public string name { get; set; }      [required]     [displayname("uuid")]     [stringlength(36, errormessage = "the 'uuid' cannot longer 36 characters")]     public string uuid { get; set; }      [required]     [displayname("location")]     [stringlength(512, errormessage = "the 'location' cannot longer 512 characters")]     public string location { get; set; }      [displayname("power_installation")]     public int installation_id { get; set; }      [displayname("power_coordinator")]     public int coordinator_id { get; set; }      [displayname("installation id")]     public virtual power_installation installation_ { get; set; }      [displayname("coordinator id")]     public virtual power_coordinator coordinator_ { get; set; } }  public class power_string {     [scaffoldcolumn(false)]     public int id { get; set; }      [required]     [displayname("uuid")]     [stringlength(36, errormessage = "the 'uuid' cannot longer 36 characters")]     public string uuid { get; set; }      [required]     [displayname("position")]     public int position { get; set; }      [displayname("name")]     [stringlength(128, errormessage = "the 'name' cannot longer 128 characters")]     public string name { get; set; }      [displayname("location")]     [stringlength(512, errormessage = "the 'location' cannot longer 512 characters")]     public string location { get; set; }      [required]     [displayname("power_combiner")]     public int combiner_id { get; set; }      [displayname("combiner id")]     public virtual power_combiner combiner_ { get; set; } }  public class power_stringhistory {     [scaffoldcolumn(false)]     public int id { get; set; }      [required]     [displayname("current")]     public double current { get; set; }      [required]     [displayname("record time")]     public datetime recordtime { get; set; }      [required]     [displayname("power_string")]     public int string_id { get; set; }      [displayname("string id")]     public virtual power_string string_ { get; set; } } 

edit

the below code have. having problems conversion of date. gettotalmilliseconds not exist in current context. coming highcharts scripts or other namespace need include? also, using data context correctly assign data chart? changed x value combiner id:

.setseries(new[] {     new series     {         name = "combiner",         yaxis = 0,         data = new data(powercombinerhistorys.select(mm => new point { x = mm.combiner_id,  y = mm.current}).toarray())     } }); 

and still error. error is: unable cast type 'system.int32' type 'dotnet.highcharts.helpers.number'. linq entities supports casting entity data model primitive types.

using system; using system.collections.generic; using system.linq; using system.web; using system.web.mvc; using system.drawing; using dotnet.highcharts; using dotnet.highcharts.enums; using dotnet.highcharts.helpers; using dotnet.highcharts.options; using point = dotnet.highcharts.options.point; using aessmart.models; using system.data; using system.data.entity;  namespace aessmart.controllers {     public class highchartstestcontroller : controller     {         private aessmartentities db = new aessmartentities();          public actionresult combinerhistorydata()         {             var powercombinerhistorys = db.powercombinerhistorys.include(p => p.combiner_);              highcharts chart = new highcharts("chart")             .initchart(new chart { defaultseriestype = charttypes.column })             .settitle(new title { text = "combiner history" })             .setxaxis(new xaxis { type = axistypes.datetime })             .setyaxis(new yaxis             {                 min = 0,                 title = new yaxistitle { text = "current" }             })             .setseries(new[]                        {                            new series                            {                                name = "combiner",                                yaxis = 0,                                data = new data(powercombinerhistorys.select(x => new point { x = gettotalmilliseconds(x.recordtime),  y = x.current}).toarray())                            }                        });              return view(chart);         }     } } 

as understand need chart display values (temperature, voltage, current, etc.). see in model have recordtime can xaxis. here example code:

highcharts chart = new highcharts("chart")             .initchart(new chart { defaultseriestype = charttypes.line })             .settitle(new title { text = "combiner history" })             .setxaxis(new xaxis { type = axistypes.datetime })             .setyaxis(new[]                       {                           new yaxis                           {                               title = new yaxistitle { text = "current" },                               gridlinewidth = 1                           },                           new yaxis                           {                               labels = new yaxislabels { formatter = "function() { return this.value +'°c'; }", },                               title = new yaxistitle { text = "temperature" },                               opposite = true,                               gridlinewidth = 0                           },                           new yaxis                           {                               labels = new yaxislabels { formatter = "function() { return this.value +' v'; }" },                               title = new yaxistitle { text = "voltage" },                               opposite = true,                               gridlinewidth = 0                           }                       })             .setseries(new[]                        {                            new series                            {                                name = "current",                                yaxis = 0,                                data = new data(history.select(x => new point { x = gettotalmilliseconds(x.recordtime), y = x.current}).toarray())                            },                            new series                            {                                name = "temperature",                                yaxis = 1,                                data = new data(history.select(x => new point { x = gettotalmilliseconds(x.recordtime), y = x.temperature}).toarray())                            },                            new series                            {                                name = "voltage",                                yaxis = 2,                                data = new data(history.select(x => new point { x = gettotalmilliseconds(x.recordtime), y = x.voltage}).toarray())                            }                        }); 

and result following diagram: enter image description here

the second chart can interesting column diagram compare current values 2 measurements recorded time. here example code:

highcharts chart = new highcharts("chart")             .initchart(new chart { defaultseriestype = charttypes.column })             .settitle(new title { text = "combiner history" })             .setxaxis(new xaxis { type = axistypes.datetime })             .setyaxis(new yaxis             {                 min = 0,                 title = new yaxistitle { text = "current" }             })             .setseries(new[]                        {                            new series                            {                                name = "combiner",                                yaxis = 0,                                data = new data(combinerhistories.select(x => new point { x = gettotalmilliseconds(x.recordtime), y = x.current}).toarray())                            },                            new series                            {                                name = "string",                                yaxis = 0,                                data = new data(stringhistories.select(x => new point { x = gettotalmilliseconds(x.recordtime), y = x.current}).toarray())                            }                        }); 

and here chart on page: enter image description here

i hope helpful you.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -