Welcome Guest Search | Active Topics |

Passing data from model and implementing using jquery - Gantt chart
Venkat0110
#1 Posted : Monday, September 23, 2013 12:24:27 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/23/2013(UTC)
Posts: 3

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
Hi,

The gantt chart is not plotted for me. Please find the details of the code below,

Model:

public SampleViewModel GetPrograms()
{
var returnData = new SampleViewModel();


for (var count = 5; count >=1; count--)
{
var titles = new TitleDetails
{
Title = "Title " + count,
FromValues = new DateTime(2010, 1, 1).AddDays(count),
ToValues = new DateTime(2010, 1, 30).AddDays(count)
};

returnData.GantChartData.ProgramDetails.Add(titles);


}

return returnData;
}

ViewModel:

public class SampleViewModel : BaseViewModel
{
public Programs GantChartData { get; set; }

public string ChartData
{
get
{
if (GantChartData != null && ErrorList != null)
GantChartData.ErrorList = ErrorList;
var serializer = new JavaScriptSerializer
{
MaxJsonLength = Int32.MaxValue
};
return serializer.Serialize(GantChartData.ProgramDetails);
}
}

public SampleViewModel()
{
GantChartData = new Programs();
}
}

public class Programs
{
public List<TitleDetails> ProgramDetails { get; set; }
public List<ResponseError> ErrorList { get; set; }

public Programs()
{
ProgramDetails = new List<TitleDetails>();


}
}

public class TitleDetails
{
public string Title { get; set; }
public DateTime FromValues { get; set; }
public DateTime ToValues { get; set; }

}

Controller:


var viewModel = new SampleViewModel();
List<SampleModel> test = new List<SampleModel>();

SampleModel Model = new SampleModel();
viewModel = Model.GetPrograms();

return View("Test", viewModel);

View:


<link rel="stylesheet" type="text/css" href="@ComponentUrlHelper.Content("~/Content/jquery.jqChart.css")" />
<link rel="stylesheet" type="text/css" href="@ComponentUrlHelper.Content("~/Content/jquery.jqRangeSlider.css")" />

<script src="../../Scripts/jquery-1.5.1.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.jqChart.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.jqRangeSlider.min.js" type="text/javascript"></script>
<!--[if IE]><script type="text/javascript" src="../../Scripts/excanvas.js"></script><![endif]-->

<script language="javascript" type="text/javascript">

this.chartData = @Html.Raw(Model.ChartData);


$('#jqChart1').jqChart({
title: { text: 'Conflict Visualizer' },
animation: { duration: 1 },
shadows: {
enabled: true
},
legend: {
visible: false
},
series: [
{
type: 'gantt',
fillStyles: ['#CA6B4B', '#005CDB', '#F3D288', '#506381', '#F1B9A8'],
//data:chartData

data: chartData
}
]
});
</script>

Thanks,
Venkatesh
Dragan
#2 Posted : Tuesday, September 24, 2013 7:53:41 AM(UTC)
Rank: Advanced Member

Groups: Administrators, DataVizJavaScript, jQueryChart, jQueryDV, MvcChart, Registered
Joined: 1/3/2011(UTC)
Posts: 483

Thanks: 0 times
Was thanked: 87 time(s) in 87 post(s)
I'm not really sure what you are trying to do here. I think it is better to follow the code in this example:

http://www.jqchart.com/aspnetmvc/chart/GanttCharts/GanttChart
Best Regards,
Dragan Matek
jqChart Inc.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

FlatEarth Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.250 seconds.