public Chart GenerateChart(string title, List<AssetWeighting> model)
        {
            Chart chart1 = new Chart();
            Title title1 = GenerateTitle(title);

            View3D view3D1 = new View3D();
            RotateX rotateX1 = new RotateX() { Val = 30 };
            Perspective perspective1 = new Perspective() { Val = 30 };

            view3D1.Append(rotateX1);
            view3D1.Append(perspective1);

            PlotArea plotArea1 = new PlotArea();
            Layout layout1 = new Layout();

            Pie3DChart pie3DChart1 = new Pie3DChart();
            VaryColors varyColors1 = new VaryColors() { Val = true };

            PieChartSeries pieChartSeries1 = new PieChartSeries();
            Index index1 = new Index() { Val = (UInt32Value)0U };
            Order order1 = new Order() { Val = (UInt32Value)0U };

            // c:tx series text
            SeriesText seriesText1 = GenerateSeriesText(title, GraphData.DataColumn);

            // c:cat category axis data
            var categoryData = model.OrderByDescending(m => m.Weighting).Select(n => n.AssetClass);
            GraphData.AddTextColumn(categoryName, categoryData);
            CategoryAxisData categoryAxisData1 = GenerateCategoryAxisData(categoryData, GraphData.TextColumn);

            // c:val values
            var valuesData = model.OrderByDescending(m => m.Weighting).Select(n => n.Weighting ?? 0).ToArray();
            string valuesColumn = GraphData.AddDataColumn(seriesName, valuesData);
            Values values1 = GenerateValues(valueFormat, valuesData, valuesColumn);

            //var series = from m in model
            //             orderby m.Weighting descending
            //             select new TextSeries { Name = m.AssetClass, Values = (new List<double>() { m.Weighting ?? 0 }) };

            //string[] headers = { categoryName, seriesName };
            //GraphData.AddTextSeries(headers, series);

            pieChartSeries1.Append(index1);
            pieChartSeries1.Append(order1);
            pieChartSeries1.Append(seriesText1);
            pieChartSeries1.Append(categoryAxisData1);
            pieChartSeries1.Append(values1);

            pie3DChart1.Append(varyColors1);
            pie3DChart1.Append(pieChartSeries1);

            plotArea1.Append(layout1);
            plotArea1.Append(pie3DChart1);

            Legend legend1 = GenerateLegend(LegendPositionValues.Right);
            PlotVisibleOnly plotVisibleOnly1 = new PlotVisibleOnly() { Val = true };

            chart1.Append(title1);
            chart1.Append(view3D1);
            chart1.Append(plotArea1);
            chart1.Append(legend1);
            chart1.Append(plotVisibleOnly1);

            return chart1;
        }
