Exemplo n.º 1
0
        internal void ApplySeries()
        {
            var dataPoint = GetDataPointStyle();
            var applyFill = (!_chart.IsTypeLine() || _chart.ChartType == eChartType.Line3D);   //Lines have no fill, except Line3D
            int serieNo   = 0;

            foreach (var chart in _chart.PlotArea.ChartTypes)
            {
                foreach (ExcelChartSerie serie in chart.Series)
                {
                    //Note: Datalabels are applied in the ApplyDataLabels method

                    //Marker
                    var items = serie.NumberOfItems;
                    ApplyStyle(serie, dataPoint, serieNo, items, applyFill);
                    if (serie is IDrawingChartMarker serieMarker && serieMarker.HasMarker())     //Applies to Line and Scatterchart series
                    {
                        ApplyStyle(serieMarker.Marker, Style.DataPointMarker, serieNo, items);
                        serieMarker.Marker.Size = Style.DataPointMarkerLayout.Size;
                        if (Style.DataPointMarkerLayout.Style != eMarkerStyle.None)
                        {
                            serieMarker.Marker.Style = Style.DataPointMarkerLayout.Style;
                        }
                    }

                    //Trendlines
                    foreach (var tl in serie.TrendLines)
                    {
                        ApplyStyle(tl, Style.Trendline);
                        ApplyStyle(tl.Label, Style.TrendlineLabel);
                    }

                    //Datapoints
                    if (serie is IDrawingChartDataPoints dps)
                    {
                        foreach (var dp in dps.DataPoints)
                        {
                            ApplyStyle(dp, dataPoint, dp.Index, items, applyFill);
                            if (dp.HasMarker())
                            {
                                ApplyStyle(dp.Marker, Style.DataPointMarker, dp.Index, items);
                                dp.Marker.Size = Style.DataPointMarkerLayout.Size;
                                if (Style.DataPointMarkerLayout.Style != eMarkerStyle.None)
                                {
                                    dp.Marker.Style = Style.DataPointMarkerLayout.Style;
                                }
                            }
                        }
                    }

                    //Errorbars
                    if (serie is ExcelChartSerieWithErrorBars chartSerieWithErrorBars && chartSerieWithErrorBars.ErrorBars != null)
                    {
                        ApplyStyle(chartSerieWithErrorBars.ErrorBars, Style.ErrorBar);
                    }
                    serieNo++;
                }
            }
        }