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