Exemple #1
0
        /// <summary>
        /// 构建Chart Category
        /// </summary>
        private string BuildChartCategory(ReportDesignView designView, RptViewChartMain chartMain, XmlDocument formatXml)
        {
            StringBuilder sbCategory        = new StringBuilder();
            string        strCategoryFormat = formatXml.SelectSingleNode("//CategoryGrouping").FirstChild.Value;

            for (int i = 0; designView.ChartCategories != null && i < designView.ChartCategories.Length; i++)
            {
                if (designView.ChartCategories[i].ChartSequence == chartMain.ChartSequence)
                {
                    string strColumnName = designView.ChartCategories[i].ColumnName;
                    string strTmp        = strCategoryFormat;
                    strTmp = strTmp.Replace("<%CategoryName%>", "chart_" + chartMain.ChartSequence.ToString() + "_category_" + strColumnName);
                    strTmp = strTmp.Replace("<%GroupExpression%>", "=Fields!" + strColumnName + ".Value");
                    strTmp = strTmp.Replace("<%Label%>", "=Fields!" + strColumnName + ".Value");
                    sbCategory.Append(strTmp);
                }
            }
            if (sbCategory.Length == 0)
            {
                return("");
            }
            string strCategoryListFormat = formatXml.SelectSingleNode("//CategoryGroupingList").FirstChild.Value;

            strCategoryListFormat = strCategoryListFormat.Replace("<%CategoryGrouping%>", sbCategory.ToString());
            return(strCategoryListFormat);
        }
Exemple #2
0
        /// <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());
        }
Exemple #3
0
        /// <summary>
        /// 构建Chart
        /// </summary>
        private string BuildChart(ReportDesignView designView, XmlDocument formatXml)
        {
            StringBuilder sbChartTotal = new StringBuilder();

            for (int i = 0; designView.ChartMains != null && i < designView.ChartMains.Length; i++)
            {
                RptViewChartMain chartMain = designView.ChartMains[i];
                StringBuilder    sbChart   = new StringBuilder();
                sbChart.Append(formatXml.SelectSingleNode("//Chart").FirstChild.Value);
                sbChart.Replace("<%ChartName%>", "CHART" + chartMain.ChartSequence.ToString());
                sbChart.Replace("<%ChartType%>", chartMain.ChartType);
                sbChart.Replace("<%ShowLegend%>", FormatHelper.StringToBoolean(chartMain.ShowLegend).ToString().ToLower());
                sbChart.Replace("<%SeriesGroup%>", this.BuildChartSeries(designView, chartMain, formatXml));
                sbChart.Replace("<%CategoryGroupingList%>", this.BuildChartCategory(designView, chartMain, formatXml));
                sbChart.Replace("<%ChartData%>", this.BuildChartData(designView, chartMain, formatXml));

                sbChartTotal.Append(sbChart.ToString());
            }

            return(sbChartTotal.ToString());
        }
Exemple #4
0
        /// <summary>
        /// 构建Chart Series
        /// </summary>
        private string BuildChartSeries(ReportDesignView designView, RptViewChartMain chartMain, XmlDocument formatXml)
        {
            StringBuilder sbSeries = new StringBuilder();
            // Dynamic Series
            string strSeriesDyanmic = formatXml.SelectSingleNode("//SeriesGroupDynamic").FirstChild.Value;

            for (int i = 0; designView.ChartSeries != null && i < designView.ChartSeries.Length; i++)
            {
                if (designView.ChartSeries[i].ChartSequence == chartMain.ChartSequence)
                {
                    string strColumnName = designView.ChartSeries[i].ColumnName;
                    string strTmp        = strSeriesDyanmic;
                    strTmp = strTmp.Replace("<%SeriesName%>", "chart_" + chartMain.ChartSequence.ToString() + "_series_" + strColumnName);
                    strTmp = strTmp.Replace("<%GroupExpression%>", string.Format("=Fields!{0}.Value", strColumnName));
                    strTmp = strTmp.Replace("<%Label%>", string.Format("=Fields!{0}.Value", strColumnName));
                    sbSeries.Append(strTmp);
                }
            }
            if (designView.ChartSeries == null || designView.ChartSeries.Length == 0)
            {
                // Static Series
                string strSeriesStaticMemberList = "";
                string strSeriesStaticMember     = formatXml.SelectSingleNode("//SeriesGroupStaticMember").FirstChild.Value;
                for (int i = 0; designView.ChartDatas != null && i < designView.ChartDatas.Length; i++)
                {
                    if (designView.ChartDatas[i].ChartSequence == chartMain.ChartSequence)
                    {
                        string strTmp = strSeriesStaticMember;
                        strTmp = strTmp.Replace("<%Label%>", (designView.DataSourceColumns[designView.ChartDatas[i].ColumnName] != null ? designView.DataSourceColumns[designView.ChartDatas[i].ColumnName].Description : designView.ChartDatas[i].ColumnName));
                        strSeriesStaticMemberList = strSeriesStaticMemberList + strTmp;
                    }
                }
                string strSeriesStatic = formatXml.SelectSingleNode("//SeriesGroupStatic").FirstChild.Value;
                strSeriesStatic = strSeriesStatic.Replace("<%SeriesGroupStaticMember%>", strSeriesStaticMemberList);

                sbSeries.Append(strSeriesStatic);
            }

            return(sbSeries.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);
        }