JeniseM

Members
  • Content count

    4
  • Joined

  • Last visited

About JeniseM

  • Rank
    Forum Newbie

Recent Profile Visitors

2,408 profile views
  1. I'm trying to create a stacked chart with from a database into a JSON Append object and am having some trouble. I have a set a weeks to display on the X axis. The Y axis will display a number of Hours per status. This is my first chart with a JSON object within MVC and instead of getting an error message, the screen just shows "Charts...." text. I believe my issue is mainly within my foreach loop through the status. I also need to implement the passing of the week along with the status so that I am getting the "Hours" for that status and week. Please let me know if you have any questions. I have all my code in page for now. Thank You!! --------------------------------------------------------------- public class WOWeekData { //public int lworkweekcode { get; set; } public DateTime WkDate { get; set; } } public class WOHrsData { //public int WOStatusID { get; set; } //public int lworkweekcode { get; set; } public string WOStatus { get; set; } public int WkHrs { get; set; } public DateTime WkDate { get; set; } } public class HomeController : Controller { List<WOWeekData> wdata_list = new List<WOWeekData>(); List<WOHrsData> hdata_list = new List<WOHrsData>(); public string createChart() { string dat = getData(); Chart cc = new Chart("stackedcolumn3d", "mychart", "750", "550", "json", dat); return cc.Render(); } public string getData() { List<DateTime> WOWkDate2_list = new List<DateTime>(); List<string> WOStatus_list = new List<string>(); List<int> WOWkHrs_list = new List<int>(); List<DateTime> WOWkDate_list = new List<DateTime>(); string db= ConfigurationManager.ConnectionStrings["string"].ConnectionString; SqlConnection con = new SqlConnection(); con.ConnectionString = db; con.Open(); SqlCommand com = new SqlCommand("Select distinct(WkDate) from v_SampleData2", con); SqlDataReader sda = com.ExecuteReader(); while (sda.Read()) { WOWeekData wod = new WOWeekData(); wod.WkDate = DateTime.Parse(sda[0].ToString()); //wod.W = Int32.Parse(sda[1].ToString()); //wod.P = Int32.Parse(sda[2].ToString()); //wod.H = Int32.Parse(sda[3].ToString()); wdata_list.Add(wod); } foreach (WOWeekData w in wdata_list) { WOWkDate_list.Add(w.WkDate); } sda.Close(); SqlCommand com2 = new SqlCommand("Select * from v_SampleData2", con); SqlDataReader sda2 = com2.ExecuteReader(); while (sda2.Read()) { WOHrsData hrs = new WOHrsData(); hrs.WOStatus = sda2[1].ToString(); hrs.WkHrs = Int32.Parse(sda2[2].ToString()); hrs.WkDate = DateTime.Parse(sda2[0].ToString()); hdata_list.Add(hrs); } foreach (WOHrsData h in hdata_list) { //WOWk.Add(h.WkDate); WOStatus_list.Add(h.WOStatus); WOWkHrs_list.Add(h.WkHrs); WOWkDate2_list.Add(h.WkDate); } sda2.Close(); con.Close(); con.Dispose(); //building JSON String StringBuilder JSON = new StringBuilder(); JSON.Append("{" + "'chart': {" + "'caption': 'One Chart Per Department'," + // "'exportEnabled':'1'," + "'xAxisname': 'Weeks'," + "'yAxisName': 'Hours'," + " }," ); //appenfing into StringBuilder objectiterating through collections JSON.Append("'categories': [{" + "'category': [ "); foreach (var wk in WOWkDate_list.Distinct()) { //for last element escaping comma if (wk == WOWkDate_list.Distinct().Last()) { JSON.Append("{ 'label': '" + wk + "' }"); break; } JSON.Append("{ 'label': '" + wk + "' },"); } JSON.Append("]" + "}]," + "'dataset': ["); foreach (var wostat in WOStatus_list.Distinct()) { List<int> wohrsvalue = getWOHrsData(wostat); JSON.Append("{" + "'seriesname':" + "'" + wostat + "'," + "'data': ["); foreach (var whrs in wohrsvalue) { if (whrs == wohrsvalue.Last()) { JSON.Append("{" + "'value':" + "'" + whrs + "'}"); break; } JSON.Append("{" + "'value':" + "'" + whrs + "'},"); } if (wostat == WOStatus_list.Distinct().Last()) { JSON.Append("]" + " }"); break; } JSON.Append("]" + " },"); } //replacing all ' into " string str = JSON.ToString().Replace('\'', '\"'); return str; } public List<int> getWOHrsData(string wostat) { List<int> hrsvalue = new List<int>(); var seriesLink = from wo in hdata_list where wo.WOStatus == wostat select new { linkdata = wo.WkHrs }; foreach (var obj in seriesLink) { hrsvalue.Add(obj.linkdata); } return hrsvalue; } public ActionResult Index() { ViewBag.mydata = createChart(); return View(); } public ActionResult About() { ViewBag.Message = "Your application description page."; return View(); } public ActionResult Contact() { ViewBag.Message = "Your contact page."; return View(); } }
  2. I'm trying to create my first dashboard with Fusioncharts and .net but I cannot get them to show up side by side. I'm using the asp:Literal tag and Fusioncharts.Renderchart in code behind. The size of the charts don't seem to be the issue. I have each Literal tag within its own DIV tag. But they still show up one on top of the other. Any suggestions. thank you Jenise
  3. Gantt chart with rolling days from DB

    Thank you Gagan, I will give that a try and let you know if I have any other questions. Jenise
  4. Hello, I'm new to Fusioncharts and trying to demo a Gantt chart by days populated from a database. The tasks can span across large periods of time but I always want the initial view to display 7 days prior to the current date through 22 days forward. I was thinking of creating a calendar table so i know when the start and stop date of every month based upon the current day. What is the best way to retrieve the data? Would it be to have a query for each set of data; one to retrieve the tasks, processes and then the calendar? I see a lot of examples like this: <categories> <category start="08/01/2014" end="08/31/2014" label="Aug '14" /> <category start="09/01/2014" end="09/30/2014" label="Sep '14" /> <category start="10/01/2014" end="10/31/2014" label="Oct '14" /> <category start="11/01/2014" end="11/30/2014" label="Nov '14" /> <category start="12/01/2014" end="12/31/2014" label="Dec '14" /> <category start="01/01/2015" end="01/31/2015" label="Jan '15" /> <category start="02/01/2015" end="02/28/2015" label="Feb '15" /> <category start="03/01/2015" end="03/31/2015" label="Mar '15" /> </categories> But if I want my labels to be day instead of a span of time then do I need the start date, end date and label to be the same, replicated for the number of days I want to show on the table. Like this? <category start="01/20/2016" end="01/20/2016" label="01/20/2016" /> Is this the best way to do this? Also, I was using the "scrolltodate" option so that the chart is always shows up with the current date by default, but that doesn't seem to working? Any thoughts? thank you! Jenise