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)
- {
-
- }
-
-
- }
- }
How could I shorten up this process? or is this the way is supposed to be working?
Regards.