Пример #1
0
    /// <summary>
    /// 设置图表标题
    /// </summary>
    /// <param name="control">图表控件</param>
    /// /// <param name="isVisible">标题是否可见</param>
    /// <param name="text">标题文本</param>
    /// <param name="isWordWrop">是否换行</param>
    /// <param name="maxLineCount">最大允许行数</param>
    /// <param name="alignment">对齐方式</param>
    /// <param name="dock">位置</param>
    /// <param name="isAntialiasing">是否允许设置外观</param>
    /// <param name="font">字体</param>
    /// <param name="textColor">文本颜色</param>
    /// <param name="indent">字体缩进值</param>
    public static void SetChartTitle(DevExpress.XtraCharts.Web.WebChartControl control, bool isVisible, String text, bool isWordWrop, int maxLineCount, StringAlignment alignment, ChartTitleDockStyle dock, bool isAntialiasing, Font font, Color textColor, int indent)
    {
        //设置标题
        ChartTitle title = new ChartTitle();

        title.Visible = isVisible;
        //显示文本
        title.Text = text;
        //是否允许换行
        title.WordWrap = isWordWrop;
        //最大允许行数
        title.MaxLineCount = maxLineCount;
        //对齐方式
        title.Alignment = alignment;
        //位置
        title.Dock = dock;
        //是否允许设置外观
        title.Antialiasing = isAntialiasing;
        //字体
        title.Font = font;
        //字体颜色
        title.TextColor = textColor;
        //缩进值
        title.Indent = indent;
        control.Titles.Add(title);
    }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="webChartContro"></param>
        /// <param name="title"></param>
        private void CreateCustomerChart(DataTable dt, DevExpress.XtraCharts.Web.WebChartControl webChartContro, string title)
        {
            webChartContro.Series.Clear();
            if (dt.Rows.Count > 0)
            {
                Series series = new Series("客户分布", ViewType.Pie);//首先new一个对象
                //for (int i = 0; i < dt.Rows.Count; i++)
                //{
                foreach (DataRow row in dt.Rows)//将传入的表dt中每行数据都加入进去
                {
                    SeriesPoint point = new SeriesPoint(row["C_X"].ToString(), row["C_Y"].ToString());
                    series.Points.Add(point);
                }
                //}

                webChartContro.Series.Add(series);

                //样式设置
                series.ArgumentScaleType = ScaleType.Qualitative;
                series.ValueScaleType    = ScaleType.Numerical;

                ((PieSeriesView)series.View).Rotation          = 90;                            //从90度方向开始
                series.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent;         //显示为百分比形式
                series.LegendPointOptions.PointView            = PointView.Argument;            //右边的图例
                series.PointOptions.PointView = PointView.ArgumentAndValues;                    //左边饼上的图例
                ((PiePointOptions)(series.PointOptions)).PercentOptions.PercentageAccuracy = 3; //保留三位小数

                ChartTitle CTitl = new ChartTitle();                                            //加标题
                CTitl.Text = title;

                webChartContro.Titles.Clear();
                webChartContro.Titles.Add(CTitl);
                webChartContro.Visible = true;
            }
        }
Пример #3
0
    /// <summary>
    /// 绘制图形
    /// </summary>
    /// <param name="control">图表控件</param>
    /// <param name="seriesName">系列名</param>
    /// <param name="type">类型</param>
    /// <param name="dt">数据源</param>
    /// <param name="column1"></param>
    /// <param name="column2"></param>
    public static void DrawChart(DevExpress.XtraCharts.Web.WebChartControl control, string seriesName, ViewType type, DataTable dt, string column1, string column2)
    {
        Series series = new Series(seriesName, type);

        series.ArgumentScaleType   = ScaleType.Qualitative;
        series.ArgumentDataMember  = column1;
        series.ValueDataMembers[0] = column2;
        DataTable table = dt;
        // series.DataSource = table;
        SeriesPoint point = null;

        for (int i = 0; i < table.Rows.Count; i++)
        {
            point = new SeriesPoint(table.Rows[i][column1].ToString(), Convert.ToDouble(table.Rows[i][column2].ToString()));
            series.Points.Add(point);
        }

        control.Series.Add(series);


        //针对饼图的特殊处理
        if (type == ViewType.Pie)
        {
            //设置显示方式(Argument:显示图例说明,ArgumentAndValues:显示图例内容和数据)
            series.Label.PointOptions.PointView = PointView.ArgumentAndValues;
            //设置数据显示形式(Percent:百分比,Currency:货币类型,数据前添加¥,Scientific:科学计数法)
            series.Label.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
            //数据是否保留小数(0:不保留小数位,1保留一位小数,2保留两位小数)
            series.Label.PointOptions.ValueNumericOptions.Precision = 0;

            //数据以百分比显示时只能是Default和None
            ((PieSeriesLabel)series.Label).ResolveOverlappingMode = ResolveOverlappingMode.Default;
        }
    }
