private void AllOther(HttpContext context) { Granularity granularity = Granularity.Day; int estPoints = GetRangeDays(); int maxPoints = imageWidth / POINT_SPACE; int step = 1; int maxSteps = imageWidth / LABLE_SPACE; if (estPoints > maxPoints) { estPoints = GetRangeMonths(); granularity = Granularity.Month; } if (estPoints > maxPoints) { estPoints = GetRangeYears(); granularity = Granularity.Year; } while (estPoints > maxSteps) { estPoints = estPoints / 2; step++; } StatisticResult result = null; switch (statisticsType) { case StatisticsType.CountCommunityMembers: result = Statistics.GetObjectCountCommunityMembers(dateFrom, dateTo, groupBy, granularity, parentObjectID, include); break; case StatisticsType.CountProfileFriends: result = Statistics.GetObjectCountProfileFriends(dateFrom, dateTo, groupBy, granularity, parentObjectID, include); break; case StatisticsType.TotalObjectsCount: result = Statistics.GetObjectCountCommunityTotal(parentObjectID, groupBy).Results[0]; break; case StatisticsType.CreationObjects: if (!ignoreCommunity && parentObjectID.HasValue) { if (parentObjectType == Helper.GetObjectTypeNumericID("Community")) { result = Statistics.GetObjectCreationCommunityObjects(dateFrom, dateTo, groupBy, granularity, parentObjectID, include); } else if (parentObjectType == Helper.GetObjectTypeNumericID("ProfileCommunity")) { result = Statistics.GetObjectCreationProfileObjects(dateFrom, dateTo, groupBy, granularity, parentObjectID, include); } else { result = Statistics.GetObjectCreationObjects(dateFrom, dateTo, groupBy, granularity, include); } } else { result = Statistics.GetObjectCreationObjects(dateFrom, dateTo, groupBy, granularity, include); } break; } if (result == null || result.Series.Count < 1) { context.Response.ContentType = "text/plain"; context.Response.StatusCode = 501; context.Response.AddHeader("IDS", string.Concat(chartId, "|", errorId)); context.Response.Write(language.GetString("MessageStatisticNoData")); return; } List <string> colors = GetColors(result.Series.Count); DateTime minDate = DateTime.MaxValue; DateTime maxDate = DateTime.MinValue; DateTime lastDate = DateTime.MinValue; Graph graph = new Graph(); graph.Bgcolor = "#FFFFFF"; if (!string.IsNullOrEmpty(result.LabelX)) { Legend xLegend = new Legend(); xLegend.Text = result.LabelX; xLegend.Style = "color: #444444; font-size: 12px;"; graph.X_Legend = xLegend; } if (!string.IsNullOrEmpty(result.LabelY)) { Legend yLegend = new Legend(); yLegend.Text = result.LabelY; yLegend.Style = "color: #444444; font-size: 12px;"; graph.Y_Legend = yLegend; } XAxis xAxis = new XAxis(); xAxis.Colour = "#444444"; xAxis.GridColour = "#CCCCCC"; xAxis.Steps = step; graph.X_Axis = xAxis; YAxis yAxis = new YAxis(); yAxis.Colour = "#444444"; yAxis.GridColour = "#CCCCCC"; int y = result.MaxY - result.MinY; yAxis.Steps = y / 5; graph.Y_Axis = yAxis; string toolTip = language.GetString("LableStatisticCalls"); for (int i = 0; i < result.Series.Count; i++) { ChartBase chart = null; switch (chartType) { case ChartType.Bar: chart = new Bar(); break; case ChartType.Line: chart = new Line(); break; case ChartType.Column: chart = new HBar(); break; case ChartType.Pie: chart = new Pie(); break; } chart.Colour = colors[i]; //chart.Text = result.Series[i].Label.ToLowerInvariant(); chart.Text = result.Series[i].Label; if (statisticsType == StatisticsType.PageView) { chart.Tooltip = string.Format("#val# {0} ({1})", toolTip, chart.Text); } else { chart.Tooltip = string.Format("#val#"); } chart.Fontsize = 9; for (int j = 0; j < result.Series[i].Values.Count; j++) { StatisticValue value = result.Series[i].Values[j]; string xLabel = string.Empty; if (value is StatisticValueDateTimeInt) { StatisticValueDateTimeInt valueDateTime = (StatisticValueDateTimeInt)value; if (lastDate == DateTime.MinValue) { lastDate = valueDateTime.X; } if (valueDateTime.X > maxDate) { maxDate = valueDateTime.X; } if (valueDateTime.X < minDate) { minDate = valueDateTime.X; } if (j % xAxis.Steps == 0) { if (granularity == Granularity.Year) { xLabel = valueDateTime.X.ToString("yyyy"); } else if (granularity == Granularity.Month) { if (lastDate.Year != valueDateTime.X.Year || valueDateTime.X.Month == 1) { lastDate = valueDateTime.X; xLabel = valueDateTime.X.ToString("MMM. yy"); } else { xLabel = valueDateTime.X.ToString("MMM."); } } else if (granularity == Granularity.Day) { if (lastDate.Year != valueDateTime.X.Year || lastDate.Month != valueDateTime.X.Month || valueDateTime.X.Day == 1) { lastDate = valueDateTime.X; xLabel = valueDateTime.X.ToString("d.M."); } else { xLabel = valueDateTime.X.ToString("d."); } } } } else if (value is StatisticValueStringInt) { xLabel = ((StatisticValueStringInt)value).X; } var val = chart.NewValue(xLabel, value.Y); chart.Values.Add(val); } graph.Title = new Title(GetTitle(granularity)); graph.AddElement(chart); } //context.Response.ContentType = "application/json"; context.Response.ContentType = "text/plain"; context.Response.AddHeader("IDS", string.Concat(chartId, "|", errorId)); context.Response.Write(graph.ToString()); }