Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChartEx"/> class.
 /// </summary>
 public ChartEx(P.GraphicFrame grFrame, IShapeContext shapeContext, IChartRefParser chartRefParser)
 {
     _grFrame        = grFrame ?? throw new ArgumentNullException(nameof(grFrame));
     _shapeContext   = shapeContext ?? throw new ArgumentNullException(nameof(shapeContext));
     _chartRefParser = chartRefParser;
     _chartType      = new Lazy <ChartType>(GetChartType);
     _firstSeries    = new Lazy <OpenXmlElement>(GetFirstSeries);
     _xValues        = new Lazy <LibraryCollection <double> >(TryGetXValues);
     Init(); //TODO: convert to lazy loading
 }
Beispiel #2
0
        public Series(ChartType type, OpenXmlElement sdkSeries, ChartPart sdkChartPart, IChartRefParser chartRefParser)
        {
            _sdkSeries = sdkSeries ?? throw new ArgumentNullException(nameof(sdkSeries));
            Check.NotNull(sdkSeries, nameof(sdkSeries));
            Check.NotNull(sdkChartPart, nameof(sdkChartPart));

            _sdkChartPart   = sdkChartPart ?? throw new ArgumentNullException(nameof(sdkChartPart));
            _chartRefParser = chartRefParser;
            _pointValues    = new Lazy <List <double> >(GetPointValues);
            _name           = new Lazy <string>(GetNameOrDefault);
            Type            = type;
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new collection of the chart series.
        /// </summary>
        public SeriesCollection(IEnumerable <OpenXmlElement> sdkCharts, ChartPart sdkChartPart, IChartRefParser chartRefParser)
        {
            _chartRefParser = chartRefParser;
            Check.NotEmpty(sdkCharts, nameof(sdkCharts));
            Check.NotNull(sdkChartPart, nameof(sdkChartPart));

            var tempSeriesCollection = new LinkedList <Series>(); //TODO: make weak reference

            foreach (var nextSdkChart in sdkCharts)
            {
                Enum.TryParse(nextSdkChart.LocalName, true, out ChartType chartType);
                var nextSdkChartSeriesCollection = nextSdkChart.ChildElements
                                                   .Where(e => e.LocalName.Equals("ser", StringComparison.Ordinal));
                foreach (var sdkSeries in nextSdkChartSeriesCollection)
                {
                    var series = new Series(chartType, sdkSeries, sdkChartPart, _chartRefParser);
                    tempSeriesCollection.AddLast(series);
                }
            }

            CollectionItems = new List <Series>(tempSeriesCollection);
        }