Пример #4
0
    /// <summary>
    /// 为X轴添加标题
    /// </summary>
    /// <param name="control">图形控件</param>
    /// <param name="isVisible">标题是否可见</param>
    /// <param name="aligment">对齐方式</param>
    /// <param name="text">标题显示文本</param>
    /// <param name="color">标题字体颜色</param>
    /// <param name="isAntialiasing">是否允许设置外观</param>
    /// <param name="font">字体</param>
    public static void SetAxisY(DevExpress.XtraCharts.Web.WebChartControl control, bool isVisible, StringAlignment aligment, string text, Color color, bool isAntialiasing, Font font)
    {
        XYDiagram xydiagram = (XYDiagram)control.Diagram;

        xydiagram.AxisY.Title.Visible      = isVisible;
        xydiagram.AxisY.Title.Alignment    = aligment;
        xydiagram.AxisY.Title.Text         = text;
        xydiagram.AxisY.Title.TextColor    = color;
        xydiagram.AxisY.Title.Antialiasing = isAntialiasing;
        xydiagram.AxisY.Title.Font         = font;
    }
Пример #5
0
 private void Bind(DevExpress.XtraCharts.Web.WebChartControl chart, DevExpress.Web.ASPxGridView.ASPxGridView grid, string str1, string str2, string str3, string sql1, string sql2)
 {
     using (Adapter ad = new Adapter(Conn))
     {
         DataTable data = ad.Query(sql1, null);
         chart.Series.Clear();
         chart.SeriesDataMember = str1;
         chart.SeriesSorting    = DevExpress.XtraCharts.SortingMode.Ascending;
         chart.SeriesTemplate.ArgumentDataMember           = str2;
         chart.SeriesTemplate.ArgumentScaleType            = DevExpress.XtraCharts.ScaleType.Qualitative;
         chart.SeriesTemplate.SeriesPointsSorting          = DevExpress.XtraCharts.SortingMode.Ascending;
         chart.SeriesTemplate.ValueDataMembersSerializable = str3;
         chart.SeriesTemplate.LabelsVisibility             = DevExpress.Utils.DefaultBoolean.True;
         chart.SeriesTemplate.ValueScaleType = ScaleType.Numerical;
         chart.PaletteName = "Metro";
         chart.DataSource  = data;
         chart.DataBind();
         DataTable data2 = ad.Query(sql2, null);
         grid.DataSource = data2;
         grid.DataBind();
     }
 }
 protected void Page_Load(object sender, System.EventArgs e)
 {
     _chCtrl = new DevExpress.XtraCharts.Web.WebChartControl();
 }
        public void LoadGraph()
        {
            int t1 = System.Environment.TickCount;

            if (_report.State != Report.StateEnum.Executed)
                return;

            _chCtrl.BeginInit();

            bool rotateGraph = false;
            bool pivotAxes = ((_report.GraphOptions & OlapReport.GraphOptionsEnum.Pivot) > 0);

            int seriesPosCount = (pivotAxes ? _report.Cellset.Axis1PosCount : _report.Cellset.Axis0PosCount);
            int seriesMemCount = (pivotAxes ? _report.Cellset.Axis1TupleMemCount : _report.Cellset.Axis0TupleMemCount);
            int catPosCount = (pivotAxes ? _report.Cellset.Axis0PosCount : _report.Cellset.Axis1PosCount);
            int catMemCount = (pivotAxes ? _report.Cellset.Axis0TupleMemCount : _report.Cellset.Axis1TupleMemCount);
            if (seriesPosCount == 0 || catPosCount == 0)
                return;

            Size size = new Size(_report.GraphWidth, _report.GraphHeight);
            size = this.AdjustGraphWidth(size, _report.GraphType);

            // limit number of series
            if (seriesPosCount > __MaxSeriesCount)
                seriesPosCount = __MaxSeriesCount;
            if (_report.GraphType == OlapReport.GraphTypeEnum.Pie || _report.GraphType == OlapReport.GraphTypeEnum.PieBrokenApart)
                if (seriesPosCount > __MaxPieCount)
                    seriesPosCount = __MaxPieCount;

            // limit number of categories
            if (catPosCount > __MaxCategoriesCount)
                catPosCount = __MaxCategoriesCount;

            bool showValues = (_report.GraphOptions & OlapReport.GraphOptionsEnum.ShowValues) > 0;
            bool showSeries = (_report.GraphOptions & OlapReport.GraphOptionsEnum.ShowSeries) > 0;
            bool showCats = (_report.GraphOptions & OlapReport.GraphOptionsEnum.ShowCategories) > 0;
            bool setScaling = _report.GraphType != OlapReport.GraphTypeEnum.Pie && ((_report.GraphOptions & OlapReport.GraphOptionsEnum.ScalingBySeries) > 0);
            bool setPerc = !setScaling && ((_report.GraphOptions & OlapReport.GraphOptionsEnum.PercentByCategories) > 0);
            byte graphPieColumns = (_report.GraphPieColumns == 0 ?
                Convert.ToByte(Math.Sqrt(seriesPosCount)) : _report.GraphPieColumns);
            byte graphMixedLinePos = _report.GraphMixedLinePosition;
            graphMixedLinePos = (graphMixedLinePos <= 0 || graphMixedLinePos > seriesPosCount ? (byte)1 : graphMixedLinePos);

            // theme
            if (_report.GraphTheme != null && _report.GraphTheme != "")
                _chCtrl.AppearanceName = _report.GraphTheme;

            // create series
            for (int i = 0; i < seriesPosCount; i++)
            {
                string name = "";
                for (int j = 0; j < seriesMemCount; j++)
                    name += (j == 0 ? "" : " | ") + (pivotAxes ? _report.Cellset.GetCellsetMember(1, j, i).Name : _report.Cellset.GetCellsetMember(0, j, i).Name);

                Series series = new Series();
                series.Name = name;

                // type
                if (_report.GraphType == OlapReport.GraphTypeEnum.Pie || _report.GraphType == OlapReport.GraphTypeEnum.PieBrokenApart)
                {
                    // if pie, each of series is displayed as individual graph
                    if (_report.GraphType == OlapReport.GraphTypeEnum.PieBrokenApart)
                        _chCtrl.Series.Clear();
                    _chCtrl.Series.Add(series);

                    series.ChangeView(ViewType.Pie);

                    PiePointOptions ppo = (PiePointOptions)series.PointOptions;
                    PieSeriesView psw = (PieSeriesView)series.View;
                    PieSeriesLabel psl = (PieSeriesLabel)series.Label;

                    psl.Position = PieSeriesLabelPosition.TwoColumns;
                    series.PointOptions.PointView = PointView.Undefined;

                    if (_report.GraphType == OlapReport.GraphTypeEnum.Pie)
                    {
                        SimpleDiagram sd = new SimpleDiagram();
                        sd.LayoutDirection = LayoutDirection.Horizontal;
                        sd.Dimension = graphPieColumns;
                        _chCtrl.Diagram = sd;
                    }

                    // legend
                    if (showCats)
                        _chCtrl.Legend.Visible = false;

                    series.Label.OverlappingOptions.ResolveOverlapping = true;
                    series.LegendPointOptions.PointView = PointView.Argument;

                    _chCtrl.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Center;
                    _chCtrl.Legend.AlignmentVertical = LegendAlignmentVertical.BottomOutside;
                    _chCtrl.Legend.Direction = LegendDirection.LeftToRight;

                    // series title
                    SeriesTitle sTitle = new SeriesTitle();
                    sTitle.Text = name;
                    sTitle.Alignment = StringAlignment.Center;
                    sTitle.Dock = ChartTitleDockStyle.Bottom;
                    psw.Titles.Add(sTitle);
                }
                else
                {
                    // diagram
                    if (_chCtrl.Diagram == null)
                        _chCtrl.Diagram = new XYDiagram();
                    XYDiagram diag = (XYDiagram)_chCtrl.Diagram;

                    //// panes
                    //if (_report.GraphType == OlapReport.GraphTypeEnum.LineWithBars && graphMixedLinePos <= seriesPosCount && diag.Panes.Count == 0)
                    //{
                    //    // add new pane
                    //    XYDiagramPane pane = new XYDiagramPane();
                    //    pane.Visible = true;
                    //    pane.SizeMode = PaneSizeMode.UseWeight;
                    //    pane.Weight = 0.66;
                    //    diag.PaneLayoutDirection = PaneLayoutDirection.Vertical;
                    //    diag.Panes.Add(pane);

                    //    // set default pane weight
                    //    diag.DefaultPane.SizeMode = PaneSizeMode.UseWeight;
                    //    diag.DefaultPane.Weight = 0.33;
                    //}

                    // add series
                    _chCtrl.Series.Add(series);

                    // add series to secondary pane if needed (in case of LineWithBars)
                    if (diag.Panes.Count > 0 && i != graphMixedLinePos - 1)
                        ((XYDiagramSeriesViewBase)series.View).Pane = diag.Panes[0];

                    if (_report.GraphType == OlapReport.GraphTypeEnum.BarVertical)
                    {
                        series.ChangeView(ViewType.Bar);
                    }
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.BarHorizontal)
                    {
                        series.ChangeView(ViewType.Bar);
                        rotateGraph = true;
                    }
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.StackedBarVertical)
                        series.ChangeView(ViewType.StackedBar);
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.StackedBarHorizontal)
                    {
                        series.ChangeView(ViewType.StackedBar);
                        rotateGraph = true;
                    }
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.LineHorizontal)
                        series.ChangeView(ViewType.Line);
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.LineWithBars)
                    {
                        if (i == graphMixedLinePos - 1)
                        {
                            //if (!setScaling)
                            //{
                            //    // create secondary axis
                            //    SecondaryAxisY axisY = new SecondaryAxisY(series.Name);
                            //    axisY.Visible = true;
                            //    axisY.Title.Text = series.Name;
                            //    axisY.Title.Visible = true;
                            //    axisY.Alignment = AxisAlignment.Near;
                            //    ((XYDiagram)_chCtrl.Diagram).SecondaryAxesY.Add(axisY);
                            //    ((XYDiagramSeriesViewBase)series.View).AxisY = axisY;

                            //    // set default axis title
                            //    ((XYDiagram)_chCtrl.Diagram).AxisY.Title.Text = "Bar axis";
                            //    ((XYDiagram)_chCtrl.Diagram).AxisY.Title.Visible = true;
                            //}

                            // change view
                            series.ChangeView(ViewType.Line);
                        }
                        else
                            series.ChangeView(ViewType.Bar);
                    }

                    // 20 pixels per label (250 pixels for legend), othervise overlapping resolution will never finish
                    if ((size.Width - 250) / catPosCount > 20)
                    {
                        series.Label.OverlappingOptions.ResolveOverlapping = true;
                        PointOverlappingOptions poo = series.Label.OverlappingOptions as PointOverlappingOptions;
                        if (poo != null)
                            poo.AttractToMarker = true;
                    }

                    series.LegendText = name;
                    series.ShowInLegend = true;
                    series.ValueScaleType = ScaleType.Numerical;
                    series.PointOptions.PointView = PointView.Undefined;
                    series.LegendPointOptions.PointView = PointView.SeriesName;
                    series.Visible = true;

                    // labels orientation
                    diag.Rotated = rotateGraph;
                    if (rotateGraph)
                    {
                        diag.AxisY.Label.Antialiasing = true;
                        diag.AxisY.Label.Angle = 315;
                    }
                    else
                    {
                        diag.AxisX.Label.Antialiasing = true;
                        diag.AxisX.Label.Angle = 315;
                    }

                    // if scaling
                    if (setScaling)
                        diag.AxisY.Visible = false;
                }

                // prepare scaling ranges
                double scalingMin = double.MaxValue;
                double scalingMax = double.MinValue;
                if (setScaling)
                {
                    for (int l = 0; l < catPosCount; l++)
                    {
                        string val = (pivotAxes ? _report.Cellset.GetCell(l, i).Value : _report.Cellset.GetCell(i, l).Value);
                        double dVal = 0;
                        double.TryParse(val, System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out dVal);
                        if (dVal < scalingMin)
                            scalingMin = dVal;
                        if (dVal > scalingMax)
                            scalingMax = dVal;
                    }
                }
                scalingMin = scalingMin - (scalingMax - scalingMin) * 0.1;

                // set data
                double percSum = 0;
                for (int l = 0; l < catPosCount; l++)
                {
                    string argument = "";
                    for (int m = 0; m < catMemCount; m++)
                        argument += (m == 0 ? "" : " | ") + (pivotAxes ? _report.Cellset.GetCellsetMember(0, m, l).Name : _report.Cellset.GetCellsetMember(1, m, l).Name);

                    string val = (pivotAxes ? _report.Cellset.GetCell(l, i).Value : _report.Cellset.GetCell(i, l).Value);

                    double dVal = 0;
                    double.TryParse(val, System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out dVal);
                    if (setPerc)
                        percSum += dVal;
                    else if (setScaling)
                        dVal = (scalingMax - scalingMin == 0 ? 0 : (dVal - scalingMin) / (scalingMax - scalingMin));

                    string fVal = (pivotAxes ? _report.Cellset.GetCell(l, i).FormattedValue : _report.Cellset.GetCell(i, l).FormattedValue);

                    SeriesPoint sp = new SeriesPoint(argument, new double[] { dVal });
                    sp.Tag = fVal;
                    series.Points.Add(sp);
                }

                // set custom labels and value as percentage
                for (int l = 0; l < catPosCount; l++)
                {
                    SeriesPoint sp = series.Points[l];
                    if (setPerc)
                    {
                        sp.Values[0] = sp.Values[0] / percSum;
                        sp.Tag = sp.Values[0].ToString("P");
                    }

                    // custom point label
                    string customLabel = string.Empty;
                    if (!showValues && !showSeries && !showCats)
                        series.Label.Visible = false;
                    else
                    {
                        string fVal = (string)sp.Tag;
                        if (fVal == null || fVal == "")
                            fVal = "0";
                        customLabel = (showSeries ? series.Name : string.Empty);
                        customLabel += (showCats ? (customLabel != string.Empty ? " | " : string.Empty) + sp.Argument : string.Empty);
                        customLabel += (showValues ? (customLabel != string.Empty ? ": " : string.Empty) + fVal : string.Empty);
                    }

                    series.Points[l].Tag = customLabel;
                }

                // for pie, layout each of series individually
                if (_report.GraphType == OlapReport.GraphTypeEnum.PieBrokenApart)
                {
                    _chCtrl.Titles.Clear();
                    _chCtrl.EndInit();
                    LayoutGraph(_report.ID.ToString() + "." + i.ToString(), size, graphPieColumns);

                    // init next chart
                    if (i < seriesPosCount - 1)
                    {
                        _chCtrl = new DevExpress.XtraCharts.Web.WebChartControl();
                        _chCtrl.BeginInit();
                    }
                }
            }

            int t2 = System.Environment.TickCount;

            if (_report.GraphType != OlapReport.GraphTypeEnum.PieBrokenApart)
            {
                ChartTitle title = new ChartTitle();
                title.Alignment = StringAlignment.Center;
                title.Lines = new string[] { _report.Name, _report.Description };
                _chCtrl.Titles.Add(title);

                LayoutGraph(_report.ID.ToString(), size, 0);
            }

            // if LineWithBars
            if (_report.GraphType == OlapReport.GraphTypeEnum.LineWithBars)
            {
                // fill combo
                for (int i = 0; i < _chCtrl.Series.Count; i++)
                    this.selMixedLinePos.Items.Add(new ListItem(_chCtrl.Series[i].Name, (i + 1).ToString()));
                this.selMixedLinePos.SelectedIndex = graphMixedLinePos - 1;

                // set line as last
                if (!(_chCtrl.Series[_chCtrl.Series.Count - 1].View is LineSeriesView))
                {
                    // roll down through series
                    for (int i = graphMixedLinePos - 1; i < _chCtrl.Series.Count - 1; i++)
                        _chCtrl.Series.Swap(i, i + 1);
                }
            }

            int t3 = System.Environment.TickCount;
            double time1 = (t3 - t2) / 1000.0;
            double time2 = (t2 - t1) / 1000.0;
            t1 = 0;
        }
