I am using Dotnet Highchart that is based on C# code that has output code javascript.
Dotnet HighChart
This is almost how my chart looks like:

I am using data from my database to give this chart data by using LINQ queries.
I have a column “Completed Date” in my entity and I need to make two textboxes with datepicker so user can choose Start and end dates of Completed Date.Then the user should be able to click on a submit button and then the chart should update and show the statistic between the two dates. I have the complete LINQ Query for this
This is the LINQ query that I am going to use:
public List<CoreValueAndAverageGrade> GetAverageGradeForAllCoreValues(DateTime startDate, DateTime endDate)
{
return db.CoreValue
.Where(coreValue => coreValue.CoreValueQuestion
.Any(coreValueQuestion => coreValueQuestion.SubjectType.Ignored_Statistic == false))
.Select(coreValue => new CoreValueAndAverageGrade
{
CoreValue = coreValue,
AverageGrade = coreValue.CoreValueQuestion
.Where(coreValueQuestion => coreValueQuestion.SubjectType.Ignored_Statistic == false)
.Average(coreValueQuestion => coreValueQuestion.SelectedQuestions
.Where(selectedQuestion => selectedQuestion.GoalCardQuestionAnswer != null
&& selectedQuestion.GoalCardQuestionAnswer.Grade.HasValue
&& selectedQuestion.GoalCard.Completed_Date >= startDate
&& selectedQuestion.GoalCard.Completed_Date <= endDate
)
.Average(selectedQuestion => selectedQuestion.GoalCardQuestionAnswer.Grade.Value))
})
.ToList();
}
This is my ViewModel
public class OfficeStatisticNKIViewModel
{
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
In my GET action method I have following code:
public ActionResult OfficeStatistic()
{
{
OfficeStatisticNKIViewModel model = new OfficeStatisticNKIViewModel();
model.EndDate = DateTime.Now;
model.StartDate = DateTime.Now;
var averageGrades = OfficeStatisticRepository.GetAverageGradeForAllCoreValues(model.StartDate, model.EndDate);
var dataItems = (averageGrades.Select(averageGrade => averageGrade.AverageGrade).ToArray());
Data data = new Data(
dataItems.Select(y => new Point {Color = GetBarColour(y), Y = y}).ToArray());
Highcharts chart1 = new Highcharts("Chart")
.SetXAxis(new XAxis { Categories = averageGrades.Select(averageGrade => averageGrade.CoreValue.Name).ToArray() })
.SetYAxis(new YAxis { Min = 0, Max = 10, TickInterval = 1, Title = new YAxisTitle { Text = "Betygskalan" } })
.SetSeries(new Series { Data = data, Name = "Snittbetyg" })
.SetLegend(new Legend { Enabled = false })
.SetTitle(new Title { Text = "Örebro Statistik", })
.InitChart(new Chart { DefaultSeriesType = ChartTypes.Column });
return View(new Container(new[] { chart1 }));
}
The problem is that I have no idea how to do the post action method, The chart needs to update with the new the statistic, do I need some kind of ajax or can I do this on the serverside?
Any kind of help or tips is very appreciated!
Thanks in advance!
http://dotnethighcharts.codeplex.com/discussions/350721/