/// <summary>
        /// Updates the supplied series in a chart with range related information.
        /// </summary>
        /// <param name="chartSeries">The OpenXml representation of the chart which is to be updated</param>
        /// <param name="dataRangeInfo">Information relating to the category, axis and series data ranges.</param>
        /// <param name="seriesBrush">The brush which will be used when creating the series in the chart.</param>
        private static void UpdateChartSeriesDataReferences(OpenXmlCompositeElement chartSeries, ChartDataRangeInfo dataRangeInfo, Brush seriesBrush)
        {
            SeriesType seriesType = GetSeriesType(chartSeries);

            switch (seriesType)
            {
            case SeriesType.Line:
            {
                // Update series to match Excel document (leave series index/order 0 as will be set later)
                chartSeries.UpdateCategoryValueChartSeries((uint)0,         // Series Index
                                                           dataRangeInfo.SeriesTextRange,
                                                           dataRangeInfo.CategoryAxisDataRange,
                                                           dataRangeInfo.SeriesValuesRange);
                chartSeries.UpdateLineBrush(seriesBrush);
                break;
            }

            case SeriesType.Pie:
            {
                // Update series to match Excel document (leave series index/order 0 as will be set later)
                chartSeries.UpdateCategoryValueChartSeries((uint)0,         // Series Index
                                                           dataRangeInfo.SeriesTextRange,
                                                           dataRangeInfo.CategoryAxisDataRange,
                                                           dataRangeInfo.SeriesValuesRange);
                //TODO: Update based on the value, not the series....
                // chartSeries.UpdateLineBrush(seriesBrush);
                break;
            }

            case SeriesType.Scatter:
            {
                chartSeries.UpdateSeriesMarkerBrush(seriesBrush);

                // if the scatter has a trendline then update its brush to match
                var trendline = chartSeries.Descendants <DrawingCharts.Trendline>().FirstOrDefault();
                if (trendline != null)
                {
                    trendline.UpdateLineBrush(seriesBrush);
                }

                ((DrawingCharts.ScatterChartSeries)chartSeries).UpdateXYValueChartSeries((uint)0,                             // Series Index
                                                                                         dataRangeInfo.SeriesTextRange,       // Category Axis column Index
                                                                                         dataRangeInfo.CategoryAxisDataRange, // Data Column Index
                                                                                         dataRangeInfo.SeriesValuesRange);
                break;
            }
            }
        }