예제 #1
0
        /// <summary>
        /// Apply the chart and color style to the chart.
        /// <seealso cref="Style"/>
        /// <seealso cref="ColorsManager"/>
        /// </summary>
        public void ApplyStyles()
        {
            //Make sure we have a theme
            if (_theme.CurrentTheme == null)
            {
                _theme.CreateDefaultTheme();
            }

            if (_chart._topChart != null)
            {
                throw (new InvalidOperationException("Please style the parent chart only"));
            }
            if (_chart.VaryColors)
            {
                GenerateDataPoints();
            }
            ApplyStyle(_chart, Style.ChartArea);

            //Plotarea
            if (_chart.IsType3D())
            {
                ApplyStyle(_chart.PlotArea, Style.PlotArea3D);
                ApplyStyle(_chart.Floor, Style.Floor);
                ApplyStyle(_chart.SideWall, Style.Wall);
                ApplyStyle(_chart.BackWall, Style.Wall);
            }
            else
            {
                ApplyStyle(_chart.PlotArea, Style.PlotArea);
            }

            //Title
            if (_chart.HasTitle)
            {
                ApplyStyle(_chart.Title, Style.Title);
            }

            if (_chart.PlotArea.DataTable != null)
            {
                ApplyStyle(_chart.PlotArea.DataTable, Style.DataTable);
            }

            ApplyDataLabels();

            if (_chart.HasLegend)
            {
                ApplyStyle(_chart.Legend, Style.Legend);
            }

            if (_chart is ExcelLineChart lineChart)
            {
                if (!(lineChart.DropLine is null))
                {
                    ApplyStyle(lineChart.DropLine, Style.DropLine);
                }
                if (!(lineChart.HighLowLine is null))
                {
                    ApplyStyle(lineChart.HighLowLine, Style.HighLowLine);
                }
                if (!(lineChart.UpBar is null))
                {
                    ApplyStyle(lineChart.UpBar, Style.UpBar);
                }
                if (!(lineChart.DownBar is null))
                {
                    ApplyStyle(lineChart.DownBar, Style.DownBar);
                }
            }

            ApplyAxis();
            ApplySeries();
        }
예제 #2
0
        private void WriteWorkSheetChart_chart_plotArea(ExcelChart excelChart, XElement root)
        {
            XElement plotAreaElement = new XElement(XName.Get("plotArea", ExcelCommon.Schema_Chart));
            XElement layoutElement = new XElement(XName.Get("layout", ExcelCommon.Schema_Chart));
            plotAreaElement.Add(layoutElement);

            if (excelChart.IsType3D())
            {
                XElement view3DElement = new XElement(XName.Get("view3D", ExcelCommon.Schema_Chart));
                view3DElement.Add(new XElement(XName.Get("perspective", ExcelCommon.Schema_Chart), new XAttribute(XName.Get("val"), 30)));
                plotAreaElement.Add(view3DElement);
            }

            WriteWorkSheetChart_chart_chartType(excelChart, plotAreaElement);
            WriteWorkSheetChart_chart_Ax(excelChart, plotAreaElement);

            root.Add(plotAreaElement);
        }