Example #2
0
        internal C.PlotArea ToPlotArea()
        {
            C.PlotArea pa = new C.PlotArea();
            pa.Append(this.Layout.ToLayout());

            int iChartType;
            int i;

            // TODO: the rendering order is sort of listed in the following.
            // But apparently if you plot data series for doughnut first before bar-of-pie
            // it's different than if you plot bar-of-pie then doughnut.
            // Find out the "correct" order next version I suppose...

            // Excel 2010 apparently sets this by default for any chart...
            SLGroupDataLabelOptions gdlo = new SLGroupDataLabelOptions(this.ShapeProperties.listThemeColors);
            gdlo.ShowLegendKey = false;
            gdlo.ShowValue = false;
            gdlo.ShowCategoryName = false;
            gdlo.ShowSeriesName = false;
            gdlo.ShowPercentage = false;
            gdlo.ShowBubbleSize = false;

            #region Doughnut
            iChartType = (int)SLDataSeriesChartType.DoughnutChart;
            if (this.UsedChartTypes[iChartType])
            {
                C.DoughnutChart dc = new C.DoughnutChart();
                dc.VaryColors = new C.VaryColors() { Val = this.UsedChartOptions[iChartType].VaryColors ?? true };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        dc.Append(this.DataSeries[i].ToPieChartSeries());
                    }
                }

                dc.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                dc.Append(new C.FirstSliceAngle() { Val = this.UsedChartOptions[iChartType].FirstSliceAngle });
                dc.Append(new C.HoleSize() { Val = this.UsedChartOptions[iChartType].HoleSize });
                
                pa.Append(dc);
            }
            #endregion

            #region Bar-of-pie
            iChartType = (int)SLDataSeriesChartType.OfPieChartBar;
            if (this.UsedChartTypes[iChartType])
            {
                C.OfPieChart opc = new C.OfPieChart();
                opc.OfPieType = new C.OfPieType() { Val = C.OfPieValues.Bar };
                opc.VaryColors = new C.VaryColors() { Val = this.UsedChartOptions[iChartType].VaryColors ?? true };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        opc.Append(this.DataSeries[i].ToPieChartSeries());
                    }
                }

                opc.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                opc.Append(new C.GapWidth() { Val = this.UsedChartOptions[iChartType].GapWidth });
                
                if (this.UsedChartOptions[iChartType].HasSplit)
                {
                    opc.Append(new C.SplitType() { Val = this.UsedChartOptions[iChartType].SplitType });
                    if (this.UsedChartOptions[iChartType].SplitType != C.SplitValues.Custom)
                    {
                        opc.Append(new C.SplitPosition() { Val = this.UsedChartOptions[iChartType].SplitPosition });
                    }
                    else
                    {
                        C.CustomSplit custsplit = new C.CustomSplit();
                        foreach (int iPiePoint in this.UsedChartOptions[iChartType].SecondPiePoints)
                        {
                            custsplit.Append(new C.SecondPiePoint() { Val = (uint)iPiePoint });
                        }
                        opc.Append(custsplit);
                    }
                }

                opc.Append(new C.SecondPieSize() { Val = this.UsedChartOptions[iChartType].SecondPieSize });

                if (this.UsedChartOptions[iChartType].SeriesLinesShapeProperties.HasShapeProperties)
                {
                    opc.Append(new C.SeriesLines()
                    {
                        ChartShapeProperties = this.UsedChartOptions[iChartType].SeriesLinesShapeProperties.ToChartShapeProperties()
                    });
                }
                else
                {
                    opc.Append(new C.SeriesLines());
                }

                pa.Append(opc);
            }
            #endregion

            #region Pie-of-pie
            iChartType = (int)SLDataSeriesChartType.OfPieChartPie;
            if (this.UsedChartTypes[iChartType])
            {
                C.OfPieChart opc = new C.OfPieChart();
                opc.OfPieType = new C.OfPieType() { Val = C.OfPieValues.Pie };
                opc.VaryColors = new C.VaryColors() { Val = this.UsedChartOptions[iChartType].VaryColors ?? true };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        opc.Append(this.DataSeries[i].ToPieChartSeries());
                    }
                }

                opc.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                opc.Append(new C.GapWidth() { Val = this.UsedChartOptions[iChartType].GapWidth });

                if (this.UsedChartOptions[iChartType].HasSplit)
                {
                    opc.Append(new C.SplitType() { Val = this.UsedChartOptions[iChartType].SplitType });
                    if (this.UsedChartOptions[iChartType].SplitType != C.SplitValues.Custom)
                    {
                        opc.Append(new C.SplitPosition() { Val = this.UsedChartOptions[iChartType].SplitPosition });
                    }
                    else
                    {
                        C.CustomSplit custsplit = new C.CustomSplit();
                        foreach (int iPiePoint in this.UsedChartOptions[iChartType].SecondPiePoints)
                        {
                            custsplit.Append(new C.SecondPiePoint() { Val = (uint)iPiePoint });
                        }
                        opc.Append(custsplit);
                    }
                }

                opc.Append(new C.SecondPieSize() { Val = this.UsedChartOptions[iChartType].SecondPieSize });

                if (this.UsedChartOptions[iChartType].SeriesLinesShapeProperties.HasShapeProperties)
                {
                    opc.Append(new C.SeriesLines()
                    {
                        ChartShapeProperties = this.UsedChartOptions[iChartType].SeriesLinesShapeProperties.ToChartShapeProperties()
                    });
                }
                else
                {
                    opc.Append(new C.SeriesLines());
                }

                pa.Append(opc);
            }
            #endregion

            #region Pie
            iChartType = (int)SLDataSeriesChartType.PieChart;
            if (this.UsedChartTypes[iChartType])
            {
                C.PieChart pc = new C.PieChart();
                pc.VaryColors = new C.VaryColors() { Val = this.UsedChartOptions[iChartType].VaryColors ?? true };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        pc.Append(this.DataSeries[i].ToPieChartSeries());
                    }
                }

                pc.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                pc.Append(new C.FirstSliceAngle() { Val = this.UsedChartOptions[iChartType].FirstSliceAngle });

                pa.Append(pc);
            }
            #endregion

            #region Radar primary
            iChartType = (int)SLDataSeriesChartType.RadarChartPrimary;
            if (this.UsedChartTypes[iChartType])
            {
                C.RadarChart rc = new C.RadarChart();
                rc.RadarStyle = new C.RadarStyle() { Val = this.UsedChartOptions[iChartType].RadarStyle };
                rc.VaryColors = new C.VaryColors() { Val = false };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        rc.Append(this.DataSeries[i].ToRadarChartSeries());
                    }
                }

                rc.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                rc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis1 });
                rc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis2 });

                pa.Append(rc);
            }
            #endregion

            #region Radar secondary
            iChartType = (int)SLDataSeriesChartType.RadarChartSecondary;
            if (this.UsedChartTypes[iChartType])
            {
                C.RadarChart rc = new C.RadarChart();
                rc.RadarStyle = new C.RadarStyle() { Val = this.UsedChartOptions[iChartType].RadarStyle };
                rc.VaryColors = new C.VaryColors() { Val = false };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        rc.Append(this.DataSeries[i].ToRadarChartSeries());
                    }
                }

                rc.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                rc.Append(new C.AxisId() { Val = SLConstants.SecondaryAxis1 });
                rc.Append(new C.AxisId() { Val = SLConstants.SecondaryAxis2 });

                pa.Append(rc);
            }
            #endregion

            #region Area primary
            iChartType = (int)SLDataSeriesChartType.AreaChartPrimary;
            if (this.UsedChartTypes[iChartType])
            {
                C.AreaChart ac = new C.AreaChart();
                ac.Grouping = new C.Grouping() { Val = this.UsedChartOptions[iChartType].Grouping };
                ac.VaryColors = new C.VaryColors() { Val = false };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        ac.Append(this.DataSeries[i].ToAreaChartSeries());
                    }
                }

                ac.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                ac.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis1 });
                ac.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis2 });

                pa.Append(ac);
            }
            #endregion

            #region Area secondary
            iChartType = (int)SLDataSeriesChartType.AreaChartSecondary;
            if (this.UsedChartTypes[iChartType])
            {
                C.AreaChart ac = new C.AreaChart();
                ac.Grouping = new C.Grouping() { Val = this.UsedChartOptions[iChartType].Grouping };
                ac.VaryColors = new C.VaryColors() { Val = false };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        ac.Append(this.DataSeries[i].ToAreaChartSeries());
                    }
                }

                ac.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                ac.Append(new C.AxisId() { Val = SLConstants.SecondaryAxis1 });
                ac.Append(new C.AxisId() { Val = SLConstants.SecondaryAxis2 });

                pa.Append(ac);
            }
            #endregion

            #region Column primary
            iChartType = (int)SLDataSeriesChartType.BarChartColumnPrimary;
            if (this.UsedChartTypes[iChartType])
            {
                C.BarChart bc = new C.BarChart();
                bc.BarDirection = new C.BarDirection() { Val = C.BarDirectionValues.Column };
                bc.BarGrouping = new C.BarGrouping() { Val = this.UsedChartOptions[iChartType].BarGrouping };
                bc.VaryColors = new C.VaryColors() { Val = false };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        bc.Append(this.DataSeries[i].ToBarChartSeries());
                    }
                }

                bc.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                bc.Append(new C.GapWidth() { Val = this.UsedChartOptions[iChartType].GapWidth });

                if (this.UsedChartOptions[iChartType].Overlap != 0)
                {
                    bc.Append(new C.Overlap() { Val = this.UsedChartOptions[iChartType].Overlap });
                }

                bc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis1 });
                bc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis2 });

                pa.Append(bc);
            }
            #endregion

            #region Column secondary
            iChartType = (int)SLDataSeriesChartType.BarChartColumnSecondary;
            if (this.UsedChartTypes[iChartType])
            {
                C.BarChart bc = new C.BarChart();
                bc.BarDirection = new C.BarDirection() { Val = C.BarDirectionValues.Column };
                bc.BarGrouping = new C.BarGrouping() { Val = this.UsedChartOptions[iChartType].BarGrouping };
                bc.VaryColors = new C.VaryColors() { Val = false };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        bc.Append(this.DataSeries[i].ToBarChartSeries());
                    }
                }

                bc.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                bc.Append(new C.GapWidth() { Val = this.UsedChartOptions[iChartType].GapWidth });

                if (this.UsedChartOptions[iChartType].Overlap != 0)
                {
                    bc.Append(new C.Overlap() { Val = this.UsedChartOptions[iChartType].Overlap });
                }

                bc.Append(new C.AxisId() { Val = SLConstants.SecondaryAxis1 });
                bc.Append(new C.AxisId() { Val = SLConstants.SecondaryAxis2 });

                pa.Append(bc);
            }
            #endregion

            #region Bar primary
            iChartType = (int)SLDataSeriesChartType.BarChartBarPrimary;
            if (this.UsedChartTypes[iChartType])
            {
                C.BarChart bc = new C.BarChart();
                bc.BarDirection = new C.BarDirection() { Val = C.BarDirectionValues.Bar };
                bc.BarGrouping = new C.BarGrouping() { Val = this.UsedChartOptions[iChartType].BarGrouping };
                bc.VaryColors = new C.VaryColors() { Val = false };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        bc.Append(this.DataSeries[i].ToBarChartSeries());
                    }
                }

                bc.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                bc.Append(new C.GapWidth() { Val = this.UsedChartOptions[iChartType].GapWidth });

                if (this.UsedChartOptions[iChartType].Overlap != 0)
                {
                    bc.Append(new C.Overlap() { Val = this.UsedChartOptions[iChartType].Overlap });
                }

                bc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis1 });
                bc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis2 });

                pa.Append(bc);
            }
            #endregion

            #region Bar secondary
            iChartType = (int)SLDataSeriesChartType.BarChartBarSecondary;
            if (this.UsedChartTypes[iChartType])
            {
                C.BarChart bc = new C.BarChart();
                bc.BarDirection = new C.BarDirection() { Val = C.BarDirectionValues.Bar };
                bc.BarGrouping = new C.BarGrouping() { Val = this.UsedChartOptions[iChartType].BarGrouping };
                bc.VaryColors = new C.VaryColors() { Val = false };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        bc.Append(this.DataSeries[i].ToBarChartSeries());
                    }
                }

                bc.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                bc.Append(new C.GapWidth() { Val = this.UsedChartOptions[iChartType].GapWidth });

                if (this.UsedChartOptions[iChartType].Overlap != 0)
                {
                    bc.Append(new C.Overlap() { Val = this.UsedChartOptions[iChartType].Overlap });
                }

                bc.Append(new C.AxisId() { Val = SLConstants.SecondaryAxis1 });
                bc.Append(new C.AxisId() { Val = SLConstants.SecondaryAxis2 });

                pa.Append(bc);
            }
            #endregion

            #region Scatter primary
            iChartType = (int)SLDataSeriesChartType.ScatterChartPrimary;
            if (this.UsedChartTypes[iChartType])
            {
                C.ScatterChart sc = new C.ScatterChart();
                sc.ScatterStyle = new C.ScatterStyle() { Val = this.UsedChartOptions[iChartType].ScatterStyle };
                sc.VaryColors = new C.VaryColors() { Val = false };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        sc.Append(this.DataSeries[i].ToScatterChartSeries());
                    }
                }

                sc.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                sc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis1 });
                sc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis2 });

                pa.Append(sc);
            }
            #endregion

            #region Scatter secondary
            iChartType = (int)SLDataSeriesChartType.ScatterChartSecondary;
            if (this.UsedChartTypes[iChartType])
            {
                C.ScatterChart sc = new C.ScatterChart();
                sc.ScatterStyle = new C.ScatterStyle() { Val = this.UsedChartOptions[iChartType].ScatterStyle };
                sc.VaryColors = new C.VaryColors() { Val = false };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        sc.Append(this.DataSeries[i].ToScatterChartSeries());
                    }
                }

                sc.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                sc.Append(new C.AxisId() { Val = SLConstants.SecondaryAxis1 });
                sc.Append(new C.AxisId() { Val = SLConstants.SecondaryAxis2 });

                pa.Append(sc);
            }
            #endregion

            #region Line primary
            iChartType = (int)SLDataSeriesChartType.LineChartPrimary;
            if (this.UsedChartTypes[iChartType])
            {
                C.LineChart lc = new C.LineChart();
                lc.Grouping = new C.Grouping() { Val = this.UsedChartOptions[iChartType].Grouping };
                lc.VaryColors = new C.VaryColors() { Val = false };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        lc.Append(this.DataSeries[i].ToLineChartSeries());
                    }
                }

                lc.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                lc.Append(new C.ShowMarker() { Val = this.UsedChartOptions[iChartType].ShowMarker });
                lc.Append(new C.Smooth() { Val = this.UsedChartOptions[iChartType].Smooth });

                lc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis1 });
                lc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis2 });

                pa.Append(lc);
            }
            #endregion

            #region Line secondary
            iChartType = (int)SLDataSeriesChartType.LineChartSecondary;
            if (this.UsedChartTypes[iChartType])
            {
                C.LineChart lc = new C.LineChart();
                lc.Grouping = new C.Grouping() { Val = this.UsedChartOptions[iChartType].Grouping };
                lc.VaryColors = new C.VaryColors() { Val = false };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        lc.Append(this.DataSeries[i].ToLineChartSeries());
                    }
                }

                lc.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                lc.Append(new C.ShowMarker() { Val = this.UsedChartOptions[iChartType].ShowMarker });
                lc.Append(new C.Smooth() { Val = this.UsedChartOptions[iChartType].Smooth });

                lc.Append(new C.AxisId() { Val = SLConstants.SecondaryAxis1 });
                lc.Append(new C.AxisId() { Val = SLConstants.SecondaryAxis2 });

                pa.Append(lc);
            }
            #endregion

            #region Area3D
            iChartType = (int)SLDataSeriesChartType.Area3DChart;
            if (this.UsedChartTypes[iChartType])
            {
                C.Area3DChart ac = new C.Area3DChart();
                ac.Grouping = new C.Grouping() { Val = this.UsedChartOptions[iChartType].Grouping };
                ac.VaryColors = new C.VaryColors() { Val = false };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        ac.Append(this.DataSeries[i].ToAreaChartSeries());
                    }
                }

                ac.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                if (this.UsedChartOptions[iChartType].GapDepth != 150)
                {
                    ac.Append(new C.GapDepth() { Val = this.UsedChartOptions[iChartType].GapDepth });
                }

                ac.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis1 });
                ac.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis2 });
                ac.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis3 });

                pa.Append(ac);
            }
            #endregion

            #region Bar3D
            iChartType = (int)SLDataSeriesChartType.Bar3DChart;
            if (this.UsedChartTypes[iChartType])
            {
                C.Bar3DChart bc = new C.Bar3DChart();
                bc.BarDirection = new C.BarDirection() { Val = this.UsedChartOptions[iChartType].BarDirection };
                bc.BarGrouping = new C.BarGrouping() { Val = this.UsedChartOptions[iChartType].BarGrouping };
                bc.VaryColors = new C.VaryColors() { Val = false };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        bc.Append(this.DataSeries[i].ToBarChartSeries());
                    }
                }

                bc.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                bc.Append(new C.GapWidth() { Val = this.UsedChartOptions[iChartType].GapWidth });

                if (this.UsedChartOptions[iChartType].GapDepth != 150)
                {
                    bc.Append(new C.GapDepth() { Val = this.UsedChartOptions[iChartType].GapDepth });
                }

                bc.Append(new C.Shape() { Val = this.UsedChartOptions[iChartType].Shape });

                bc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis1 });
                bc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis2 });
                bc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis3 });

                pa.Append(bc);
            }
            #endregion

            #region Bubble
            iChartType = (int)SLDataSeriesChartType.BubbleChart;
            if (this.UsedChartTypes[iChartType])
            {
                C.BubbleChart bc = new C.BubbleChart();
                bc.VaryColors = new C.VaryColors() { Val = false };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        bc.Append(this.DataSeries[i].ToBubbleChartSeries());
                    }
                }

                bc.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                if (!this.UsedChartOptions[iChartType].Bubble3D)
                {
                    bc.Append(new C.Bubble3D() { Val = this.UsedChartOptions[iChartType].Bubble3D });
                }

                if (this.UsedChartOptions[iChartType].BubbleScale != 100)
                {
                    bc.Append(new C.BubbleScale() { Val = this.UsedChartOptions[iChartType].BubbleScale });
                }

                if (!this.UsedChartOptions[iChartType].ShowNegativeBubbles)
                {
                    bc.Append(new C.ShowNegativeBubbles() { Val = this.UsedChartOptions[iChartType].ShowNegativeBubbles });
                }

                if (this.UsedChartOptions[iChartType].SizeRepresents != C.SizeRepresentsValues.Area)
                {
                    bc.Append(new C.SizeRepresents() { Val = this.UsedChartOptions[iChartType].SizeRepresents });
                }

                bc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis1 });
                bc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis2 });

                pa.Append(bc);
            }
            #endregion

            #region Line3D
            iChartType = (int)SLDataSeriesChartType.Line3DChart;
            if (this.UsedChartTypes[iChartType])
            {
                C.Line3DChart lc = new C.Line3DChart();
                lc.Grouping = new C.Grouping() { Val = this.UsedChartOptions[iChartType].Grouping };
                lc.VaryColors = new C.VaryColors() { Val = false };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        lc.Append(this.DataSeries[i].ToLineChartSeries());
                    }
                }

                lc.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                if (this.UsedChartOptions[iChartType].GapDepth != 150)
                {
                    lc.Append(new C.GapDepth() { Val = this.UsedChartOptions[iChartType].GapDepth });
                }

                lc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis1 });
                lc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis2 });
                lc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis3 });

                pa.Append(lc);
            }
            #endregion

            #region Pie3D
            iChartType = (int)SLDataSeriesChartType.Pie3DChart;
            if (this.UsedChartTypes[iChartType])
            {
                C.Pie3DChart pc = new C.Pie3DChart();
                pc.VaryColors = new C.VaryColors() { Val = this.UsedChartOptions[iChartType].VaryColors ?? true };

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        pc.Append(this.DataSeries[i].ToPieChartSeries());
                    }
                }

                pc.Append(gdlo.ToDataLabels(new Dictionary<int, SLDataLabelOptions>(), false));

                pa.Append(pc);
            }
            #endregion

            #region Surface
            iChartType = (int)SLDataSeriesChartType.SurfaceChart;
            if (this.UsedChartTypes[iChartType])
            {
                C.SurfaceChart sc = new C.SurfaceChart();
                if (this.UsedChartOptions[iChartType].bWireframe != null)
                {
                    sc.Wireframe = new C.Wireframe() { Val = this.UsedChartOptions[iChartType].Wireframe };
                }

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        sc.Append(this.DataSeries[i].ToSurfaceChartSeries());
                    }
                }

                sc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis1 });
                sc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis2 });
                sc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis3 });

                pa.Append(sc);
            }
            #endregion

            #region Surface3D
            iChartType = (int)SLDataSeriesChartType.Surface3DChart;
            if (this.UsedChartTypes[iChartType])
            {
                C.Surface3DChart sc = new C.Surface3DChart();
                if (this.UsedChartOptions[iChartType].bWireframe != null)
                {
                    sc.Wireframe = new C.Wireframe() { Val = this.UsedChartOptions[iChartType].Wireframe };
                }

                for (i = 0; i < this.DataSeries.Count; ++i)
                {
                    if ((int)this.DataSeries[i].ChartType == iChartType)
                    {
                        sc.Append(this.DataSeries[i].ToSurfaceChartSeries());
                    }
                }

                sc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis1 });
                sc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis2 });
                sc.Append(new C.AxisId() { Val = SLConstants.PrimaryAxis3 });

                pa.Append(sc);
            }
            #endregion

            if (this.HasPrimaryAxes)
            {
                this.PrimaryTextAxis.IsCrosses = this.PrimaryValueAxis.OtherAxisIsCrosses;
                this.PrimaryTextAxis.Crosses = this.PrimaryValueAxis.OtherAxisCrosses;
                this.PrimaryTextAxis.CrossesAt = this.PrimaryValueAxis.OtherAxisCrossesAt;

                this.PrimaryTextAxis.OtherAxisIsInReverseOrder = this.PrimaryValueAxis.InReverseOrder;

                if (this.PrimaryValueAxis.OtherAxisIsCrosses != null
                    && this.PrimaryValueAxis.OtherAxisIsCrosses.Value
                    && this.PrimaryValueAxis.OtherAxisCrosses == C.CrossesValues.Maximum)
                {
                    this.PrimaryTextAxis.OtherAxisCrossedAtMaximum = true;
                }
                else
                {
                    this.PrimaryTextAxis.OtherAxisCrossedAtMaximum = false;
                }

                this.PrimaryValueAxis.IsCrosses = this.PrimaryTextAxis.OtherAxisIsCrosses;
                this.PrimaryValueAxis.Crosses = this.PrimaryTextAxis.OtherAxisCrosses;
                this.PrimaryValueAxis.CrossesAt = this.PrimaryTextAxis.OtherAxisCrossesAt;

                // value axis takes on text axis CrossBetween.
                this.PrimaryValueAxis.CrossBetween = this.PrimaryTextAxis.CrossBetween;

                this.PrimaryValueAxis.OtherAxisIsInReverseOrder = this.PrimaryTextAxis.InReverseOrder;

                if (this.PrimaryTextAxis.OtherAxisIsCrosses != null
                    && this.PrimaryTextAxis.OtherAxisIsCrosses.Value
                    && this.PrimaryTextAxis.OtherAxisCrosses == C.CrossesValues.Maximum)
                {
                    this.PrimaryValueAxis.OtherAxisCrossedAtMaximum = true;
                }
                else
                {
                    this.PrimaryValueAxis.OtherAxisCrossedAtMaximum = false;
                }

                switch (this.PrimaryTextAxis.AxisType)
                {
                    case SLAxisType.Category:
                        pa.Append(this.PrimaryTextAxis.ToCategoryAxis());
                        break;
                    case SLAxisType.Date:
                        pa.Append(this.PrimaryTextAxis.ToDateAxis());
                        break;
                    case SLAxisType.Value:
                        pa.Append(this.PrimaryTextAxis.ToValueAxis());
                        break;
                }
                pa.Append(this.PrimaryValueAxis.ToValueAxis());
            }

            if (this.HasDepthAxis)
            {
                pa.Append(this.DepthAxis.ToSeriesAxis());
            }

            if (this.HasSecondaryAxes)
            {
                this.SecondaryTextAxis.IsCrosses = this.SecondaryValueAxis.OtherAxisIsCrosses;
                this.SecondaryTextAxis.Crosses = this.SecondaryValueAxis.OtherAxisCrosses;
                this.SecondaryTextAxis.CrossesAt = this.SecondaryValueAxis.OtherAxisCrossesAt;

                this.SecondaryTextAxis.OtherAxisIsInReverseOrder = this.SecondaryValueAxis.InReverseOrder;

                if (this.SecondaryValueAxis.OtherAxisIsCrosses != null
                    && this.SecondaryValueAxis.OtherAxisIsCrosses.Value
                    && this.SecondaryValueAxis.OtherAxisCrosses == C.CrossesValues.Maximum)
                {
                    this.SecondaryTextAxis.OtherAxisCrossedAtMaximum = true;
                }
                else
                {
                    this.SecondaryTextAxis.OtherAxisCrossedAtMaximum = false;
                }

                this.SecondaryValueAxis.IsCrosses = this.SecondaryTextAxis.OtherAxisIsCrosses;
                this.SecondaryValueAxis.Crosses = this.SecondaryTextAxis.OtherAxisCrosses;
                this.SecondaryValueAxis.CrossesAt = this.SecondaryTextAxis.OtherAxisCrossesAt;

                // value axis takes on text axis CrossBetween.
                this.SecondaryValueAxis.CrossBetween = this.SecondaryTextAxis.CrossBetween;

                this.SecondaryValueAxis.OtherAxisIsInReverseOrder = this.SecondaryTextAxis.InReverseOrder;

                if (this.SecondaryTextAxis.OtherAxisIsCrosses != null
                    && this.SecondaryTextAxis.OtherAxisIsCrosses.Value
                    && this.SecondaryTextAxis.OtherAxisCrosses == C.CrossesValues.Maximum)
                {
                    this.SecondaryValueAxis.OtherAxisCrossedAtMaximum = true;
                }
                else
                {
                    this.SecondaryValueAxis.OtherAxisCrossedAtMaximum = false;
                }

                // the order of axes is:
                // 1) primary category/date/value axis
                // 2) primary value axis
                // 3) secondary value axis
                // 4) secondary category/date/value axis
                pa.Append(this.SecondaryValueAxis.ToValueAxis());
                switch (this.SecondaryTextAxis.AxisType)
                {
                    case SLAxisType.Category:
                        pa.Append(this.SecondaryTextAxis.ToCategoryAxis());
                        break;
                    case SLAxisType.Date:
                        pa.Append(this.SecondaryTextAxis.ToDateAxis());
                        break;
                    case SLAxisType.Value:
                        pa.Append(this.SecondaryTextAxis.ToValueAxis());
                        break;
                }
            }

            if (this.ShowDataTable) pa.Append(this.DataTable.ToDataTable());

            if (this.ShapeProperties.HasShapeProperties) pa.Append(this.ShapeProperties.ToChartShapeProperties());

            return pa;
        }
        // Create Chart in Word document
        public void CreateChart(List <ChartSubArea> chartList)
        {
            // Get MainDocumentPart of Document
            MainDocumentPart mainPart = document.AddMainDocumentPart();

            mainPart.Document = new Document(new Body());

            // Create ChartPart object in Word Document
            ChartPart chartPart = mainPart.AddNewPart <ChartPart>("rId110");

            // the root element of chartPart
            dc.ChartSpace chartSpace = new dc.ChartSpace();
            chartSpace.Append(new dc.EditingLanguage()
            {
                Val = "en-us"
            });

            // Create Chart
            dc.Chart chart = new dc.Chart();
            chart.Append(new dc.AutoTitleDeleted()
            {
                Val = true
            });

            // Define the 3D view
            dc.View3D view3D = new dc.View3D();
            view3D.Append(new dc.RotateX()
            {
                Val = 30
            });
            view3D.Append(new dc.RotateY()
            {
                Val = 0
            });

            // Intiliazes a new instance of the PlotArea class
            dc.PlotArea plotArea = new dc.PlotArea();
            plotArea.Append(new dc.Layout());

            // the type of Chart
            dc.Pie3DChart pie3DChart = new dc.Pie3DChart();
            pie3DChart.Append(new dc.VaryColors()
            {
                Val = true
            });
            dc.PieChartSeries pieChartSers = new dc.PieChartSeries();
            pieChartSers.Append(new dc.Index()
            {
                Val = 0U
            });
            pieChartSers.Append(new dc.Order()
            {
                Val = 0U
            });
            dc.SeriesText seriesText = new dc.SeriesText();
            seriesText.Append(new dc.NumericValue()
            {
                Text = "Series"
            });

            uint   rowcount = 0;
            uint   count    = UInt32.Parse(chartList.Count.ToString());
            string endCell  = (count + 1).ToString();

            dc.ChartShapeProperties chartShapePros = new dc.ChartShapeProperties();

            // Define cell for lable information
            dc.CategoryAxisData cateAxisData = new dc.CategoryAxisData();
            dc.StringReference  stringRef    = new dc.StringReference();
            stringRef.Append(new dc.Formula()
            {
                Text = "Main!$A$2:$A$" + endCell
            });
            dc.StringCache stringCache = new dc.StringCache();
            stringCache.Append(new dc.PointCount()
            {
                Val = count
            });

            // Define cells for value information
            dc.Values          values = new dc.Values();
            dc.NumberReference numRef = new dc.NumberReference();
            numRef.Append(new dc.Formula()
            {
                Text = "Main!$B$2:$B$" + endCell
            });

            dc.NumberingCache numCache = new dc.NumberingCache();
            numCache.Append(new dc.FormatCode()
            {
                Text = "General"
            });
            numCache.Append(new dc.PointCount()
            {
                Val = count
            });

            // Fill data for chart
            foreach (var item in chartList)
            {
                if (count == 0)
                {
                    chartShapePros.Append(new d.SolidFill(new d.SchemeColor()
                    {
                        Val = item.Color
                    }));
                    pieChartSers.Append(chartShapePros);
                }
                else
                {
                    dc.DataPoint dataPoint = new dc.DataPoint();
                    dataPoint.Append(new dc.Index()
                    {
                        Val = rowcount
                    });
                    chartShapePros = new dc.ChartShapeProperties();
                    chartShapePros.Append(new d.SolidFill(new d.SchemeColor()
                    {
                        Val = item.Color
                    }));
                    dataPoint.Append(chartShapePros);
                    pieChartSers.Append(dataPoint);
                }

                dc.StringPoint stringPoint = new dc.StringPoint()
                {
                    Index = rowcount
                };
                stringPoint.Append(new dc.NumericValue()
                {
                    Text = item.Label
                });
                stringCache.Append(stringPoint);

                dc.NumericPoint numericPoint = new dc.NumericPoint()
                {
                    Index = rowcount
                };
                numericPoint.Append(new dc.NumericValue()
                {
                    Text = item.Value
                });
                numCache.Append(numericPoint);
                rowcount++;
            }

            // Create c:cat and c:val element
            stringRef.Append(stringCache);
            cateAxisData.Append(stringRef);
            numRef.Append(numCache);
            values.Append(numRef);

            // Append c:cat and c:val to the end of c:ser element
            pieChartSers.Append(cateAxisData);
            pieChartSers.Append(values);

            // Append c:ser to the end of c:pie3DChart element
            pie3DChart.Append(pieChartSers);

            // Append c:pie3DChart to the end of s:plotArea element
            plotArea.Append(pie3DChart);

            // create child elements of the c:legend element
            dc.Legend legend = new dc.Legend();
            legend.Append(new dc.LegendPosition()
            {
                Val = LegendPositionValues.Right
            });
            dc.Overlay overlay = new dc.Overlay()
            {
                Val = false
            };
            legend.Append(overlay);

            dc.TextProperties textPros = new TextProperties();
            textPros.Append(new d.BodyProperties());
            textPros.Append(new d.ListStyle());

            d.Paragraph                  paragraph       = new d.Paragraph();
            d.ParagraphProperties        paraPros        = new d.ParagraphProperties();
            d.DefaultParagraphProperties defaultParaPros = new d.DefaultParagraphProperties();
            defaultParaPros.Append(new d.LatinFont()
            {
                Typeface = "Arial", PitchFamily = 34, CharacterSet = 0
            });
            defaultParaPros.Append(new d.ComplexScriptFont()
            {
                Typeface = "Arial", PitchFamily = 34, CharacterSet = 0
            });
            paraPros.Append(defaultParaPros);
            paragraph.Append(paraPros);
            paragraph.Append(new d.EndParagraphRunProperties()
            {
                Language = "en-Us"
            });

            textPros.Append(paragraph);
            legend.Append(textPros);

            // Append c:view3D, c:plotArea and c:legend elements to the end of c:chart element
            chart.Append(view3D);
            chart.Append(plotArea);
            chart.Append(legend);

            // Append the c:chart element to the end of c:chartSpace element
            chartSpace.Append(chart);

            // Create c:spPr Elements and fill the child elements of it
            chartShapePros = new dc.ChartShapeProperties();
            d.Outline outline = new d.Outline();
            outline.Append(new d.NoFill());
            chartShapePros.Append(outline);

            // Append c:spPr element to the end of c:chartSpace element
            chartSpace.Append(chartShapePros);

            chartPart.ChartSpace = chartSpace;

            // Generate content of the MainDocumentPart
            GeneratePartContent(mainPart);
        }
        internal C.PlotArea ToPlotArea(bool IsStylish = false)
        {
            var pa = new C.PlotArea();

            pa.Append(Layout.ToLayout());

            int iChartType;
            int i;

            // TODO: the rendering order is sort of listed in the following.
            // But apparently if you plot data series for doughnut first before bar-of-pie
            // it's different than if you plot bar-of-pie then doughnut.
            // Find out the "correct" order next version I suppose...

            // Excel 2010 apparently sets this by default for any chart...
            var gdlo = new SLGroupDataLabelOptions(ShapeProperties.listThemeColors);

            gdlo.ShowLegendKey    = false;
            gdlo.ShowValue        = false;
            gdlo.ShowCategoryName = false;
            gdlo.ShowSeriesName   = false;
            gdlo.ShowPercentage   = false;
            gdlo.ShowBubbleSize   = false;

            #region Doughnut

            iChartType = (int)SLDataSeriesChartType.DoughnutChart;
            if (UsedChartTypes[iChartType])
            {
                var dc = new C.DoughnutChart();
                dc.VaryColors = new C.VaryColors {
                    Val = UsedChartOptions[iChartType].VaryColors ?? true
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        dc.Append(DataSeries[i].ToPieChartSeries(IsStylish));
                    }
                }

                dc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                dc.Append(new C.FirstSliceAngle {
                    Val = UsedChartOptions[iChartType].FirstSliceAngle
                });
                dc.Append(new C.HoleSize {
                    Val = UsedChartOptions[iChartType].HoleSize
                });

                pa.Append(dc);
            }

            #endregion

            #region Bar-of-pie

            iChartType = (int)SLDataSeriesChartType.OfPieChartBar;
            if (UsedChartTypes[iChartType])
            {
                var opc = new C.OfPieChart();
                opc.OfPieType = new C.OfPieType {
                    Val = C.OfPieValues.Bar
                };
                opc.VaryColors = new C.VaryColors {
                    Val = UsedChartOptions[iChartType].VaryColors ?? true
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        opc.Append(DataSeries[i].ToPieChartSeries(IsStylish));
                    }
                }

                opc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                opc.Append(new C.GapWidth {
                    Val = UsedChartOptions[iChartType].GapWidth
                });

                if (UsedChartOptions[iChartType].HasSplit)
                {
                    opc.Append(new C.SplitType {
                        Val = UsedChartOptions[iChartType].SplitType
                    });
                    if (UsedChartOptions[iChartType].SplitType != C.SplitValues.Custom)
                    {
                        opc.Append(new C.SplitPosition {
                            Val = UsedChartOptions[iChartType].SplitPosition
                        });
                    }
                    else
                    {
                        var custsplit = new C.CustomSplit();
                        foreach (var iPiePoint in UsedChartOptions[iChartType].SecondPiePoints)
                        {
                            custsplit.Append(new C.SecondPiePoint {
                                Val = (uint)iPiePoint
                            });
                        }
                        opc.Append(custsplit);
                    }
                }

                opc.Append(new C.SecondPieSize {
                    Val = UsedChartOptions[iChartType].SecondPieSize
                });

                if (UsedChartOptions[iChartType].SeriesLinesShapeProperties.HasShapeProperties)
                {
                    opc.Append(new C.SeriesLines
                    {
                        ChartShapeProperties =
                            UsedChartOptions[iChartType].SeriesLinesShapeProperties.ToChartShapeProperties()
                    });
                }
                else
                {
                    opc.Append(new C.SeriesLines());
                }

                pa.Append(opc);
            }

            #endregion

            #region Pie-of-pie

            iChartType = (int)SLDataSeriesChartType.OfPieChartPie;
            if (UsedChartTypes[iChartType])
            {
                var opc = new C.OfPieChart();
                opc.OfPieType = new C.OfPieType {
                    Val = C.OfPieValues.Pie
                };
                opc.VaryColors = new C.VaryColors {
                    Val = UsedChartOptions[iChartType].VaryColors ?? true
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        opc.Append(DataSeries[i].ToPieChartSeries(IsStylish));
                    }
                }

                opc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                opc.Append(new C.GapWidth {
                    Val = UsedChartOptions[iChartType].GapWidth
                });

                if (UsedChartOptions[iChartType].HasSplit)
                {
                    opc.Append(new C.SplitType {
                        Val = UsedChartOptions[iChartType].SplitType
                    });
                    if (UsedChartOptions[iChartType].SplitType != C.SplitValues.Custom)
                    {
                        opc.Append(new C.SplitPosition {
                            Val = UsedChartOptions[iChartType].SplitPosition
                        });
                    }
                    else
                    {
                        var custsplit = new C.CustomSplit();
                        foreach (var iPiePoint in UsedChartOptions[iChartType].SecondPiePoints)
                        {
                            custsplit.Append(new C.SecondPiePoint {
                                Val = (uint)iPiePoint
                            });
                        }
                        opc.Append(custsplit);
                    }
                }

                opc.Append(new C.SecondPieSize {
                    Val = UsedChartOptions[iChartType].SecondPieSize
                });

                if (UsedChartOptions[iChartType].SeriesLinesShapeProperties.HasShapeProperties)
                {
                    opc.Append(new C.SeriesLines
                    {
                        ChartShapeProperties =
                            UsedChartOptions[iChartType].SeriesLinesShapeProperties.ToChartShapeProperties()
                    });
                }
                else
                {
                    opc.Append(new C.SeriesLines());
                }

                pa.Append(opc);
            }

            #endregion

            #region Pie

            iChartType = (int)SLDataSeriesChartType.PieChart;
            if (UsedChartTypes[iChartType])
            {
                var pc = new C.PieChart();
                pc.VaryColors = new C.VaryColors {
                    Val = UsedChartOptions[iChartType].VaryColors ?? true
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        pc.Append(DataSeries[i].ToPieChartSeries(IsStylish));
                    }
                }

                pc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                pc.Append(new C.FirstSliceAngle {
                    Val = UsedChartOptions[iChartType].FirstSliceAngle
                });

                pa.Append(pc);
            }

            #endregion

            #region Radar primary

            iChartType = (int)SLDataSeriesChartType.RadarChartPrimary;
            if (UsedChartTypes[iChartType])
            {
                var rc = new C.RadarChart();
                rc.RadarStyle = new C.RadarStyle {
                    Val = UsedChartOptions[iChartType].RadarStyle
                };
                rc.VaryColors = new C.VaryColors {
                    Val = false
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        rc.Append(DataSeries[i].ToRadarChartSeries(IsStylish));
                    }
                }

                rc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                rc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis1
                });
                rc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis2
                });

                pa.Append(rc);
            }

            #endregion

            #region Radar secondary

            iChartType = (int)SLDataSeriesChartType.RadarChartSecondary;
            if (UsedChartTypes[iChartType])
            {
                var rc = new C.RadarChart();
                rc.RadarStyle = new C.RadarStyle {
                    Val = UsedChartOptions[iChartType].RadarStyle
                };
                rc.VaryColors = new C.VaryColors {
                    Val = false
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        rc.Append(DataSeries[i].ToRadarChartSeries(IsStylish));
                    }
                }

                rc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                rc.Append(new C.AxisId {
                    Val = SLConstants.SecondaryAxis1
                });
                rc.Append(new C.AxisId {
                    Val = SLConstants.SecondaryAxis2
                });

                pa.Append(rc);
            }

            #endregion

            #region Area primary

            iChartType = (int)SLDataSeriesChartType.AreaChartPrimary;
            if (UsedChartTypes[iChartType])
            {
                var ac = new C.AreaChart();
                ac.Grouping = new C.Grouping {
                    Val = UsedChartOptions[iChartType].Grouping
                };
                ac.VaryColors = new C.VaryColors {
                    Val = false
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        ac.Append(DataSeries[i].ToAreaChartSeries(IsStylish));
                    }
                }

                ac.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                if (UsedChartOptions[iChartType].HasDropLines)
                {
                    ac.Append(UsedChartOptions[iChartType].DropLines.ToDropLines(IsStylish));
                }

                ac.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis1
                });
                ac.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis2
                });

                pa.Append(ac);
            }

            #endregion

            #region Area secondary

            iChartType = (int)SLDataSeriesChartType.AreaChartSecondary;
            if (UsedChartTypes[iChartType])
            {
                var ac = new C.AreaChart();
                ac.Grouping = new C.Grouping {
                    Val = UsedChartOptions[iChartType].Grouping
                };
                ac.VaryColors = new C.VaryColors {
                    Val = false
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        ac.Append(DataSeries[i].ToAreaChartSeries(IsStylish));
                    }
                }

                ac.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                if (UsedChartOptions[iChartType].HasDropLines)
                {
                    ac.Append(UsedChartOptions[iChartType].DropLines.ToDropLines(IsStylish));
                }

                ac.Append(new C.AxisId {
                    Val = SLConstants.SecondaryAxis1
                });
                ac.Append(new C.AxisId {
                    Val = SLConstants.SecondaryAxis2
                });

                pa.Append(ac);
            }

            #endregion

            #region Column primary

            iChartType = (int)SLDataSeriesChartType.BarChartColumnPrimary;
            if (UsedChartTypes[iChartType])
            {
                var bc = new C.BarChart();
                bc.BarDirection = new C.BarDirection {
                    Val = C.BarDirectionValues.Column
                };
                bc.BarGrouping = new C.BarGrouping {
                    Val = UsedChartOptions[iChartType].BarGrouping
                };
                bc.VaryColors = new C.VaryColors {
                    Val = false
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        bc.Append(DataSeries[i].ToBarChartSeries(IsStylish));
                    }
                }

                bc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                bc.Append(new C.GapWidth {
                    Val = UsedChartOptions[iChartType].GapWidth
                });

                if (UsedChartOptions[iChartType].Overlap != 0)
                {
                    bc.Append(new C.Overlap {
                        Val = UsedChartOptions[iChartType].Overlap
                    });
                }

                bc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis1
                });
                bc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis2
                });

                pa.Append(bc);
            }

            #endregion

            #region Column secondary

            iChartType = (int)SLDataSeriesChartType.BarChartColumnSecondary;
            if (UsedChartTypes[iChartType])
            {
                var bc = new C.BarChart();
                bc.BarDirection = new C.BarDirection {
                    Val = C.BarDirectionValues.Column
                };
                bc.BarGrouping = new C.BarGrouping {
                    Val = UsedChartOptions[iChartType].BarGrouping
                };
                bc.VaryColors = new C.VaryColors {
                    Val = false
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        bc.Append(DataSeries[i].ToBarChartSeries(IsStylish));
                    }
                }

                bc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                bc.Append(new C.GapWidth {
                    Val = UsedChartOptions[iChartType].GapWidth
                });

                if (UsedChartOptions[iChartType].Overlap != 0)
                {
                    bc.Append(new C.Overlap {
                        Val = UsedChartOptions[iChartType].Overlap
                    });
                }

                bc.Append(new C.AxisId {
                    Val = SLConstants.SecondaryAxis1
                });
                bc.Append(new C.AxisId {
                    Val = SLConstants.SecondaryAxis2
                });

                pa.Append(bc);
            }

            #endregion

            #region Bar primary

            iChartType = (int)SLDataSeriesChartType.BarChartBarPrimary;
            if (UsedChartTypes[iChartType])
            {
                var bc = new C.BarChart();
                bc.BarDirection = new C.BarDirection {
                    Val = C.BarDirectionValues.Bar
                };
                bc.BarGrouping = new C.BarGrouping {
                    Val = UsedChartOptions[iChartType].BarGrouping
                };
                bc.VaryColors = new C.VaryColors {
                    Val = false
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        bc.Append(DataSeries[i].ToBarChartSeries(IsStylish));
                    }
                }

                bc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                bc.Append(new C.GapWidth {
                    Val = UsedChartOptions[iChartType].GapWidth
                });

                if (UsedChartOptions[iChartType].Overlap != 0)
                {
                    bc.Append(new C.Overlap {
                        Val = UsedChartOptions[iChartType].Overlap
                    });
                }

                bc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis1
                });
                bc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis2
                });

                pa.Append(bc);
            }

            #endregion

            #region Bar secondary

            iChartType = (int)SLDataSeriesChartType.BarChartBarSecondary;
            if (UsedChartTypes[iChartType])
            {
                var bc = new C.BarChart();
                bc.BarDirection = new C.BarDirection {
                    Val = C.BarDirectionValues.Bar
                };
                bc.BarGrouping = new C.BarGrouping {
                    Val = UsedChartOptions[iChartType].BarGrouping
                };
                bc.VaryColors = new C.VaryColors {
                    Val = false
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        bc.Append(DataSeries[i].ToBarChartSeries(IsStylish));
                    }
                }

                bc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                bc.Append(new C.GapWidth {
                    Val = UsedChartOptions[iChartType].GapWidth
                });

                if (UsedChartOptions[iChartType].Overlap != 0)
                {
                    bc.Append(new C.Overlap {
                        Val = UsedChartOptions[iChartType].Overlap
                    });
                }

                bc.Append(new C.AxisId {
                    Val = SLConstants.SecondaryAxis1
                });
                bc.Append(new C.AxisId {
                    Val = SLConstants.SecondaryAxis2
                });

                pa.Append(bc);
            }

            #endregion

            #region Scatter primary

            iChartType = (int)SLDataSeriesChartType.ScatterChartPrimary;
            if (UsedChartTypes[iChartType])
            {
                var sc = new C.ScatterChart();
                sc.ScatterStyle = new C.ScatterStyle {
                    Val = UsedChartOptions[iChartType].ScatterStyle
                };
                sc.VaryColors = new C.VaryColors {
                    Val = false
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        sc.Append(DataSeries[i].ToScatterChartSeries(IsStylish));
                    }
                }

                sc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                sc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis1
                });
                sc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis2
                });

                pa.Append(sc);
            }

            #endregion

            #region Scatter secondary

            iChartType = (int)SLDataSeriesChartType.ScatterChartSecondary;
            if (UsedChartTypes[iChartType])
            {
                var sc = new C.ScatterChart();
                sc.ScatterStyle = new C.ScatterStyle {
                    Val = UsedChartOptions[iChartType].ScatterStyle
                };
                sc.VaryColors = new C.VaryColors {
                    Val = false
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        sc.Append(DataSeries[i].ToScatterChartSeries(IsStylish));
                    }
                }

                sc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                sc.Append(new C.AxisId {
                    Val = SLConstants.SecondaryAxis1
                });
                sc.Append(new C.AxisId {
                    Val = SLConstants.SecondaryAxis2
                });

                pa.Append(sc);
            }

            #endregion

            #region Line primary

            iChartType = (int)SLDataSeriesChartType.LineChartPrimary;
            if (UsedChartTypes[iChartType])
            {
                var lc = new C.LineChart();
                lc.Grouping = new C.Grouping {
                    Val = UsedChartOptions[iChartType].Grouping
                };
                lc.VaryColors = new C.VaryColors {
                    Val = false
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        lc.Append(DataSeries[i].ToLineChartSeries(IsStylish));
                    }
                }

                lc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                if (UsedChartOptions[iChartType].HasDropLines)
                {
                    lc.Append(UsedChartOptions[iChartType].DropLines.ToDropLines(IsStylish));
                }

                lc.Append(new C.ShowMarker {
                    Val = UsedChartOptions[iChartType].ShowMarker
                });
                lc.Append(new C.Smooth {
                    Val = UsedChartOptions[iChartType].Smooth
                });

                lc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis1
                });
                lc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis2
                });

                pa.Append(lc);
            }

            #endregion

            #region Line secondary

            iChartType = (int)SLDataSeriesChartType.LineChartSecondary;
            if (UsedChartTypes[iChartType])
            {
                var lc = new C.LineChart();
                lc.Grouping = new C.Grouping {
                    Val = UsedChartOptions[iChartType].Grouping
                };
                lc.VaryColors = new C.VaryColors {
                    Val = false
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        lc.Append(DataSeries[i].ToLineChartSeries(IsStylish));
                    }
                }

                lc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                if (UsedChartOptions[iChartType].HasDropLines)
                {
                    lc.Append(UsedChartOptions[iChartType].DropLines.ToDropLines(IsStylish));
                }

                lc.Append(new C.ShowMarker {
                    Val = UsedChartOptions[iChartType].ShowMarker
                });
                lc.Append(new C.Smooth {
                    Val = UsedChartOptions[iChartType].Smooth
                });

                lc.Append(new C.AxisId {
                    Val = SLConstants.SecondaryAxis1
                });
                lc.Append(new C.AxisId {
                    Val = SLConstants.SecondaryAxis2
                });

                pa.Append(lc);
            }

            #endregion

            #region Area3D

            iChartType = (int)SLDataSeriesChartType.Area3DChart;
            if (UsedChartTypes[iChartType])
            {
                var ac = new C.Area3DChart();
                ac.Grouping = new C.Grouping {
                    Val = UsedChartOptions[iChartType].Grouping
                };
                ac.VaryColors = new C.VaryColors {
                    Val = false
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        ac.Append(DataSeries[i].ToAreaChartSeries(IsStylish));
                    }
                }

                ac.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                if (UsedChartOptions[iChartType].GapDepth != 150)
                {
                    ac.Append(new C.GapDepth {
                        Val = UsedChartOptions[iChartType].GapDepth
                    });
                }

                ac.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis1
                });
                ac.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis2
                });
                ac.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis3
                });

                pa.Append(ac);
            }

            #endregion

            #region Bar3D

            iChartType = (int)SLDataSeriesChartType.Bar3DChart;
            if (UsedChartTypes[iChartType])
            {
                var bc = new C.Bar3DChart();
                bc.BarDirection = new C.BarDirection {
                    Val = UsedChartOptions[iChartType].BarDirection
                };
                bc.BarGrouping = new C.BarGrouping {
                    Val = UsedChartOptions[iChartType].BarGrouping
                };
                bc.VaryColors = new C.VaryColors {
                    Val = false
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        bc.Append(DataSeries[i].ToBarChartSeries(IsStylish));
                    }
                }

                bc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                bc.Append(new C.GapWidth {
                    Val = UsedChartOptions[iChartType].GapWidth
                });

                if (UsedChartOptions[iChartType].GapDepth != 150)
                {
                    bc.Append(new C.GapDepth {
                        Val = UsedChartOptions[iChartType].GapDepth
                    });
                }

                bc.Append(new C.Shape {
                    Val = UsedChartOptions[iChartType].Shape
                });

                bc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis1
                });
                bc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis2
                });
                bc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis3
                });

                pa.Append(bc);
            }

            #endregion

            #region Bubble

            iChartType = (int)SLDataSeriesChartType.BubbleChart;
            if (UsedChartTypes[iChartType])
            {
                var bc = new C.BubbleChart();
                bc.VaryColors = new C.VaryColors {
                    Val = false
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        bc.Append(DataSeries[i].ToBubbleChartSeries(IsStylish));
                    }
                }

                bc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                if (!UsedChartOptions[iChartType].Bubble3D)
                {
                    bc.Append(new C.Bubble3D {
                        Val = UsedChartOptions[iChartType].Bubble3D
                    });
                }

                if (UsedChartOptions[iChartType].BubbleScale != 100)
                {
                    bc.Append(new C.BubbleScale {
                        Val = UsedChartOptions[iChartType].BubbleScale
                    });
                }

                if (!UsedChartOptions[iChartType].ShowNegativeBubbles)
                {
                    bc.Append(new C.ShowNegativeBubbles {
                        Val = UsedChartOptions[iChartType].ShowNegativeBubbles
                    });
                }

                if (UsedChartOptions[iChartType].SizeRepresents != C.SizeRepresentsValues.Area)
                {
                    bc.Append(new C.SizeRepresents {
                        Val = UsedChartOptions[iChartType].SizeRepresents
                    });
                }

                bc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis1
                });
                bc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis2
                });

                pa.Append(bc);
            }

            #endregion

            #region Line3D

            iChartType = (int)SLDataSeriesChartType.Line3DChart;
            if (UsedChartTypes[iChartType])
            {
                var lc = new C.Line3DChart();
                lc.Grouping = new C.Grouping {
                    Val = UsedChartOptions[iChartType].Grouping
                };
                lc.VaryColors = new C.VaryColors {
                    Val = false
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        lc.Append(DataSeries[i].ToLineChartSeries(IsStylish));
                    }
                }

                lc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                if (UsedChartOptions[iChartType].HasDropLines)
                {
                    lc.Append(UsedChartOptions[iChartType].DropLines.ToDropLines(IsStylish));
                }

                if (UsedChartOptions[iChartType].GapDepth != 150)
                {
                    lc.Append(new C.GapDepth {
                        Val = UsedChartOptions[iChartType].GapDepth
                    });
                }

                lc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis1
                });
                lc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis2
                });
                lc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis3
                });

                pa.Append(lc);
            }

            #endregion

            #region Pie3D

            iChartType = (int)SLDataSeriesChartType.Pie3DChart;
            if (UsedChartTypes[iChartType])
            {
                var pc = new C.Pie3DChart();
                pc.VaryColors = new C.VaryColors {
                    Val = UsedChartOptions[iChartType].VaryColors ?? true
                };

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        pc.Append(DataSeries[i].ToPieChartSeries(IsStylish));
                    }
                }

                pc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                pa.Append(pc);
            }

            #endregion

            #region Surface

            iChartType = (int)SLDataSeriesChartType.SurfaceChart;
            if (UsedChartTypes[iChartType])
            {
                var sc = new C.SurfaceChart();
                if (UsedChartOptions[iChartType].bWireframe != null)
                {
                    sc.Wireframe = new C.Wireframe {
                        Val = UsedChartOptions[iChartType].Wireframe
                    }
                }
                ;

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        sc.Append(DataSeries[i].ToSurfaceChartSeries(IsStylish));
                    }
                }

                sc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis1
                });
                sc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis2
                });
                sc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis3
                });

                pa.Append(sc);
            }

            #endregion

            #region Surface3D

            iChartType = (int)SLDataSeriesChartType.Surface3DChart;
            if (UsedChartTypes[iChartType])
            {
                var sc = new C.Surface3DChart();
                if (UsedChartOptions[iChartType].bWireframe != null)
                {
                    sc.Wireframe = new C.Wireframe {
                        Val = UsedChartOptions[iChartType].Wireframe
                    }
                }
                ;

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        sc.Append(DataSeries[i].ToSurfaceChartSeries(IsStylish));
                    }
                }

                sc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis1
                });
                sc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis2
                });
                sc.Append(new C.AxisId {
                    Val = SLConstants.PrimaryAxis3
                });

                pa.Append(sc);
            }

            #endregion

            #region Stock

            iChartType = (int)SLDataSeriesChartType.StockChart;
            if (UsedChartTypes[iChartType])
            {
                var sc = new C.StockChart();

                for (i = 0; i < DataSeries.Count; ++i)
                {
                    if ((int)DataSeries[i].ChartType == iChartType)
                    {
                        sc.Append(DataSeries[i].ToLineChartSeries(IsStylish));
                    }
                }

                sc.Append(gdlo.ToDataLabels(new Dictionary <int, SLDataLabelOptions>(), false));

                if (UsedChartOptions[iChartType].HasDropLines)
                {
                    sc.Append(UsedChartOptions[iChartType].DropLines.ToDropLines(IsStylish));
                }

                if (UsedChartOptions[iChartType].HasHighLowLines)
                {
                    sc.Append(UsedChartOptions[iChartType].HighLowLines.ToHighLowLines(IsStylish));
                }

                if (UsedChartOptions[iChartType].HasUpDownBars)
                {
                    sc.Append(UsedChartOptions[iChartType].UpDownBars.ToUpDownBars(IsStylish));
                }

                // stock charts either have a bar chart as the primary chart (the Volume) or doesn't.
                // If there is, then it's either a Volume-High-Low-Close or Volumn-Open-High-Low-Close,
                // so we use the secondary axis IDs.
                if (UsedChartTypes[(int)SLDataSeriesChartType.BarChartColumnPrimary])
                {
                    sc.Append(new C.AxisId {
                        Val = SLConstants.SecondaryAxis1
                    });
                    sc.Append(new C.AxisId {
                        Val = SLConstants.SecondaryAxis2
                    });
                }
                else
                {
                    sc.Append(new C.AxisId {
                        Val = SLConstants.PrimaryAxis1
                    });
                    sc.Append(new C.AxisId {
                        Val = SLConstants.PrimaryAxis2
                    });
                }

                pa.Append(sc);
            }

            #endregion

            if (HasPrimaryAxes)
            {
                PrimaryTextAxis.IsCrosses = PrimaryValueAxis.OtherAxisIsCrosses;
                PrimaryTextAxis.Crosses   = PrimaryValueAxis.OtherAxisCrosses;
                PrimaryTextAxis.CrossesAt = PrimaryValueAxis.OtherAxisCrossesAt;

                PrimaryTextAxis.OtherAxisIsInReverseOrder = PrimaryValueAxis.InReverseOrder;

                if ((PrimaryValueAxis.OtherAxisIsCrosses != null) &&
                    PrimaryValueAxis.OtherAxisIsCrosses.Value &&
                    (PrimaryValueAxis.OtherAxisCrosses == C.CrossesValues.Maximum))
                {
                    PrimaryTextAxis.OtherAxisCrossedAtMaximum = true;
                }
                else
                {
                    PrimaryTextAxis.OtherAxisCrossedAtMaximum = false;
                }

                PrimaryValueAxis.IsCrosses = PrimaryTextAxis.OtherAxisIsCrosses;
                PrimaryValueAxis.Crosses   = PrimaryTextAxis.OtherAxisCrosses;
                PrimaryValueAxis.CrossesAt = PrimaryTextAxis.OtherAxisCrossesAt;

                PrimaryValueAxis.OtherAxisIsInReverseOrder = PrimaryTextAxis.InReverseOrder;

                if ((PrimaryTextAxis.OtherAxisIsCrosses != null) &&
                    PrimaryTextAxis.OtherAxisIsCrosses.Value &&
                    (PrimaryTextAxis.OtherAxisCrosses == C.CrossesValues.Maximum))
                {
                    PrimaryValueAxis.OtherAxisCrossedAtMaximum = true;
                }
                else
                {
                    PrimaryValueAxis.OtherAxisCrossedAtMaximum = false;
                }

                switch (PrimaryTextAxis.AxisType)
                {
                case SLAxisType.Category:
                    pa.Append(PrimaryTextAxis.ToCategoryAxis(IsStylish));
                    break;

                case SLAxisType.Date:
                    pa.Append(PrimaryTextAxis.ToDateAxis(IsStylish));
                    break;

                case SLAxisType.Value:
                    pa.Append(PrimaryTextAxis.ToValueAxis(IsStylish));
                    break;
                }
                pa.Append(PrimaryValueAxis.ToValueAxis(IsStylish));
            }

            if (HasDepthAxis)
            {
                pa.Append(DepthAxis.ToSeriesAxis(IsStylish));
            }

            if (HasSecondaryAxes)
            {
                SecondaryTextAxis.IsCrosses = SecondaryValueAxis.OtherAxisIsCrosses;
                SecondaryTextAxis.Crosses   = SecondaryValueAxis.OtherAxisCrosses;
                SecondaryTextAxis.CrossesAt = SecondaryValueAxis.OtherAxisCrossesAt;

                SecondaryTextAxis.OtherAxisIsInReverseOrder = SecondaryValueAxis.InReverseOrder;

                if ((SecondaryValueAxis.OtherAxisIsCrosses != null) &&
                    SecondaryValueAxis.OtherAxisIsCrosses.Value &&
                    (SecondaryValueAxis.OtherAxisCrosses == C.CrossesValues.Maximum))
                {
                    SecondaryTextAxis.OtherAxisCrossedAtMaximum = true;
                }
                else
                {
                    SecondaryTextAxis.OtherAxisCrossedAtMaximum = false;
                }

                SecondaryValueAxis.IsCrosses = SecondaryTextAxis.OtherAxisIsCrosses;
                SecondaryValueAxis.Crosses   = SecondaryTextAxis.OtherAxisCrosses;
                SecondaryValueAxis.CrossesAt = SecondaryTextAxis.OtherAxisCrossesAt;

                SecondaryValueAxis.OtherAxisIsInReverseOrder = SecondaryTextAxis.InReverseOrder;

                if ((SecondaryTextAxis.OtherAxisIsCrosses != null) &&
                    SecondaryTextAxis.OtherAxisIsCrosses.Value &&
                    (SecondaryTextAxis.OtherAxisCrosses == C.CrossesValues.Maximum))
                {
                    SecondaryValueAxis.OtherAxisCrossedAtMaximum = true;
                }
                else
                {
                    SecondaryValueAxis.OtherAxisCrossedAtMaximum = false;
                }

                // the order of axes is:
                // 1) primary category/date/value axis
                // 2) primary value axis
                // 3) secondary value axis
                // 4) secondary category/date/value axis
                pa.Append(SecondaryValueAxis.ToValueAxis(IsStylish));
                switch (SecondaryTextAxis.AxisType)
                {
                case SLAxisType.Category:
                    pa.Append(SecondaryTextAxis.ToCategoryAxis(IsStylish));
                    break;

                case SLAxisType.Date:
                    pa.Append(SecondaryTextAxis.ToDateAxis(IsStylish));
                    break;

                case SLAxisType.Value:
                    pa.Append(SecondaryTextAxis.ToValueAxis(IsStylish));
                    break;
                }
            }

            if (ShowDataTable)
            {
                pa.Append(DataTable.ToDataTable(IsStylish));
            }

            if (ShapeProperties.HasShapeProperties)
            {
                pa.Append(ShapeProperties.ToChartShapeProperties(IsStylish));
            }

            return(pa);
        }