public void MakeParetoChart(Microsoft.Reporting.Chart.WebForms.Chart chart, string srcSeriesName, string destSeriesName) { string chartArea = chart.Series[srcSeriesName].ChartArea; chart.Series[srcSeriesName].ChartType = SeriesChartType.Column; chart.DataManipulator.Sort(PointsSortOrder.Descending, srcSeriesName); double num = 0.0; foreach (DataPoint point in chart.Series[srcSeriesName].Points) { if (!point.Empty && !double.IsNaN(point.YValues[0])) { num += point.YValues[0]; } } chart.ChartAreas[chartArea].AxisY.Maximum = num; Series series = new Series(destSeriesName); chart.Series.Add(series); series.ChartType = SeriesChartType.Line; series.ChartArea = chart.Series[srcSeriesName].ChartArea; if (chart.Series[srcSeriesName].Points.Count > 0) { series.BorderWidth = chart.Series[srcSeriesName].Points[0].BorderWidth; } series.Font = chart.Series[srcSeriesName].Font; series.FontAngle = chart.Series[srcSeriesName].FontAngle; series.FontColor = chart.Series[srcSeriesName].FontColor; series.Legend = chart.Series[srcSeriesName].Legend; series.YAxisType = AxisType.Secondary; chart.ChartAreas[chartArea].AxisY2.Maximum = 1.0; chart.ChartAreas[chartArea].AxisY2.LabelStyle.Format = "P0"; double num2 = 0.0; foreach (DataPoint point2 in chart.Series[srcSeriesName].Points) { num2 += point2.YValues[0] / num; series.Points.Add(Math.Round(num2, 2)); } }
public CollectedPieHelper(Microsoft.Reporting.Chart.WebForms.Chart chartControl) { this.chartControl = chartControl; this.chartControl.PostPaint += chart_PostPaint; }
public void CreateHistogram(Microsoft.Reporting.Chart.WebForms.Chart chartControl, string dataSeriesName, string histogramSeriesName, string histogramLegendText) { if (chartControl == null) { throw new ArgumentNullException("chartControl"); } int index = chartControl.Series.GetIndex(dataSeriesName); if (index < 0) { throw new ArgumentException("Series with name'" + dataSeriesName + "' was not found.", "dataSeriesName"); } Series series = chartControl.Series[dataSeriesName]; Series series2 = null; if (chartControl.Series.GetIndex(histogramSeriesName) < 0) { series2 = new Series(histogramSeriesName); chartControl.Series.Insert(index, series2); series2.ChartType = series.ChartType; series2.LegendText = histogramLegendText; if (series.Points.Count > 0) { series2.BorderColor = series.Points[0].BorderColor; series2.BorderWidth = series.Points[0].BorderWidth; series2.BorderStyle = series.Points[0].BorderStyle; } series2.Color = series.Color; series2.BackGradientEndColor = series.BackGradientEndColor; series2.BackGradientType = series.BackGradientType; series2.Legend = series.Legend; series2.ChartArea = series.ChartArea; DataPointAttributes dataPointAttributes = series; for (int i = 0; i < series.Points.Count; i++) { if (!series.Points[i].Empty) { dataPointAttributes = series.Points[i]; break; } } series2.LabelBackColor = dataPointAttributes.LabelBackColor; series2.LabelBorderColor = dataPointAttributes.LabelBorderColor; series2.LabelBorderWidth = dataPointAttributes.LabelBorderWidth; series2.LabelBorderStyle = dataPointAttributes.LabelBorderStyle; series2.LabelFormat = dataPointAttributes.LabelFormat; series2.ShowLabelAsValue = dataPointAttributes.ShowLabelAsValue; series2.Font = dataPointAttributes.Font; series2.FontColor = dataPointAttributes.FontColor; series2.FontAngle = dataPointAttributes.FontAngle; } double num = double.MaxValue; double num2 = double.MinValue; int num3 = 0; foreach (DataPoint point in series.Points) { if (!point.Empty) { if (point.YValues[0] > num2) { num2 = point.YValues[0]; } if (point.YValues[0] < num) { num = point.YValues[0]; } num3++; } } if (SegmentIntervalWidth == 0.0) { SegmentIntervalWidth = (num2 - num) / (double)SegmentIntervalNumber; SegmentIntervalWidth = RoundInterval(SegmentIntervalWidth); } num = Math.Floor(num / SegmentIntervalWidth) * SegmentIntervalWidth; num2 = Math.Ceiling(num2 / SegmentIntervalWidth) * SegmentIntervalWidth; double num4 = num; for (num4 = num; num4 <= num2; num4 += SegmentIntervalWidth) { int num5 = 0; foreach (DataPoint point2 in series.Points) { if (!point2.Empty) { double num6 = num4 + SegmentIntervalWidth; if (point2.YValues[0] >= num4 && point2.YValues[0] < num6) { num5++; } else if (num6 >= num2 && point2.YValues[0] >= num4 && point2.YValues[0] <= num6) { num5++; } } } series2.Points.AddXY(num4 + SegmentIntervalWidth / 2.0, num5); } series2["PointWidth"] = "1"; ChartArea chartArea = chartControl.ChartAreas[series2.ChartArea]; chartArea.AxisY.Title = "Frequency"; chartArea.AxisX.Minimum = num; chartArea.AxisX.Maximum = num2; double num7 = SegmentIntervalWidth; bool flag = false; while ((num2 - num) / num7 > 10.0) { num7 *= 2.0; flag = true; } chartArea.AxisX.Interval = num7; if (chartArea.AxisX.LabelStyle.ShowEndLabels && flag) { chartArea.AxisX.Maximum = num + Math.Ceiling((num2 - num) / num7) * num7; } chartControl.Series.Remove(series); chartArea.AxisY2.Enabled = AxisEnabled.Auto; if (ShowPercentOnSecondaryYAxis) { chartArea.Recalculate(); chartArea.AxisY2.Enabled = AxisEnabled.True; chartArea.AxisY2.LabelStyle.Format = "P0"; chartArea.AxisY2.MajorGrid.Enabled = false; chartArea.AxisY2.Title = "Percent of Total"; chartArea.AxisY2.Minimum = chartArea.AxisY.Minimum / (double)num3; chartArea.AxisY2.Maximum = chartArea.AxisY.Maximum / (double)num3; double num8 = (chartArea.AxisY2.Maximum > 0.2) ? 0.05 : 0.01; chartArea.AxisY2.Interval = Math.Ceiling(chartArea.AxisY2.Maximum / 5.0 / num8) * num8; } }