Exemplo n.º 1
0
        private string GetNameOrDefault()
        {
            C.StringReference cStringReference = _seriesXmlElement.GetFirstChild <C.SeriesText>()?.StringReference;
            if (cStringReference == null)
            {
                return(null);
            }

            return(ChartReferencesParser.GetSingleString(cStringReference, SlideChart));
        }
Exemplo n.º 2
0
        private LibraryCollection <double> GetXValues()
        {
            var sdkXValues = _firstSeries.Value?.GetFirstChild <C.XValues>();

            if (sdkXValues?.NumberReference == null)
            {
                return(null);
            }

            IReadOnlyList <double> points =
                ChartReferencesParser.GetNumbersFromCacheOrSpreadsheet(sdkXValues.NumberReference, this);

            return(new LibraryCollection <double>(points));
        }
Exemplo n.º 3
0
        private IReadOnlyList <double> GetPointValues()
        {
            C.NumberReference numReference;
            C.Values          cVal = _seriesXmlElement.GetFirstChild <C.Values>();
            if (cVal != null) // scatter type chart does not have <c:val> element
            {
                numReference = cVal.NumberReference;
            }
            else
            {
                numReference = _seriesXmlElement.GetFirstChild <C.YValues>().NumberReference;
            }

            return(ChartReferencesParser.GetNumbersFromCacheOrSpreadsheet(numReference, SlideChart));
        }
Exemplo n.º 4
0
        internal static CategoryCollection Create(
            SlideChart slideChart,
            OpenXmlElement firstChartSeries,
            ChartType chartType)
        {
            if (chartType == ChartType.BubbleChart || chartType == ChartType.ScatterChart)
            {
                return(null);
            }

            var categoryList = new List <Category>();

            //  Get category data from the first series.
            //  Actually, it can be any series since all chart series contain the same categories.
            //  <c:cat>
            //      <c:strRef>
            //          <c:f>Sheet1!$A$2:$A$3</c:f>
            //          <c:strCache>
            //              <c:ptCount val="2"/>
            //              <c:pt idx="0">
            //                  <c:v>Category 1</c:v>
            //              </c:pt>
            //              <c:pt idx="1">
            //                  <c:v>Category 2</c:v>
            //              </c:pt>
            //          </c:strCache>
            //      </c:strRef>
            //  </c:cat>
            C.CategoryAxisData cCatAxisData = firstChartSeries.GetFirstChild <C.CategoryAxisData>();

            C.MultiLevelStringReference cMultiLvlStringRef = cCatAxisData.MultiLevelStringReference;
            if (cMultiLvlStringRef != null) // is it chart with multi-level category?
            {
                categoryList = GetMultiCategories(cMultiLvlStringRef);
            }
            else
            {
                C.Formula cFormula;
                IEnumerable <C.NumericValue> cachedValues; // C.NumericValue (<c:v>) can store string value
                C.NumberReference            cNumReference = cCatAxisData.NumberReference;
                C.StringReference            cStrReference = cCatAxisData.StringReference;
                if (cNumReference != null)
                {
                    cFormula     = cNumReference.Formula;
                    cachedValues = cNumReference.NumberingCache.Descendants <C.NumericValue>();
                }
                else
                {
                    cFormula     = cStrReference.Formula;
                    cachedValues = cStrReference.StringCache.Descendants <C.NumericValue>();
                }

                int xCellIdx = 0;
                var xCells   = new ResettableLazy <List <X.Cell> >(() =>
                                                                   ChartReferencesParser.GetXCellsByFormula(cFormula, slideChart));
                foreach (C.NumericValue cachedValue in cachedValues)
                {
                    categoryList.Add(new Category(xCells, xCellIdx++, cachedValue));
                }
            }

            return(new CategoryCollection(categoryList));
        }