asp.net mvc - highcharts not working properly -


i want make highchart http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/line-labels/ have stored procedure count room type reserved every month (january :double 2,triple 4..) need transmit parameter stored procedure in roomtypereservations.roomtypebydate(i); when 1 data january, 2 data february......

  public actionresult gresit()     {    dbcontext.current.open();    list<series> allseries = new list<series>();   list<roomtypereservations> rezervari = new list<roomtypereservations>();   (int =1; < 13; i++)   {       rezervari = roomtypereservations.roomtypebydate(i);       var results = new object[4];        foreach (var in rezervari)       {           results = (new object[] { a.numrezervari });            allseries.add(new series       {           name = a.room_type,      //data = new data(mydata)           data = new data(results.toarray())        });       }   };         highcharts charts = new highcharts("chart")           .initchart(new chart { defaultseriestype = charttypes.spline, })           .settitle(new title { text = "gradul de ocupare pe luni" })           .setxaxis(new xaxis { categories = reservation.categories })           .setyaxis(new yaxis           {               title = new yaxistitle { text = "numarul de camere" },               labels = new yaxislabels { step = 5, formatter = "function() { return this.value}" }            })           .settooltip(new tooltip           {               crosshairs = new crosshairs(true),               shared = true           })           .setplotoptions(new plotoptions           {               spline = new plotoptionsspline               {                   marker = new plotoptionsseriesmarker                   {                       radius = 4,                       linecolor = colortranslator.fromhtml("#666666"),                       linewidth = 1                   }               }           })           .setseries(allseries.select(s => new series { name = s.name, data = s.data }).toarray());        return view(charts);      } 

but doing wrong because this: data showed january. doing wrong? enter image description here

that because looping through , creating series each data point. need take allseries.add statement out of foreach structure. try using below modified structure:

for (int =1; < 13; i++) {   rezervari = roomtypereservations.roomtypebydate(i);   var results = new list<object>();    foreach (var in rezervari)   {     results.add(a.numrezervari);   }    allseries.add(new series   {     name = a.room_type,     data = new data(results.toarray())   }); } 

by looks of creating 12 different series.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -