/// <summary> /// 构建Chart Data /// </summary> private string BuildChartData(ReportDesignView designView, RptViewChartMain chartMain, XmlDocument formatXml) { StringBuilder sbData = new StringBuilder(); string strDataFormat = formatXml.SelectSingleNode("//ChartData").FirstChild.Value; for (int i = 0; designView.ChartDatas != null && i < designView.ChartDatas.Length; i++) { if (designView.ChartDatas[i].ChartSequence == chartMain.ChartSequence) { RptViewChartData chartData = designView.ChartDatas[i]; string strColumnName = designView.ChartDatas[i].ColumnName; string strTmp = strDataFormat; string strValue = ""; if (chartData.TotalType == ReportTotalType.Sum) { strValue = "=Sum(Fields!" + strColumnName + ".Value)"; } else if (chartData.TotalType == ReportTotalType.Avg) { strValue = "=Avg(Fields!" + strColumnName + ".Value)"; } else if (chartData.TotalType == ReportTotalType.Count) { strValue = "=Count(Fields!" + strColumnName + ".Value)"; } strTmp = strTmp.Replace("<%Value%>", strValue); string strLabel = ""; if (FormatHelper.StringToBoolean(chartMain.ShowLabel) == true) { strLabel = formatXml.SelectSingleNode("//ChartDataLabelStyle").FirstChild.Value; RptViewDataFormat dataFormat = null; strLabel = this.ApplyFontStyle(strLabel, designView, chartMain.LabelFormatID, formatXml, out dataFormat); } strTmp = strTmp.Replace("<%DataLabelStyle%>", strLabel); string strMarker = ""; if (FormatHelper.StringToBoolean(chartMain.ShowMarker) == true) { strMarker = formatXml.SelectSingleNode("//ChartDataMarkerType").FirstChild.Value; strMarker = strMarker.Replace("<%MarkerType%>", chartMain.MarkerType); } strTmp = strTmp.Replace("<%MarkerType%>", strMarker); sbData.Append(strTmp); } } return(sbData.ToString()); }
protected override void UpdateReportDesignView() { RptViewChartMain chartMain = null; if (this.designView.ChartMains != null && this.designView.ChartMains.Length > 0) { chartMain = this.designView.ChartMains[0]; } else { chartMain = new RptViewChartMain(); } chartMain.ChartSequence = 1; chartMain.DataSourceID = this.designView.DesignMain.DataSourceID; chartMain.ChartType = this.hidChartType.Value; chartMain.ChartSubType = this.hidChartSubType.Value; chartMain.ShowLegend = FormatHelper.BooleanToString(this.chkIsShowLegend.Checked); chartMain.ShowMarker = FormatHelper.BooleanToString(this.chkIsShowMarker.Checked); if (this.chkIsShowMarker.Checked == false) { chartMain.MarkerType = ""; } else { chartMain.MarkerType = this.rdoListMarkerType.SelectedValue; } chartMain.ShowLabel = FormatHelper.BooleanToString(this.chkIsShowLabel.Checked); if (this.chkIsShowLabel.Checked == false) { chartMain.LabelFormatID = ""; this.designView.ChartDataFormats = null; } else { RptViewDataFormat dataFormat = null; this.BuildDataFormat(out dataFormat, this.hidLabelFormat.Value); chartMain.LabelFormatID = dataFormat.FormatID; this.designView.ChartDataFormats = new RptViewDataFormat[] { dataFormat }; } this.designView.ChartMains = new RptViewChartMain[] { chartMain }; ArrayList list = new ArrayList(); string[] strArrTmp = this.hidSelectedSeriesValue.Value.Split(';'); for (int i = 0; i < strArrTmp.Length; i++) { if (strArrTmp[i] == "") { continue; } RptViewChartSeries series = new RptViewChartSeries(); series.ChartSequence = 1; series.SeriesSequence = i + 1; series.DataSourceID = this.designView.DesignMain.DataSourceID; series.ColumnName = strArrTmp[i]; series.Description = this.lstSelectedSeries.Items.FindByValue(series.ColumnName).Text; list.Add(series); } this.designView.ChartSeries = new RptViewChartSeries[list.Count]; list.CopyTo(this.designView.ChartSeries); list = new ArrayList(); strArrTmp = this.hidSelectedCategoryValue.Value.Split(';'); for (int i = 0; i < strArrTmp.Length; i++) { if (strArrTmp[i] == "") { continue; } RptViewChartCategory cate = new RptViewChartCategory(); cate.ChartSequence = 1; cate.CategorySequence = i + 1; cate.DataSourceID = this.designView.DesignMain.DataSourceID; cate.ColumnName = strArrTmp[i]; list.Add(cate); } this.designView.ChartCategories = new RptViewChartCategory[list.Count]; list.CopyTo(this.designView.ChartCategories); list = new ArrayList(); for (int i = 0; i < this.gridWebGrid.Rows.Count; i++) { RptViewChartData data = new RptViewChartData(); data.ChartSequence = 1; data.DataSequence = i + 1; data.DataSourceID = this.designView.DesignMain.DataSourceID; data.ColumnName = this.gridWebGrid.Rows[i].Items.FindItemByKey("ColumnName").Value.ToString(); data.Description = this.gridWebGrid.Rows[i].Items.FindItemByKey("DisplayDesc").Value.ToString(); data.TotalType = this.gridWebGrid.Rows[i].Items.FindItemByKey("TotalType").Value.ToString(); list.Add(data); } this.designView.ChartDatas = new RptViewChartData[list.Count]; list.CopyTo(this.designView.ChartDatas); }