private ChartFrame MapObject(DocumentObjectModel.Shapes.Charts.Chart domChart) { ChartFrame chartFrame = new ChartFrame(); chartFrame.Size = new XSize(domChart.Width.Point, domChart.Height.Point); chartFrame.Location = new XPoint(domChart.Left.Position.Point, domChart.Top.Position.Point); Chart chart = new Chart((ChartType)domChart.Type); if (!domChart.IsNull("XAxis")) { AxisMapper.Map(chart.XAxis, domChart.XAxis); } if (!domChart.IsNull("YAxis")) { AxisMapper.Map(chart.YAxis, domChart.YAxis); } PlotAreaMapper.Map(chart.PlotArea, domChart.PlotArea); SeriesCollectionMapper.Map(chart.SeriesCollection, domChart.SeriesCollection); LegendMapper.Map(chart, domChart); chart.DisplayBlanksAs = (BlankType)domChart.DisplayBlanksAs; chart.HasDataLabel = domChart.HasDataLabel; if (!domChart.IsNull("DataLabel")) { DataLabelMapper.Map(chart.DataLabel, domChart.DataLabel); } if (!domChart.IsNull("Style")) { FontMapper.Map(chart.Font, domChart.Document, domChart.Style); } if (!domChart.IsNull("Format.Font")) { FontMapper.Map(chart.Font, domChart.Format.Font); } if (!domChart.IsNull("XValues")) { XValuesMapper.Map(chart.XValues, domChart.XValues); } chartFrame.Add(chart); return(chartFrame); }
internal static void Map(DataLabel dataLabel, MigraDoc.DocumentObjectModel.Shapes.Charts.DataLabel domDataLabel) { DataLabelMapper mapper = new DataLabelMapper(); mapper.MapObject(dataLabel, domDataLabel); }
void MapObject(SeriesCollection seriesCollection, DocumentObjectModel.Shapes.Charts.SeriesCollection domSeriesCollection) { foreach (DocumentObjectModel.Shapes.Charts.Series domSeries in domSeriesCollection) { Series series = seriesCollection.AddSeries(); series.Name = domSeries.Name; if (domSeries.IsNull("ChartType")) { DocumentObjectModel.Shapes.Charts.Chart chart = (DocumentObjectModel.Shapes.Charts.Chart)DocumentObjectModel.DocumentRelations.GetParentOfType(domSeries, typeof(DocumentObjectModel.Shapes.Charts.Chart)); series.ChartType = (ChartType)chart.Type; } else { series.ChartType = (ChartType)domSeries.ChartType; } if (!domSeries.IsNull("DataLabel")) { DataLabelMapper.Map(series.DataLabel, domSeries.DataLabel); } if (!domSeries.IsNull("LineFormat")) { LineFormatMapper.Map(series.LineFormat, domSeries.LineFormat); } if (!domSeries.IsNull("FillFormat")) { FillFormatMapper.Map(series.FillFormat, domSeries.FillFormat); } series.HasDataLabel = domSeries.HasDataLabel; if (domSeries.MarkerBackgroundColor.IsEmpty) { series.MarkerBackgroundColor = XColor.Empty; } else { #if noCMYK series.MarkerBackgroundColor = XColor.FromArgb(domSeries.MarkerBackgroundColor.Argb); #else series.MarkerBackgroundColor = ColorHelper.ToXColor(domSeries.MarkerBackgroundColor, domSeries.Document.UseCmykColor); #endif } if (domSeries.MarkerForegroundColor.IsEmpty) { series.MarkerForegroundColor = XColor.Empty; } else { #if noCMYK series.MarkerForegroundColor = XColor.FromArgb(domSeries.MarkerForegroundColor.Argb); #else series.MarkerForegroundColor = ColorHelper.ToXColor(domSeries.MarkerForegroundColor, domSeries.Document.UseCmykColor); #endif } series.MarkerSize = domSeries.MarkerSize.Point; if (!domSeries.IsNull("MarkerStyle")) { series.MarkerStyle = (MarkerStyle)domSeries.MarkerStyle; } foreach (DocumentObjectModel.Shapes.Charts.Point domPoint in domSeries.Elements) { if (domPoint != null) { Point point = series.Add(domPoint.Value); FillFormatMapper.Map(point.FillFormat, domPoint.FillFormat); LineFormatMapper.Map(point.LineFormat, domPoint.LineFormat); } else { series.Add(double.NaN); } } } }
internal static void Map(DataLabel dataLabel, DocumentObjectModel.Shapes.Charts.DataLabel domDataLabel) { DataLabelMapper mapper = new DataLabelMapper(); mapper.MapObject(dataLabel, domDataLabel); }