Пример #8
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     _chCtrl = new DevExpress.XtraCharts.Web.WebChartControl();
 }
Пример #9
0
        public void LoadGraph()
        {
            int t1 = System.Environment.TickCount;

            if (_report.State != Report.StateEnum.Executed)
            {
                return;
            }

            _chCtrl.BeginInit();

            bool rotateGraph = false;
            bool pivotAxes   = ((_report.GraphOptions & OlapReport.GraphOptionsEnum.Pivot) > 0);

            int seriesPosCount = (pivotAxes ? _report.Cellset.Axis1PosCount : _report.Cellset.Axis0PosCount);
            int seriesMemCount = (pivotAxes ? _report.Cellset.Axis1TupleMemCount : _report.Cellset.Axis0TupleMemCount);
            int catPosCount    = (pivotAxes ? _report.Cellset.Axis0PosCount : _report.Cellset.Axis1PosCount);
            int catMemCount    = (pivotAxes ? _report.Cellset.Axis0TupleMemCount : _report.Cellset.Axis1TupleMemCount);

            if (seriesPosCount == 0 || catPosCount == 0)
            {
                return;
            }

            Size size = new Size(_report.GraphWidth, _report.GraphHeight);

            size = this.AdjustGraphWidth(size, _report.GraphType);

            // limit number of series
            if (seriesPosCount > __MaxSeriesCount)
            {
                seriesPosCount = __MaxSeriesCount;
            }
            if (_report.GraphType == OlapReport.GraphTypeEnum.Pie || _report.GraphType == OlapReport.GraphTypeEnum.PieBrokenApart)
            {
                if (seriesPosCount > __MaxPieCount)
                {
                    seriesPosCount = __MaxPieCount;
                }
            }

            // limit number of categories
            if (catPosCount > __MaxCategoriesCount)
            {
                catPosCount = __MaxCategoriesCount;
            }

            bool showValues      = (_report.GraphOptions & OlapReport.GraphOptionsEnum.ShowValues) > 0;
            bool showSeries      = (_report.GraphOptions & OlapReport.GraphOptionsEnum.ShowSeries) > 0;
            bool showCats        = (_report.GraphOptions & OlapReport.GraphOptionsEnum.ShowCategories) > 0;
            bool setScaling      = _report.GraphType != OlapReport.GraphTypeEnum.Pie && ((_report.GraphOptions & OlapReport.GraphOptionsEnum.ScalingBySeries) > 0);
            bool setPerc         = !setScaling && ((_report.GraphOptions & OlapReport.GraphOptionsEnum.PercentByCategories) > 0);
            byte graphPieColumns = (_report.GraphPieColumns == 0 ?
                                    Convert.ToByte(Math.Sqrt(seriesPosCount)) : _report.GraphPieColumns);
            byte graphMixedLinePos = _report.GraphMixedLinePosition;

            graphMixedLinePos = (graphMixedLinePos <= 0 || graphMixedLinePos > seriesPosCount ? (byte)1 : graphMixedLinePos);

            // theme
            if (_report.GraphTheme != null && _report.GraphTheme != "")
            {
                _chCtrl.AppearanceName = _report.GraphTheme;
            }

            // create series
            for (int i = 0; i < seriesPosCount; i++)
            {
                string name = "";
                for (int j = 0; j < seriesMemCount; j++)
                {
                    name += (j == 0 ? "" : " | ") + (pivotAxes ? _report.Cellset.GetCellsetMember(1, j, i).Name : _report.Cellset.GetCellsetMember(0, j, i).Name);
                }

                Series series = new Series();
                series.Name = name;


                // type
                if (_report.GraphType == OlapReport.GraphTypeEnum.Pie || _report.GraphType == OlapReport.GraphTypeEnum.PieBrokenApart)
                {
                    // if pie, each of series is displayed as individual graph
                    if (_report.GraphType == OlapReport.GraphTypeEnum.PieBrokenApart)
                    {
                        _chCtrl.Series.Clear();
                    }
                    _chCtrl.Series.Add(series);

                    series.ChangeView(ViewType.Pie);

                    PiePointOptions ppo = (PiePointOptions)series.PointOptions;
                    PieSeriesView   psw = (PieSeriesView)series.View;
                    PieSeriesLabel  psl = (PieSeriesLabel)series.Label;

                    psl.Position = PieSeriesLabelPosition.TwoColumns;
                    series.PointOptions.PointView = PointView.Undefined;

                    if (_report.GraphType == OlapReport.GraphTypeEnum.Pie)
                    {
                        SimpleDiagram sd = new SimpleDiagram();
                        sd.LayoutDirection = LayoutDirection.Horizontal;
                        sd.Dimension       = graphPieColumns;
                        _chCtrl.Diagram    = sd;
                    }

                    // legend
                    if (showCats)
                    {
                        _chCtrl.Legend.Visible = false;
                    }

                    series.Label.OverlappingOptions.ResolveOverlapping = true;
                    series.LegendPointOptions.PointView = PointView.Argument;

                    _chCtrl.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Center;
                    _chCtrl.Legend.AlignmentVertical   = LegendAlignmentVertical.BottomOutside;
                    _chCtrl.Legend.Direction           = LegendDirection.LeftToRight;


                    // series title
                    SeriesTitle sTitle = new SeriesTitle();
                    sTitle.Text      = name;
                    sTitle.Alignment = StringAlignment.Center;
                    sTitle.Dock      = ChartTitleDockStyle.Bottom;
                    psw.Titles.Add(sTitle);
                }
                else
                {
                    // diagram
                    if (_chCtrl.Diagram == null)
                    {
                        _chCtrl.Diagram = new XYDiagram();
                    }
                    XYDiagram diag = (XYDiagram)_chCtrl.Diagram;


                    //// panes
                    //if (_report.GraphType == OlapReport.GraphTypeEnum.LineWithBars && graphMixedLinePos <= seriesPosCount && diag.Panes.Count == 0)
                    //{
                    //    // add new pane
                    //    XYDiagramPane pane = new XYDiagramPane();
                    //    pane.Visible = true;
                    //    pane.SizeMode = PaneSizeMode.UseWeight;
                    //    pane.Weight = 0.66;
                    //    diag.PaneLayoutDirection = PaneLayoutDirection.Vertical;
                    //    diag.Panes.Add(pane);

                    //    // set default pane weight
                    //    diag.DefaultPane.SizeMode = PaneSizeMode.UseWeight;
                    //    diag.DefaultPane.Weight = 0.33;
                    //}

                    // add series
                    _chCtrl.Series.Add(series);

                    // add series to secondary pane if needed (in case of LineWithBars)
                    if (diag.Panes.Count > 0 && i != graphMixedLinePos - 1)
                    {
                        ((XYDiagramSeriesViewBase)series.View).Pane = diag.Panes[0];
                    }

                    if (_report.GraphType == OlapReport.GraphTypeEnum.BarVertical)
                    {
                        series.ChangeView(ViewType.Bar);
                    }
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.BarHorizontal)
                    {
                        series.ChangeView(ViewType.Bar);
                        rotateGraph = true;
                    }
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.StackedBarVertical)
                    {
                        series.ChangeView(ViewType.StackedBar);
                    }
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.StackedBarHorizontal)
                    {
                        series.ChangeView(ViewType.StackedBar);
                        rotateGraph = true;
                    }
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.LineHorizontal)
                    {
                        series.ChangeView(ViewType.Line);
                    }
                    else if (_report.GraphType == OlapReport.GraphTypeEnum.LineWithBars)
                    {
                        if (i == graphMixedLinePos - 1)
                        {
                            //if (!setScaling)
                            //{
                            //    // create secondary axis
                            //    SecondaryAxisY axisY = new SecondaryAxisY(series.Name);
                            //    axisY.Visible = true;
                            //    axisY.Title.Text = series.Name;
                            //    axisY.Title.Visible = true;
                            //    axisY.Alignment = AxisAlignment.Near;
                            //    ((XYDiagram)_chCtrl.Diagram).SecondaryAxesY.Add(axisY);
                            //    ((XYDiagramSeriesViewBase)series.View).AxisY = axisY;

                            //    // set default axis title
                            //    ((XYDiagram)_chCtrl.Diagram).AxisY.Title.Text = "Bar axis";
                            //    ((XYDiagram)_chCtrl.Diagram).AxisY.Title.Visible = true;
                            //}

                            // change view
                            series.ChangeView(ViewType.Line);
                        }
                        else
                        {
                            series.ChangeView(ViewType.Bar);
                        }
                    }

                    // 20 pixels per label (250 pixels for legend), othervise overlapping resolution will never finish
                    if ((size.Width - 250) / catPosCount > 20)
                    {
                        series.Label.OverlappingOptions.ResolveOverlapping = true;
                        PointOverlappingOptions poo = series.Label.OverlappingOptions as PointOverlappingOptions;
                        if (poo != null)
                        {
                            poo.AttractToMarker = true;
                        }
                    }

                    series.LegendText                   = name;
                    series.ShowInLegend                 = true;
                    series.ValueScaleType               = ScaleType.Numerical;
                    series.PointOptions.PointView       = PointView.Undefined;
                    series.LegendPointOptions.PointView = PointView.SeriesName;
                    series.Visible = true;

                    // labels orientation
                    diag.Rotated = rotateGraph;
                    if (rotateGraph)
                    {
                        diag.AxisY.Label.Antialiasing = true;
                        diag.AxisY.Label.Angle        = 315;
                    }
                    else
                    {
                        diag.AxisX.Label.Antialiasing = true;
                        diag.AxisX.Label.Angle        = 315;
                    }

                    // if scaling
                    if (setScaling)
                    {
                        diag.AxisY.Visible = false;
                    }
                }


                // prepare scaling ranges
                double scalingMin = double.MaxValue;
                double scalingMax = double.MinValue;
                if (setScaling)
                {
                    for (int l = 0; l < catPosCount; l++)
                    {
                        string val  = (pivotAxes ? _report.Cellset.GetCell(l, i).Value : _report.Cellset.GetCell(i, l).Value);
                        double dVal = 0;
                        double.TryParse(val, System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out dVal);
                        if (dVal < scalingMin)
                        {
                            scalingMin = dVal;
                        }
                        if (dVal > scalingMax)
                        {
                            scalingMax = dVal;
                        }
                    }
                }
                scalingMin = scalingMin - (scalingMax - scalingMin) * 0.1;

                // set data
                double percSum = 0;
                for (int l = 0; l < catPosCount; l++)
                {
                    string argument = "";
                    for (int m = 0; m < catMemCount; m++)
                    {
                        argument += (m == 0 ? "" : " | ") + (pivotAxes ? _report.Cellset.GetCellsetMember(0, m, l).Name : _report.Cellset.GetCellsetMember(1, m, l).Name);
                    }

                    string val = (pivotAxes ? _report.Cellset.GetCell(l, i).Value : _report.Cellset.GetCell(i, l).Value);

                    double dVal = 0;
                    double.TryParse(val, System.Globalization.NumberStyles.Float, System.Globalization.NumberFormatInfo.InvariantInfo, out dVal);
                    if (setPerc)
                    {
                        percSum += dVal;
                    }
                    else if (setScaling)
                    {
                        dVal = (scalingMax - scalingMin == 0 ? 0 : (dVal - scalingMin) / (scalingMax - scalingMin));
                    }

                    string fVal = (pivotAxes ? _report.Cellset.GetCell(l, i).FormattedValue : _report.Cellset.GetCell(i, l).FormattedValue);

                    SeriesPoint sp = new SeriesPoint(argument, new double[] { dVal });
                    sp.Tag = fVal;
                    series.Points.Add(sp);
                }

                // set custom labels and value as percentage
                for (int l = 0; l < catPosCount; l++)
                {
                    SeriesPoint sp = series.Points[l];
                    if (setPerc)
                    {
                        sp.Values[0] = sp.Values[0] / percSum;
                        sp.Tag       = sp.Values[0].ToString("P");
                    }

                    // custom point label
                    string customLabel = string.Empty;
                    if (!showValues && !showSeries && !showCats)
                    {
                        series.Label.Visible = false;
                    }
                    else
                    {
                        string fVal = (string)sp.Tag;
                        if (fVal == null || fVal == "")
                        {
                            fVal = "0";
                        }
                        customLabel  = (showSeries ? series.Name : string.Empty);
                        customLabel += (showCats ? (customLabel != string.Empty ? " | " : string.Empty) + sp.Argument : string.Empty);
                        customLabel += (showValues ? (customLabel != string.Empty ? ": " : string.Empty) + fVal : string.Empty);
                    }

                    series.Points[l].Tag = customLabel;
                }

                // for pie, layout each of series individually
                if (_report.GraphType == OlapReport.GraphTypeEnum.PieBrokenApart)
                {
                    _chCtrl.Titles.Clear();
                    _chCtrl.EndInit();
                    LayoutGraph(_report.ID.ToString() + "." + i.ToString(), size, graphPieColumns);

                    // init next chart
                    if (i < seriesPosCount - 1)
                    {
                        _chCtrl = new DevExpress.XtraCharts.Web.WebChartControl();
                        _chCtrl.BeginInit();
                    }
                }
            }


            int t2 = System.Environment.TickCount;

            if (_report.GraphType != OlapReport.GraphTypeEnum.PieBrokenApart)
            {
                ChartTitle title = new ChartTitle();
                title.Alignment = StringAlignment.Center;
                title.Lines     = new string[] { _report.Name, _report.Description };
                _chCtrl.Titles.Add(title);

                LayoutGraph(_report.ID.ToString(), size, 0);
            }

            // if LineWithBars
            if (_report.GraphType == OlapReport.GraphTypeEnum.LineWithBars)
            {
                // fill combo
                for (int i = 0; i < _chCtrl.Series.Count; i++)
                {
                    this.selMixedLinePos.Items.Add(new ListItem(_chCtrl.Series[i].Name, (i + 1).ToString()));
                }
                this.selMixedLinePos.SelectedIndex = graphMixedLinePos - 1;

                // set line as last
                if (!(_chCtrl.Series[_chCtrl.Series.Count - 1].View is LineSeriesView))
                {
                    // roll down through series
                    for (int i = graphMixedLinePos - 1; i < _chCtrl.Series.Count - 1; i++)
                    {
                        _chCtrl.Series.Swap(i, i + 1);
                    }
                }
            }

            int    t3    = System.Environment.TickCount;
            double time1 = (t3 - t2) / 1000.0;
            double time2 = (t2 - t1) / 1000.0;

            t1 = 0;
        }