I'm looking for an alternative towards a process that takes too much code and generates significant overhead...
This code fills in a Chartview (LineChart) and in order to display the progression of 6 different "Areas" it runs a query 6 times and add the series 6 times...
- public static void FillLineChart(ChartView chartView, CheckedDropDownList checkedDropDown, string dateFrom, string dateTo)
- {
- foreach (var i in checkedDropDown.CheckedItems)
- {
- var iindex = i.RowIndex + 1;
- if (iindex == 1)
- {
- LineSeries crime = new LineSeries();
- FunctionsDAL cr = new FunctionsDAL();
- foreach (var caseType in cr.ListCases(1, dateFrom, dateTo))
- {
- crime.DataPoints.Add(new CategoricalDataPoint(caseType.IncrementalTotal,
- CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(caseType.MonthNum)));
- }
- chartView.Series.Add(crime);
- crime.LegendTitle = "Crime";
- crime.Spline = true;
- }
- else if (iindex == 2)
- {
- }
- else if (iindex == 3)
- {
- }
- // The same 3 more times
- }
- }
How could I shorten up this process? or is this the way is supposed to be working?
Regards.
Guest UserPosted Jul 21, 2016, 10:45 AM
theLizardPosted Jul 8, 2016, 3:56 PM
for (int i = 0; i < c.CheckedItems.Count; i++)
{
LineSeriescrime = newLineSeries();
FunctionsDALcr = newFunctionsDAL();
foreach (varcaseTypeincr.ListCases(1,dateFrom,dateTo))
{
crime.DataPoints.Add(newCategoricalDataPoint(caseType.IncrementalTotal,
CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(caseType.MonthNum)));
}
chartView.Series.Add(crime);
crime.LegendTitle = titil[i];
crime.Spline = true;
}
Guest UserPosted Jul 8, 2016, 9:23 AM
Nitin SontakkePosted Jul 8, 2016, 12:27 AM