private CategoryUnit GuessPrimaryCategoryUnit(KnownCategory kc) { /** * We do lazy matching here as well. We know that months are the most * common horizontal axis categories, so we test for them first, then for * and finally for year. */ Regex month_pattern = new Regex("^[JFMASOND]$"); Regex year_pattern = new Regex(@"^(19|20)?\d\d$"); Regex quarter_pattern = new Regex(@"^(I|II|III|IV)$"); if (month_pattern.IsMatch(kc.category)) { return(CategoryUnit.MONTH); } else if (quarter_pattern.IsMatch(kc.category)) { return(CategoryUnit.QUARTER); } else if (year_pattern.IsMatch(kc.category)) { return(CategoryUnit.YEAR); } return(CategoryUnit.UNDEF); }
private void CleanQuarters() { List <string> qtr_cat_axis = new List <string>(); if (!ca.HasNullOrEmptyCategories()) { foreach (string s in ca.Categories) { qtr_cat_axis.Add(StrQuarterToName(s)); } } else { KnownCategory kc = ca.GetKnownCategories()[0]; int qtr_first_cat = (QuarterToInteger(kc.category) - kc.position) % 4; if (qtr_first_cat < 0) { qtr_first_cat += 4; } qtr_cat_axis.Add(IntQuarterToName(qtr_first_cat)); for (int i = 0; i < ca.Categories.Count - 1; i++) { qtr_cat_axis.Insert(i + 1, IntQuarterToName(((i + qtr_first_cat) + 1) % 4)); } } /* * if (g.Series[0].Status == (int)SeriesNulls.FIRST_LAST_NULL) * { * qtr_cat_axis.RemoveAt(0); * qtr_cat_axis.RemoveAt(qtr_cat_axis.Count - 1); * }*/ g.CategoryAxis.PrimaryCategories = qtr_cat_axis; log.Debug("Primary category list has been inferred as: " + g.CategoryAxis.CategoriesToString(CategoryType.PRIMARY)); }